5 ms·
Import in JavaScript is significantly more varied and complex than import in any other language I know about. There are multiple historical module systems, var
by smt88 5y ago
Import in JavaScript is significantly more varied and complex than import in any other language I know about.
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.
- morelisp 5y agoOn top of this, a lot of the tooling is just shit. I don't just mean it makes design decisions I disagree with (which is also true of e.g. Maven, or Bundler) or that they're lacking in niceties (e.g. every C development workflow), I mean it's just absolutely poorly implemented CADT-except-they're-actually-25-and-overcapitalized trash. 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.
- handrous 5y ago> Yarn blew NPM away on speed with more features and nicer developer workflow. 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.
- KptMarchewa 5y agoPython?
- morelisp 5y agoPython's packaging infrastructure is a mess, but the even the _environment_ surrounding import, let alone the module semantics, largely hasn't changed since the introduction of venv. 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.
- smt88 5y agoI think you may be referring to package management rather than the import syntax of the language.
- maccolgan 5y agoYou're saying Java & Maven/Gradle are simpler than even Nodejs or ESM workflows?
- dmitriid 5y agoMaven and Gradle have been around for years, and they are pretty much understood. 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. [1] https://tonsky.me/blog/python-build/ https://tonsky.me/blog/python-build/
- smt88 5y agoMaven and Gradle are build tools, similar to esbuild. 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.
- cxr 5y ago> Within the actual language, there isn't a universal syntax just to use a package. 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.
- smt88 5y agoI think you're misunderstanding what I'm saying. You're still talking about package managers and build systems. I'm talking only about syntax. TypeScript, NPM, esbuild, Gradle, and Maven are completely separate from what I'm talking about.
- andrei_says_ 5y agoAfter struggling to comprehend JS import and modules as much as I did as a single dev, I concluded that it’s my fault - that there’s something wrong with me. 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.