News for hackers. Stuff that matters.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by gernb on Friday May 27, 2022 @04:00AM (#31527135)
sounds like the same experience I have with pretty much every language I'm not used to.

I just want to try this C++, download, unzip, oh it's windows so .project file. Fine, redo on windows , oh it's 3 versions of vstuido old and says it wants to upgrade , okay. Hmm errors. Try to fix. Now it's getting linking error.

repeat the same with xcode and any project in c, c++, objc, swift

okay how about ruby? oh I have old ruby , hmmm , try to install new ruby, seems to run, but it can't find certain gems or something. oh and this other ruby thing I was using is now broken ? why do I have to install this stuff globally? You don't but there are several magic spells you must execute and runes you must set in the rigtt places. Oh ... I think I got that setup but it getting this new error.

....

I'm sypathetic it sucks but it's not unique to js

Re:Today’s JavaScript, from an outsider’s perspective (2020) by donatj on Friday May 27, 2022 @10:16AM (#31529900)
I have been writing JavaScript professionally for nearly 20 years. I try my damndest to keep up, but the fact of the matter is the ecosystem is garbage. It’s really not a not-knowing-the-language thing. It’s a legacy of years and years of incompatible tooling requiring even more tooling to work around nightmare scenario. Node modules not working in the browser without translation was the original sin that kicked the whole nightmare off.

Nothing ever works like a sane person would expect. When I do get a working typescript + webpack setup it’s almost entirely by accident. I stumbled upon something that works? Just avoid touching it at all costs.

Recently I wanted to load an AMD module in Deno and just about gave my self an aneurism before giving up hours later.

I have worked in dozens of languages over my career, and not encountered as much of a clusterf*ck as JavaScript anywhere else. I have never worked with anything before where so few people had any idea how it actually worked and just prayed that it continues.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by corrral on Friday May 27, 2022 @11:40AM (#31530871)
This seems like a great place to ask how the ever-loving shit you get a front-end project with simple NPM-fetched libraries to bundle into either a single .js file ready to go in a <script> tag, or a block of <script> tags with all the referenced .js files in a directory and ready to serve. Ideally with typescript support, but surely (ha. ha. ha. ha.) I can just tack that on top and point whatever-this-is at typescript's output directory and my package.json, so that shouldn't be a problem (yeah, right...).

I've written JS professionally for probably 12 or 13 out of the last 22 years, but I skipped the first couple iterations of frontend bundlers and tooling (kept rocking it old-school and just including plain .js files with script tags) until React, so I seem to have missed that intermediate phase, and now I cannot find it. I've lost probably 3 to 4 hours to trying to figure this out, last couple times I looked.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by SahAssar on Friday May 27, 2022 @12:14PM (#31531305)
For me esbuild has worked pretty well. Given a index.js as the entrypoint for your app:

  npx esbuild index.js --bundle --sourcemap --minify --outfile=out.js --format=esm
esbuild is also pretty quick and does not have a lot of npm depencencies thanks to being a go binary.

npx should download and run the binary for you and npx is almost always installed with node automatically.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by corrral on Friday May 27, 2022 @12:55PM (#31531844)
Thank you. It was really hard to figure out which tools even could do this so I knew which one I ought to deeply "RTFM" for, which was really frustrating to me because it seemed like the most obvious default behavior for any JS build/bundle tool, which should be what it did if you just typed "some-build-tool build" or "bundle" or whatever, from your project root with nothing but a package.json containing a "main" entry.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by SahAssar on Friday May 27, 2022 @01:47PM (#31532501)
I agree that this is really not a good experience. I prefer js projects that don't rely on build tools at all for this reason, but most devs, frameworks and libraries don't support such a use-case.

When I have to use build-tools I usually go for esbuild.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by fendy3002 on Friday May 27, 2022 @10:39AM (#31530188)
> Node modules not working in the browser without translation was the original sin that kicked the whole nightmare off

Uh what? It's literally the name itself "node"_modules, it's designed to be used with node. The fact that it use same language and can later be used by browser is another matter. Thankfully we can easily bundle the whole thing using webpack nowadays.

There are also countless boilerplate project with webpack setup already so you can get reference from there.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by donatj on Friday May 27, 2022 @10:47AM (#31530266)
> It's literally the name itself "node"_modules, it's designed to be used with node.

That’s the problem. It’s not JavaScript. It’s not any part of the ECMA standard, it doesn’t work in runtimes other than node (read: the browser) yet it lives in the .js files making them not truly JavaScript. You have split the language.

The syntax isn’t part of the language and was designed in such a way that it cannot be polyfilled. This lead to a thousand packagers that would not be necessary at all if a sane syntax had been chosen. The creator of node himself has said making node incompatible with the browser was one of his biggest mistakes.

https://medium.com/@imior/10-things-i-regret-about-node-js-r...

> There are also countless boilerplate project with webpack setup already so you can get reference from there.

That’s literally the other problem! People just copying boilerplate without understanding it. That’s not a proper solution. That’s not a maintainable project, that’s copying other peoples homework and getting yourself in over your head.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by fendy3002 on Friday May 27, 2022 @11:03AM (#31530444)
If anything, it's not the fault of javascript, it's on node. However finding the popularity of it means that somewhat it's more suitable for many devs than the alternatives.

Well I can understand it. As I've used the previous generation of jQuery, knockout, etc, nodejs and it's tooling makes things easier to scale, even with bigger overhead cost.

EDIT:

> That’s literally the other problem! People just copying boilerplate without understanding it. That’s not a proper solution. That’s not a maintainable project, that’s copying other peoples homework and getting yourself in over your head.

Copy, make it run well, modify, learn is how I learn things. Without working example, it's magnitude times harder to learn something. The fact that people copy and use without trying to understand things is their fault, not the hundreds of boilerplate code.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by marpstar on Friday May 27, 2022 @10:45AM (#31530256)
Not that I agree with the GP, but I think it’s easy to conflate “node”_modules with “modules from NPM”. Bower was once the recommended package manager for front-end assets, but NPM overtook it. I use Node daily, but 90% of my packages are front end.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by fendy3002 on Friday May 27, 2022 @11:08AM (#31530489)
Uh yeah, the fact that people using npm for frontend too means alternative front end package managers isn't as good (or as suitable) as npm. I take it as even though NPM isn't aimed for that, it works well.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by franciscop on Friday May 27, 2022 @11:26AM (#31530716)
Typescript IS a different language than Javascript (for good or for bad), meaning you are compounding the issues with Javascript ecosystem with the issues with Typescript compilation.

Most of my code today is very straightforward, start a project, add type: module and 90% of the packages will work. If it doesn't, I either pick one of the 1M+ alternatives, try to decipher the issue (often is changing the import format or entrypoint), or avoid using a package for the problem I was trying to solve if trivial enough.

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?

Re:Today’s JavaScript, from an outsider’s perspective (2020) by jiggawatts on Friday May 27, 2022 @04:42AM (#31527390)
Meanwhile I've been trying to warn the Rust project team, or more specifically, the Cargo/Crates teams that they're cheerfully skipping down the easy/happy path towards the same mess.

It's inevitable that the conclusion will be the same if the same steps are taken in the same direction. The counter-arguments fail to recognise the special case of "most of us are from Mozilla and we all get along[1]", "no-one has attacked us yet so no-one ever will[2]", "it's tracktable to untangle the dependency hell in your head because there aren't that many crates (yet)", and of course "we all know this history like the back of our hand, because we've all been around since v0.1 alpha."

I'm picturing "10 years later" when some junior developer at MegaCorp Inc desperately tries to figure out why the legacy Rust 2018 version he's forced to use in 2032 can't compile some privately hosted crate that's needed for an enterprise project. It'll probably depend on a specific version of a crate that was yanked because some transitive dependency had to be yanked because that guy was a Russian kid that sold access to this popular crate for $500 to Israeli spies. Of course now the patched crate requires Rust 2030 or whatever, breaking fifty seven of the two thousand transitive crates being pulled it, so good luck to him with disentangling that mess and making this work.

PS: I wish I was making this story up, but I basically just changed Angular to Rust for a real thing that happened to me, like... a month ago. There is no fundamental difference to how Rust does packages, it's just younger so the mess hasn't accumulated to Angular's levels of madness. Give it time...

[1] Except for that spat with the core team.

[2] That we know of. Ignore the guy spamming popular, single-word crate names and shovelling in 99.9% C/C++ code with the thinnest possible Rust wrapper. Surprise! Your code is now more C++ than Rust.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by pie_flavor on Friday May 27, 2022 @12:11PM (#31531257)
Yanking crates does not get rid of their code; you can still depend on them in your crates, you just can't upload those crates to crates.io.

Editions are not lock-in; the entire point of the edition system is to allow the version of Rust that exists in 2032 to compile every prior edition in the same project at once, and only single crates at a time have to be 2030 edition.

Before making any change that could possibly be breaking, the change is tested on every single crate on crates.io, as well as on a great many GitHub repos that aren't, in order to make sure there aren't any regressions (referred to as a crater run).

You are right that the problems you describe would be problems if Rust was implemented the way you're implying. That is why Rust was not implemented the way you're implying, but rather implemented specifically to avoid these problems.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by MrJohz on Friday May 27, 2022 @11:38AM (#31530856)
You're description of the versioning issue doesn't make much sense to me, at least assuming you're talking about editions. Editions are guaranteed to be supported indefinitely, and different crates can have different editions while still being entirely compatible with each other. So a 2032 compiler should be entirely able to continue compiling the 2018 project, even though the depended-on crate is now using the 2030 edition.

The way you describe yanking also seems a bit confusing. If the original project had a dependency that was yanked for security concerns, then the original project was already compromised in the first place. Even then, assuming the lockfile was checked in, then it should still be possible to download the yanked file (plus the compromising code, although the act of downloading a yanked file produces a warning, I believe). If you mean that the project was working fine (no compromise) and then a later version of the dependency was compromised, then no changes are needed at all - the lockfile will always ensure the exact same version is downloaded.

If you genuinely think you've found a situation that isn't solved by the edition mechanism, or by the judicious use of lockfiles for all projects, then I'm sure the Rust team would love to hear it (although I can't speak for them). But from what it sounds like, you're describing issues with the Node ecosystem and assuming they also apply to Rust, despite a number of differences in how the two ecosystems operate.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by IshKebab on Friday May 27, 2022 @05:29AM (#31527614)
I don't think the Rust team are unaware of supply chain attacks, so you don't need to warn them. It's just that there's no easy solution. Or do you have some easy solution they aren't doing. Just to pre-empt you, namespacing doesn't solve the issue and manually vetting authors/crates is not something the Rust community wants.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by reificator on Friday May 27, 2022 @11:48AM (#31530989)
Namespaces do not solve the issue but they do mitigate a specific vector, while also removing a perceived need to preregister crates.

There’s no downside beyond “it requires development time and maintenance” like any other feature.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by IshKebab on Friday May 27, 2022 @12:47PM (#31531726)
What vector do they mitigate? And why would they remove the perceived need to preregister crates (or namespaces)?
Re:Today’s JavaScript, from an outsider’s perspective (2020) by vaughandroid on Friday May 27, 2022 @05:08AM (#31527515)
You've obviously thought about this quite a bit... Do you have any ideas as to how projects could avoid this problem?
Re:Today’s JavaScript, from an outsider’s perspective (2020) by jiggawatts on Friday May 27, 2022 @06:30AM (#31527956)
I have, but to be honest I've forgotten a lot of the specific debates and their finer points.

I don't have a single, definitive, clear solution -- as pointed out by others -- nobody does. It's not a simple problem.

That doesn't mean that steps can't be taken to improve the situation, perhaps dramatically in some cases.

1) Enforced MFA to publish a crate -- credential theft is semi-regularly seen as an attack vector.

2) Strong links between the "source ref" and the specific crate versions. An example of this done super badly is NuGet. All of the hundreds (thousands?) of Microsoft ASP.NET packages point to the same top-level asp.net or .net framework URLs. E.g.:

https://www.nuget.org/packages/Microsoft.Extensions.Configur...

Links to "https://dot.net" as the Project Website, and "https://github.com/dotnet/runtime" as the repository. This couldn't be more useless. Where is the Git hash for the specific change that "7.0.0-preview.4.22229.4" of this library represents? Who knows...

3) Namespaces. They're literally just folders. If you can't code this, don't run a huge public website. This is more important than it sounds, because wildly unrelated codebases might have very similar names, and it's all too easy to accidentally drag in entire "ecosystems" of packages. Think of the Apache Project. It's fine and all if you've "bought in" to the Apache way of doing... everything. But imagine accidentally importing some Google thing, some Netflix thing, some Apache thing, and some Microsoft thing into the same project. Now your 2 KLOC EXE is 574 megabytes and requires 'cc', 'python', and 'pwsh' to build. Awesome.

For example, in ASP.NET projects I avoid anything not officially published by Microsoft and with at least 10M downloads because otherwise it's guaranteed to be a disaster in 5-10 years. Ecosystems diverge, wildly, and no single programmer or even a small group could possibly stitch them back together again. Either it's a dead end of no further upgrades, or rip & replace an entire stack of deeply integrated things.

4) Publisher-verified crate metadata / tags. You just cannot rely on the authors to be honest. It's not even about attacks, it's also about consistency and quality. All crates should be compiled by the hosting provider in isolated docker containers or VMs using a special "instrumented build" flag. Every transitive dependency should be indexed. Platform compatibility should be verified. Toolchain version compatibility should be established for the both the min and max range. Flags like "no-std" or whatever should be automatically checked. CPU and platform compatibility would also be very helpful for a lot of users. The most important one in the Rust world would be the "No unsafe code" tag.

This would stop "soft attacks" such as the guy spamming C++ libraries as Rust crates. Every such crate should have been automatically labelled as: "Requires CC" and "Less than 10% Rust code".

Similarly, if a crate/package changes its public signature in a breaking way, then the publishing system should enforce the right type of semantic versioning bump.

Essentially, what I would like to see is something more akin to a monorepo, but not technically a single repository. That is, a bunch of independent developers doing their own thing, but with a cloud-hosted central set of tooling that helps gain the same benefits as a monorepo.

I'm expecting a lot of arguments along the lines of "that sounds like a lot of work, etc..." Meanwhile Mozilla had a large team for this, millions of dollars of funding, and did not do even 0.1% of what Matt Godbolt did in his spare time...

Re:Today’s JavaScript, from an outsider’s perspective (2020) by j-krieger on Friday May 27, 2022 @08:27AM (#31528761)
Good answer. Here is one more, and I got to say I am really unsure why it isn't done this way: Check each update to a crate for the usage of a TCP / HTTP / UDP stack usage. There is absolutely no reason a crate for math (for example) should be introducing any of that in its code. If you catch something like this, you can be 99% sure it's malware.

Or even better, make crates request permissions for what kind of functions they can call, similar to the chrome plugin API. A graph crate doesn't need encryption, file opening or netstack permissions.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by echelon on Friday May 27, 2022 @10:54AM (#31530355)
Transitive crate "permissions" would be amazing. To know at a glance if a crate does networking, filesystem access, IO, etc.

Someone could always roll their own IO, but self reporting and automated detection tooling (to catch those that slip through the cracks) would bring this percentage way down.

Maybe the language could even evolve "unsafe" for IO, even if just as a flag for users. That way it would all be incredibly easy to audit.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by ashishbijlani on Friday May 27, 2022 @01:06PM (#31531980)
Packj tool (https://github.com/ossillate-inc/packj) analyzes Python/NPM packages for risky code and attributes such as Network/File permissions expired email domains. It uses static code analysis. We are adding support for Rust. We found a bunch of malicious packages on PyPI using the tool, which have now been taken down: examples https://packj.dev/malware [disclosure: I’m one of the developers]
Re:Today’s JavaScript, from an outsider’s perspective (2020) by samsquire on Friday May 27, 2022 @10:36AM (#31530145)
One of my thoughts (see my profile) is "library mesh". You could register your code (or the parts that integrate) as a reverse dependency on what you depend on and they should build your code as part of their build to see if anything breaks.

Refactoring breaks everything - just look at Python 2 to Python 3. Part of the problem is having a bill of materials and having accurate tracing of the ingredients of a build, such as reproducible builds. But the time investment in these is hard work.

Computers are good at cross referencing. If you indexed everything in a graph database. It should be a simple graph Search to find dependencies of a git commit hash, binary sha256 installer file. And a web of sha256 relationships. And mapping between them and commit shas. It would be useful for security too but also interested in things being robust and reliable. Like you say it's a monorepository but not one.

Tooling is what's needed

The python packaging experience and ruby bundler and npm and other version manager experiences simply leads to common breakage.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by marcosdumay on Friday May 27, 2022 @12:12PM (#31531280)
> Similarly, if a crate/package changes its public signature in a breaking way, then the publishing system should enforce the right type of semantic versioning bump.

A common following-up question the Haskell people used to say when that was being discussed there is, if your build system can do that, why do you need semantic versioning for?

Still, it's better than doing nothing. There's nothing similar to Stackage or Backpack on Rust, so it would be a clear gain. It's just that you can go further.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by Semaphor on Friday May 27, 2022 @11:01AM (#31530422)
I work with a lot of .NET Framework legacy code. Those nuget packages have even more useless links, I’ve had both official packages 404ing (to be fair, making their own links 404 is a specialty of Microsoft, for documentation they have the opposite approach as for windows, nothing should be backwards compatible -.-) but more often link to some modern .NET core (or .NET 6 now I guess) and thus be completely unrelated.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by bowsamic on Friday May 27, 2022 @05:04AM (#31527491)
Yep, the Rust team and even the wider community are literally just ignoring this problem under the justification of "it's too early to care about these things yet".
Re:Today’s JavaScript, from an outsider’s perspective (2020) by pie_flavor on Friday May 27, 2022 @12:12PM (#31531284)
Rust has been designed specifically to avoid these problems, under the justification 'it's never too early to care about these things'. I wonder what on earth you have been reading.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by moochmooch on Friday May 27, 2022 @11:05AM (#31530456)
whinging about supply chain security is the bikeshedding topic of 2022
Re:Today’s JavaScript, from an outsider’s perspective (2020) by bborud on Friday May 27, 2022 @05:26AM (#31527596)
You are probably right, but there are differences. Languages like Go and Rust are much easier to get started with since they have better tooling, and more importantly, the tooling has a smaller and more regular surface. This is immensely important. Granted, they occasionally have unnecessary and stupid quirks, but they tend to be small (in terms of cognitive footprint) and contained.

In my neck of the woods, Python is the major source of time spent trying to get other people's code to run on my machine. The path of least resistance for Python developers tends to produce code that requires you to go through an easter egg hunt to make it run outside the original author's machine.

Yes, you could write Python utilities that are easy to install and run, but people don't. And the last bit of that sentence is the one that actually counts. "Could have" doesn't actually count in an engineering context. If the consumer has to assemble and repair software before getting it to run, the developer isn't being very professional.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by mojuba on Friday May 27, 2022 @04:42AM (#31527393)
I think static languages are generally more disciplined and manageable in this regard. The only times I struggled with 3rd party Swift code was when a package included some C or C++ code alongside with Swift.

Specifically, I think Apple's philosophy of "everything comes with its own dependencies embedded" saved us a lot of trouble. Sure, it's more disk space and potentially lots of duplicates (just count the number of times various SSL libs are included in a single large and messy application), but it usually just works.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by enlyth on Friday May 27, 2022 @05:43AM (#31527685)
I had a similar experience with Rust when I first tried it a couple years ago. Wanted to make a web server which returns Hello World, and then this crate doesn't compile, this official example from the README throws a compilation error, that crate is the wrong version, etc etc. I tried again today and got it done in 2 minutes, so it seems things have improved.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by astrange on Friday May 27, 2022 @04:47AM (#31527422)
MachO has some features that make this easier than ELF, namely matching libraries by full path and two-level namespaces (external symbols know which library they're found in).

Though it's still not great if everyone uses their own SSL library, because then you can't update it if there's a bug.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by mojuba on Friday May 27, 2022 @05:32AM (#31527628)
Yes it's a problem, but because you (as a library maintainer) are responsible for what you are embedding, you should keep an eye on the dependencies and test them with each update. This creates a hierarchy of responsibilities, as opposed to a flat mess that is Linux .so or Windows .dll approach.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by aeturnum on Friday May 27, 2022 @11:44AM (#31530946)
I agree that the C family has some similar problems but I think you're missing part of what makes Javascript uniquely frustrating.

Javascript is deployed in many different environments and you need to learn not just how to include a library in each environment, but also how to interact with that library. Also unlike C or other languages - Javascript has a hard time warning you about when you've imported something the wrong way. C can at least tell you "this does not link" (so it was found but is binary incompatible) - in my experience if you copy and paste a node import line in the browser the browser will just say "this does not make sense to me." C gives more breadcrumbs.

I also think that once you get outside the C-likes, the story is universally better. For all of its packaging flaws, it's easy to get python packages for development.

Every time I want to make something in Javascript I'm frustrated all over again by how I need to know details about the Javascript ecosystem that I have no way of knowing at this stage (like: getting to hello world can require a working knowledge of WebPack). It's just no where near that bad other places.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by greggman3 on Friday May 27, 2022 @12:04PM (#31531190)
I get it's frustrating but ... do you expect any Lua to run in every environment Lua is used in? AFAICT no 2 Lua's are alike and nearly ever use of it has it's own APIs and quirks. I have the same issue with C. You can find some C that will run anywhere. You can also find lots of C that is platform specific and unless you're an expert you'll be just as frustrated trying to get it to run on a different platform. Seems the same to me.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by aeturnum on Friday May 27, 2022 @01:42PM (#31532453)
> do you expect any Lua to run in every environment Lua is used in?

I do not, but again - I think "I should be able to run any version of a language in any place" is not related to "it is strangely hard to run a given Javascript file."

I actually think Lua is a great example for comparison that illustrates the point! Different Luas support different features, but the basics (import statements, etc) are syntactically valid (and singular) in all of them. If you try to import a library that doesn't exist in the version you've embedded, you will get an import error. In Javascript - there are multiple import systems for different ecosystems. Getting an import error might mean you need to install the library, it might mean you're using the wrong convention, it might mean that the version of the library has a compilation error....etc. Javascript does not really help you resolve this.

What this means is that there's a clean separation between environment and language. If your Lua deploy supports all the features your script uses, you are good - there are no "families" of Lua script that use different conventions for importing libraries or interop or whatever. A given piece of Javascript, however, has an arbitrary number of deployment-specific setup actions that require pretty advanced ecosystem knowledge to identify.

Like, look back at the errors listed in the article. There's nothing "wrong" with the restrictions, but the language ecosystem does an unusually bad job of helping you understand and navigate them. Like, you can have two or three different import mechanisms for different environments...but if you want to do that you should be more helpful in pointing out when you're using the wrong one.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by lolinder on Friday May 27, 2022 @04:32PM (#31534534)
Hello world in JS doesn't require WebPack in any environment. This JS file will run just fine in both the browser, node, deno, whatever:

    console.log("Hello, World")
There's absolutely nothing to stop you or anyone else from writing a JS file, importing it into an HTML file, and hosting both on GitHub pages. With ES modules you can now split your code into different files that import each other, and it all just works. No build step, no webpack, just JS files behind a server of some kind.

Meanwhile, if you're interested in using someone else's code, the CDNs are all still there. Vue, JQuery, lodash, and many other libraries are available for import directly into your HTML file.

A lot of people in this thread are conflating "all the tutorials tell beginners to do things the hard way" with "JavaScript is now a harder language to get started with than it once was".

Re:Today’s JavaScript, from an outsider’s perspective (2020) by tyingq on Friday May 27, 2022 @11:14AM (#31530541)
There are some ecosystems where the experience is different. Perl, for example, does have deprecations, but not many. It's fairly common to be able to run 30 year old code unmodified, or with very minor changes. Of course, it has it's own issues, but it is very stable across time.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by corrral on Friday May 27, 2022 @11:49AM (#31531000)
One shock if you go back and forth between Javascript and, say, Java, is adjusting your library evaluation criteria.

It's not weird for a Java project to include a library that hasn't had any updates in 4+ years. Sometimes those sorts of libraries are even considered the standard for whatever thing they do.

Meanwhile in JS you have to assume a library with no releases in the last 6 months has already bitrotted to death.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by synthmeat on Friday May 27, 2022 @04:24AM (#31527280)
Go is yet to prove its stability over timespans similar to those languages you've mentioned, but it doesn't have many of noted (and similar) quirks.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by divan on Friday May 27, 2022 @04:41AM (#31527379)
I recently had to work on a library I wrote in Go in late 2013. I think it was Go 1.2 back then. (Current release is Go 1.18)

It just worked.

And code was quite readable. I mean it not as a complement to myself, rather the fact that Go is designed to be readable and it pays off.

I only had to add modules support (basically run `go mod init` in the library's folder) to make it 100% modern-version friendly.

That was as close as I could be to successfully complete 10 Years Reproducibility Challenge [1].

[1] https://github.com/ReScience/ten-years

Re:Today’s JavaScript, from an outsider’s perspective (2020) by kaba0 on Saturday May 28, 2022 @12:51PM (#31541800)
I don’t think it is that impressive, though I have the most experience with Java, where a fat jar on a random, obsolete website displaying some university material will just work.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by divan on Sunday May 29, 2022 @01:34PM (#31550968)
To make your comparison with fat jars closer to the point, imagine you got the source code from the owner of that old obsolete website, and need to use it in your newest Java project, with the bleeding version of Java, gradle and all the stuff.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by rat9988 on Friday May 27, 2022 @04:31AM (#31527324)
My old go code doesn't compile anymore with the newer compiler versions
Re:Today’s JavaScript, from an outsider’s perspective (2020) by synthmeat on Friday May 27, 2022 @04:37AM (#31527351)
What was it that broke it? Usage of unsafe? Security and bug fixes in the compiler/tooling? Just interested.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by jcalabro on Friday May 27, 2022 @11:15AM (#31530564)
The Go 1 promise[0] says that the language spec and set of core libraries will be backwards compatible. I maintain a few dozen go projects, some of which are 10 years old, and while upgrading from i.e. 1.4 -> 1.18 has been relatively easy, it definitely has not been zero work. There are changes in the tooling, dependency ecosystem, deprecated dependencies that should be replaced, runtime behavior differences, things like that. But the language itself and stdlib is totally stable.

[0] https://go.dev/doc/go1compat

Re:Today’s JavaScript, from an outsider’s perspective (2020) by rat9988 on Friday May 27, 2022 @06:15AM (#31527871)
I didn't try for a long time I have a hard time remembering. I believe it had something to do about how it handles dependencies.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by coopierez on Friday May 27, 2022 @07:58AM (#31528498)
Its dependency management used to be a real mess though. It has got a lot better in recent years.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by Gigachad on Friday May 27, 2022 @05:17AM (#31527561)
I'm also sympathetic to the author but don't really see it as a problem. NPM modules are not apps on the App Store. They aren't intended to just be run by regular people quickly. The steps described in the article show someone hitting Node.js with a hammer until it gets closer to doing what they want without any understanding of what is going on. Which is fine, that's what people do often, but it isn't a failing of the tools when this doesn't work.

I don't expect to walk in to a workshop and find the welding tools intuitive to use with no training, and I don't expect npm modules to be intuitive to an outsider either.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by lodovic on Friday May 27, 2022 @07:28AM (#31528299)
Sure, but that is how it's sold: NodeJS and Javascript are marketed as super easy, perfect for beginners. They're not, in my opinion.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by trivialsoup on Friday May 27, 2022 @10:33AM (#31530115)
If you listen to marketers fast cars make you younger and handsomer and give you a full head of hair.

Don’t look at how things are sold, look at how they are. In this case it’s code, of course there’s complexity.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by Madmallard on Friday May 27, 2022 @04:13AM (#31527208)
Stacks being nonfunctional on install is a failure not progress
Re:Today’s JavaScript, from an outsider’s perspective (2020) by hyperpallium2 on Friday May 27, 2022 @05:16AM (#31527555)
It is unique to old languages.

Young languages are easy to get started in. Ruby used to be.

Though ruby has a separate problem of breaking changes. The back-compatibility crowd can run old code (e.g. java), but at the cost of their soul.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by lelanthran on Friday May 27, 2022 @05:32AM (#31527629)
> It is unique to old languages.

Rust is a new language, and it has the same complaints above.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by the__alchemist on Friday May 27, 2022 @10:48AM (#31530276)
I think C and C++ are a fair comparison in that their build ecosystems also a bit of a mess. I offer 3 counter-examples: Rust, Python, and JS-without-NPM.

edit: After reflection, I think Python straddles a middle ground. If you use modern packages and Python 3, it can be a smooth experience. If you use older (improperly-specified) packages, or FFI-wrapped-libs, it can turn into a mess too.

Re:Today’s JavaScript, from an outsider’s perspective (2020) by psyc on Friday May 27, 2022 @07:33AM (#31528330)
This is yak shaving. I mainly but not exclusively encounter yak shaving when, against my better judgement, I venture into the Opensourcelands. 10x more of it there, at any rate.
Re:Today’s JavaScript, from an outsider’s perspective (2020) by lysecret on Friday May 27, 2022 @10:55AM (#31530363)
this is why i love docker :D