News for hackers. Stuff that matters.
Re:Detecting the use of “curl | bash” server side by pitsnatch on Tuesday December 27, 2022 @11:56AM (#34150536)
Why is this the case?
Re:Detecting the use of “curl | bash” server side by raverbashing on Tuesday December 27, 2022 @12:53PM (#34151417)
Because JS had a very poor stdlib and attracted people that had little to no experience in best-practices in older languages

Hence left-pad. And this pet-peeve of mine https://nodejs.org/docs/latest/api/process.html#processargv (who cares about the node fullpath in argv[0]?)

Re:Detecting the use of “curl | bash” server side by SpeedilyDamage on Tuesday December 27, 2022 @01:04PM (#34151563)
Why oh why do people cite left-pad like this as an example of package bloat? It’s functionality was so valuable it was included in ECMAScript 2017!

The problem with left pad was a security one, not a package bloat one.

Re:Detecting the use of “curl | bash” server side by gfxgirl on Tuesday December 27, 2022 @01:19PM (#34151777)
No, the problem is bad developers pulling in dependencies for trivial functionally. If there was a `for-loop` npm package bad devs would be pulling it in instead of writing their own for loops. Padding on the left is something if it doesn't exist you write it in a few lines of code yourself. You don't add a package for such trivial functionality.
Re:Detecting the use of “curl | bash” server side by SpeedilyDamage on Tuesday December 27, 2022 @03:49PM (#34153595)
Nope, this is a bad take, parroted without understanding; if it got moved into the std lib, it was probably useful enough. You can even read why in the original proposal if you comb the archives enough (from https://github.com/tc39/proposal-string-pad-start-end):

> It is highly probable that the majority of current string padding implementations are inefficient. Bringing this into the platform will improve performance of the web, and developer productivity as they no longer have to implement these common functions.

“It’s too trivial” is not why left-pad was in the news. Go read about it to understand the actual issue: https://www.theregister.com/AMP/2017/07/12/javascript_spec_s...

Re:Detecting the use of “curl | bash” server side by raverbashing on Tuesday December 27, 2022 @05:36PM (#34154806)
> if it got moved into the std lib, it was probably useful enough

Of course it was useful, hence why most non-crappy languages had it in its stdlib from inception pretty much

But building a package just to do left-pad is stupid, especially since it can be implemented in a couple of lines

Re:Detecting the use of “curl | bash” server side by SpeedilyDamage on Tuesday December 27, 2022 @05:40PM (#34154831)
You can’t both believe it’s worth putting in the stdlib and not worth importing a library for, if your intention is to be consistent.
Re:Detecting the use of “curl | bash” server side by Too on Wednesday December 28, 2022 @04:03AM (#34159019)
You are neglecting the risk-factor of pulling in libraries from unknown authors on npm vs the stdlib. The package-bloat problem is one of culture, where developers keep neglecting this risk, only seeing the 5 lines of code they save by importing something, without seeing the potential cost and tech debt of having to review, maintain, update and security-monitor this dependency for all future.

Nobody thinks leftPad was not a useful function. The question is, was it useful enough to counter all the risks of npm, probably not. In the stdlib there is no such risk.

Re:Detecting the use of “curl | bash” server side by SpeedilyDamage on Wednesday December 28, 2022 @08:19AM (#34160668)
Ah, and now we’re talking about the real issue, which was the security risk.

My point has been this whole time that left-pad was not a story of a trivial function needlessly pulled from an external source as the person I replied to had claimed, and it appears you agree. Good!

Re:Detecting the use of “curl | bash” server side by encoderer on Tuesday December 27, 2022 @01:19PM (#34151774)
No that’s his point.

Why on earth did it take until 2017 to add a trivial thing that nearly everybody needs at some point? It creates a need for super popular 3rd party “packages” just to do some basic data structure manipulation.

Re:Detecting the use of “curl | bash” server side by dtgriscom on Tuesday December 27, 2022 @01:48PM (#34152168)
Here's my theory. Older programming languages force you to think about sub-dependencies: if you decided to use a third-party library, you would have to look at and manually add its requirements to your build system.

But, with npm, suddenly it was trivial to include other packages without having to worry about sub-dependencies. The whole tree just magically added itself to your build, and only if you paid attention to the build process would you discover just how many developers you were transitively trusting.

Re:Detecting the use of “curl | bash” server side by marcosdumay on Tuesday December 27, 2022 @04:13PM (#34153879)
Well, while yes, automatic dependency management is a really relevant reason why things got that bad, it can't be the only reason.

Programs in other languages with the same kind of tooling tend to stop at hundreds or at most low-thousands of dependencies. Javascript code often reach tens or low-hundreds of thousands of dependencies.

Dependency explosion is bad all around, but JS is exceptionally bad.

Re:Detecting the use of “curl | bash” server side by scotteric on Tuesday December 27, 2022 @02:48PM (#34152904)
Javascript lacks many basic facilities that other languages have.