News for hackers. Stuff that matters.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by jdminhbg on Friday May 27, 2022 @12:23PM (#31531396)
> Node modules not working in the browser without translation was the original sin that kicked the whole nightmare off.

Node modules are just a reaction to the actual original sin, which is building a popular language that essentially had no standard library. I suppose that's the kind of thing that will happen when you have to build one in a matter of weeks, but everything from webpack to left_pad is essentially the fault of the language not having a standard library.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by krapp on Friday May 27, 2022 @01:03PM (#31531938)
The language has a standard library fit for its intended purpose - scripting the DOM.

Moving javascript out of the browser and trying to use it as a one-size-fits-all replacement for everything from systems to application programming, and every language from C++ to Java, is the original sin. Stop complaining because Brendan Eich's toy scripting language isn't a good replacement for things it was never meant to be used for. A screwdriver isn't a good hammer, either.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by jdminhbg on Friday May 27, 2022 @01:15PM (#31532101)
Given how many front-end packages are on NPM, it's obviously not the case that the libraries provided were sufficient for scripting the DOM. Just take left_pad itself, that's something the language should provide, and it's an issue that it ended up being a point of failure.

I have no particular love for using JS as a language to power everything from IoT devices to web servers, but it doesn't really matter how I feel about it. It's not going anywhere.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by krapp on Friday May 27, 2022 @06:34PM (#31535698)
>Just take left_pad itself, that's something the language should provide, and it's an issue that it ended up being a point of failure.

Why should the language provide that? What other languages provide an equivalent to that? left_pad is intended for formatting text within a terminal, not a website. There's no need for it within the context of a website, because HTML has tables, CSS and other elements for that.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by deergomoo on Saturday May 28, 2022 @07:53AM (#31539590)
> What other languages provide an equivalent to that?

https://www.php.net/manual/en/function.str-pad.php

https://docs.ruby-lang.org/en/3.1/String.html

https://developer.apple.com/documentation/foundation/nsstrin...

> left_pad is intended for formatting text within a terminal, not a website. There's no need for it within the context of a website

This is just not correct. It’s for padding a string with any character, for example adding leading zeroes to a number for display purposes. There are plenty of reasons to want to do that in a browser.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by unsupp0rted on Friday May 27, 2022 @05:03PM (#31534855)
Is there an NPM module that serves as a standard library?

My code is a combo of lodash bits, datefns, helper regexes I’ve curated over the years, etc

Is there a standard library-like package that you import on most projects?