by betageek · 5y ago · 0 comments
Knowing nothing about Java, I wouldn't expect to open a Java file and know what every line means. There's a million reasons to find modern web dev complicated but not taking the time to google "js import" is not one of them. Also I wouldn't expect to "just know" how to take a Java program and build it in a way that I could host it somewhere, I'd expect to have to work at it.
I consider myself having deeper knowledge about JS and node than any other language, having spent more total time in it than anything else (except maybe bash).
I have a clearer understanding of what import/require really does in most other languages.
The flow-chart complexity and possible outcomes of what `import` really does in JS/TS are certainly greater than anything else I've encountered.
(I do find go's repository-based approach quite frustrating to work with when forking dependencies but at least it's straight-forward)
If I understand your point correctly, then that's a non-issue since modules are here.
In the go.mod file you have the current module name, and all imports of yourself will use the current repository, instead of calling the original.
So you fork the repository, but keep the original name in the go.mod file, then you don't have to modify any imports.
https://golang.org/doc/modules/managing-dependencies#unpubli...
I still find the whole gopath/gomodules thing unfortunate but it is what it is at this point (and frankly that’s a bit out scope since we’re talking imports here.. if we’re talking about the state of packaging then JS absolutely has competition; e.g. https://xkcd.com/1987/)
There are multiple historical module systems, various official and unofficial syntaxes, and also the require keyword.
It is an absolute mess. I don't know anyone who understands all of the various flavors.
Yarn blew NPM away on speed with more features and nicer developer workflow. Webpack is on major version 5 and still everyone just uses CRA rather than try to configure it by hand, but then nobody really knows how to debug CRA if something breaks. The entire babel stack is ridiculous. The dominant tools have just been so awful, for so long.
I dunno if it's still true, but for years into people saying "LOL use yarn, it's a better replacement for NPM" it was still really easy to find packages that broke under Yarn because it lacked some feature or other, or was skipping some obviously-a-good-idea sanity check that NPM did and so crashed rather than proceeding after adjusting its approach, or to venture slightly off the happy path of doing "yarn install" and running into features that yarn didn't support, but NPM did. A venture into the issue tracker in that time period was enlightening, and I don't just mean the sheer count, but digging into some of the issues and why they were happening.
[EDIT] in fact, in the agency I was at at the time, a kind of joke developed that a project wasn't fully underway until you'd been forced to replace Yarn with NPM.
I was talking about import in JavaScript itself, not build tools or package managers.
Within the actual language, there isn't a universal syntax just to use a package. In Java, there is.
There is. The issue is one of mindset. You recognize Maven and Gradle as belonging to a sort of "parastandard" set of technology, offering proprietary (albeit free/open source) glimpses of how one could conceivably solve the set of problems that they're meant to be used for, but when it comes to JS, you're elevating the parastandard stuff to the level of being part of "JS".
Neither CommonJS nor NodeJS's `require` nor package.json nor TypeScript nor esbuild are part of JS. You shouldn't give them any privileged status that you aren't willing to give to Maven or Gradle when you think of Java.
Moreover, you can skip them entirely and roll your own in a couple of hours [1]
Meanwhile in JS world? Build tools now change faster than frameworks, and not a single person is concerned with upgrade paths, or working in tandem with other tools.
And yes, import story is a mess.
I had to read the MDN guides multiple times and still need to refer to them.
Setting the build system part for my new projects is still the most challenging task.
Why do I have to learn how to build a grand piano every time I want to play a simple melody?
require ‘thing’ in Ruby requires the thing and that’s it.
require in JS should be use i. Node but not in the browser if I remember? Or maybe not? I don’t know, I guess I’ll just try things y til it works.
For all the other failings of the Python 3 migration, the Python community strongly and rightly rejected 2to3 which would've eventually produced a babelesque mess if continued.
NPM, import, etc. seem mindbogglingly complex in comparison, with an enormous number of ways to do each thing, most of which require at least one build step <script> just doesn't, and enormous numbers of third party dependencies, and if you go away for a few months and come back, there are good odds things will be different and broken.
Like Julia, I don't understand JS build systems and packaging etc., which no doubt contributes to the above experience, but I'm comparing to <script>, whose simplicity is almost unbeatable.
The most simple example is almost never a representative example that can be used as a standard to hold the whole language to.
In the same vein, one could say: "See how easy it is to build a C program with `gcc main.c`? Why should I have to figure out how to use make?". And the answer is simple: Most projects that go beyond a toy example have much more elaborate requirements(/whishes), like "I'd like to reuse code that another person has written in the past so I don't have to do it".
Ignoring the nullified value proposition, there are other reasons besides (like security) to reject what the NodeJS/NPM world considers standard practice.
I may simply have got lucky so far with that but it's worked really nicely for me for quick things where I don't care about bundling.
I feel like JS gets thrown under the bus in discussions, but no body talks about arcane file structures in Java or implicit pathing lookups which have the same kind of "historical path dependence" to why they exist as JS has for require/import.
All languages have their warts and 99% of the time they're all doing the same thing just in slightly different ways.