Today’s Javascript, from an outsider’s perspective
lea.verou.me
lea.verou.me
However, I initially learned some Python in university and I liked it then. We just installed Idle and ran some simple scripts, and everything worked. That's the right way to learn a language. If you dive straight into JS package management, you are attempting to learn multiple things at the same time:
* Node.js environment
* Browser environment
* JavaScript syntax
* 'running a localhost'
* JavaScript modules
* NPM package management
You need to tackle these one by one. If you do them all at once, even with prior experience in other languages, of course you're gonna have a bad time.
Really what I take away from this post is that the author is a bad teacher, although the experience of her student is probably similar to what many people experience when trying to learn by themselves.
There are many improvements that could be made to the JS ecosystem, but this post does not do the current state justice. What it highlights, if anything, is a problem with the available of a standardized learning path. But I'm not sure what the solution to that would be.
I've been working in Python for the last several years. There's definitely a learning curve there, and I get frustrated with things all the time, but the whole JavaScript ecosystem seems like such a mess compared to Python.
One of the things I miss the most about Python when working in JavaScript is the documentation. And I mean the core documentation from Python.org. The Tutorial is amazing [0]. And you can download the entire documentation already in PDF. Maybe I'm one of the few, but when I'm learning something new it is such a better process if I can leave my computer and read through a tutorial and mark it up.
Javascript runs directly on the browser. That automatically makes it much more complex because:
1. There are some packages written for browser and some for Node.
2. There are transpilers, abstractions layers, bundlers, etc to make packages run on both environments.
3. Browser based packages need to have all sort of backward incompatibilities in mind (from IE6 to now)
Multiply these 2 and 3 together and you'll see why it's a mess of an ecosystem...
Yet, it only takes a little bit of knowledge and experience to get something working. It's hugely productive.
I mean honestly considering the hand dealt with it (decades of backward incompatibility required), I think the js ecosystem is holding up real well.
of course, if you are new, then this approach may not be obvious
That was about 3 years ago, and I just started using modules. Even then, I use the native browser modules, no Webpack. With HTTP2, there is little cost to requesting many small files.
Likewise, I don't use a CSS preprocessor in any of my projects. They aren't that complicated.
Those projects have no build process. What you write is what you run (WYWIWYR?). If the project is small enough I'll serve its root directory with Python's SimpleHttpServer. Later, I might have nginx do it.
This allows me to get a project running in a minute. I add tools when they are needed, because then I have the motivation to learn them and set them up properly.
Such tools are required if you must coordinate the work of multiple developers. Their cost is divided by the number of devs, and their benefits multiplied.
If you're just a home gamer toying around, you can do without them.
I started using Vue from a script tag a year ago (not that hard). But when I started building an SPA, things got complicated very quickly.
I found myself longing for a really good tutorial similar to Django's [0], rather than the thousand variations of "Today We'll Build a To-Do App in Vue!" that are so common.
For the projects that I work on, I use the same pip/virtualenv setup that I've used for years. Can't imagine that happening with Webpack (Side note: it might be that I could use the same Webpack setup for years, but the unstable reputation around the JS ecosystem makes me think I couldn't).
I honestly think the only real solution is re-doing all of it 'from scratch', to make everything (a) stricter and (b) more normal/consistent.
(I think the extant transpilers/preprocessors tend to try to be too 'thin' of a wrapper around CSS/JS: they do give some nice quality of life features but still don't really clean up the mess that is JS and the DOM.)
A person can be a successful programmer for decades and do millions of HTTP operations without knowing the distinction between TCP and IP.
Python3 -m venv env. That’s all it takes.
Sometimes I am in the same boat. Thinking, this should be easy, ending up yak shaving.
For all Python's ease of use language wise it‘s ecosystem can be utterly inscrutable.
No she isn't.
This entire thread is full of the generic excuses one has come to expect from this profession when people struggle with programming setup and running programs. Always a defence of the (broken) status quo.
Something has gone wrong? You didn't read the documentation (the incomplete or non-existing documentation). Or it's actually simple, all you need to do is x, y, z followed by a, b, c - how could you not know that? (Often implied in these responses: you're clearly a clueless noob).
This is quite simply a profession that wouldn't recognise 'simple' if it came and bit it on the arse (or ass).
She wasn’t helping one of her students, she was helping a friend who is a computer scientist. The closing thought was if this person, with so much existing knowledge and some assistance, can’t make one “simple” thing work in a reasonable timeframe, what hope do actual novices have?
Novices should be referred to preset codesandbox.
There's blame to go around but I mostly blame npm for being full of hot garbage while obscuring what is garbage and hot.
If you think learning NPM is hard, try telling a new dev how to setup a Java or C# build by hand. If you think webpack is hard, try teaching someone the intricacies of make.
What about babel? Other languages make breaking changes and dictate that the new version of code just won't be compatible with older stuff. Python 2/3 wouldn't be a blip on the radar if the same option to transpile between versions existed. Those famous "update your .Net version to whatever" warnings simply wouldn't be needed. Instead, people complain that learning a few lines of config is too difficult.
If people put half the time into learning JS that they put into learning the other languages and build tools they know, there would be almost no complaints because the tooling these days just isn't that bad.
The problem is not one of putting the effort in, it's even knowing where to go.
If I want to learn about how to use some new JS library/utility/webpacker, I can probably find about 30 good-quality-looking blogs/articles/documentation pages on how to do it. Most of them won't work, because they'll be out of date. This is hugely frustrating, because you don't know if it's not working because the documentation is wrong, or because you're holding it wrong.
> If you think learning NPM is hard, try telling a new dev how to setup a Java or C# build by hand. If you think webpack is hard, try teaching someone the intricacies of make.
Make is actually a brilliant example of something that's complex and daunting, but ultimately rewarding. It's easy to put the effort in to learn it because the maintainers don't change their minds every 2 minutes about what the Makefile syntax is, so learning how to use it is pretty straightforward. And once you know it, you can understand makefiles written both yesterday and decades ago.
Give me make over webpack any day of the week. I'll put money on which dies first.
The other day I wanted to publish a little script I've been maintaining for years as a module easily usable by WebPack and whatnot, and that's much easier said than done. I published it on npm and put some UMD magic thing in there, and I think it should work now ... but I'm not really sure to be honest (still need to look at this and confirm).
Just searching "publish JavaScript module" and trying to make sense of the WebPack isn't really all that helpful, not for me anyway, as I'm joining half-way through season 6.
I have no opinion on the tooling as such – I lack experience to have an informed opinion – but it sure is confusing to "quickly" do something for people who are not heavily involved in it (i.e. me)
I use rollup for libraries and webpack only for fullblown frontend projects for precisely this reason.
I disagree. In both cases, you really only need one or two episodes to know that the story is not going anywhere. It will only get more complicated and convoluted without ever rewarding you, you will realize that no thought was ever put into it, and you will only stay for the ride because of sunk costs.
Whoa. That's a name I haven't heard in a long time.
These days you'd just add the right bit to commonJS to say this is an ES6 module.
Yikes. I really do not think that was the solution to this problem and only added a ton of complexity.
JS is in a unique position because it can run both code in a browser as well as a server-side/scripting language. In order to do that with any level of success, tooling is required. This tooling (dev server, webpack) builds on other tooling (node, babel, typescript) which is where all this complexity lives.
Furthermore, some packages are not worth installing and if you run into issues with that package, then try something else. We have no information about the package they tried to install and since the JS ecosystem encourages people to publish to npm for virtually anything, this is one area where you really have to be careful.
The lesson here is the same lesson with installing something like left-pad: be careful what you install and read the source code to understand what it is doing. Most of the time, these packages can be inlined easily. Just because a library exists, doesn't mean you should use it. Most of the time for JS I'm reading the library's source code to see if I can a) inline it or b) use it as inspiration to build specifically what I need.
Mind that this was not that much of a problem back in 1997 with Netscape Navigator and Netscape Enterprise Server. I think, the real issue here is that the JS ecosystem is targeting an abstract implementation, rather than a real world one. Much of the tooling is just about turning the abstract implementation into a real world standard and, in a second step, about packaging (i.e. linking).
So long as you have browsers in various states of compliance and paying customers using those browsers, this will always be a problem.
Node works fine out of the box from the command line, modules just need to have the correct instructions for the README.
That’s the reason why I started to love pika.dev ‘s package search. Webpack still sucks and will ruin your day with hours of unnecessary configurations and fixes.
On the other hand, when setting yourself a rule to use plain ESM only without any build system, coding has been a joy.
The only thing that still sucks is UI frameworks, because all major frameworks still require a shitty babel workflow in one form or the other. Vue.js has an ESM module which is useless without babel (due to the .vue file format), and Angular/React are still in the lets-invent-our-own-language fatigue.
Fixed that for you.
React without jsx components is just as useless as Vue without .vue files. If you cannot use the ecosystem of a framework in practice, your framework isn’t a framework anymore.
It's not useless at all. JSX in React is just an alternate syntax for React.createElement calls.
https://dev.to/arswaw/create-a-lightweight-componentized-spa...
Chrome target, native ESM modules, VS Code with JSDoc annotations for types. All libraries (chosen preferentially from microjs.com) are copied into vendor/, and the front end is written in preact.js using htm [0] for native JS tagged html strings, leading to code like:
import ImageView from "./image-view.js";
render({ trail_item, selector }, state) {
/** @type {LinkItem} */
let link_item = trail_item;
let title = this.render_title(trail_item);
let favicon = this.render_favicon(trail_item);
let img = html`<ImageView src=${favicon} />`;
return html`${img}${title}`;
}
There's a VS Code extension which formats html`` strings as actual HTML, and the Typescript checker built in to VS Code gives me advanced types and autocomplete, all with a workflow that's as simple as "refresh page".Granted, not every project can afford to target just evergreen browsers, but for my use case it works perfectly and I finally feel like I have the perfect blend of old-style web dev (in terms of refresh cycle) with modern language features and typing. The overhead, both in page-weight and cognitive load, is as small as I can make it.
EDIT: Modified my code sample to show how you can use Preact components in a JSX-like way.
[0] https://preactjs.com/guide/v10/getting-started/#alternatives...
I think the mistake of modern JS (and many other languages) is conflating source files with libraries. A better model is combining many source files into one library file, which provides one toplevel name when imported. A good example is how Three.js, which has a complex internal structure, gets distributed as one file and provides one toplevel name THREE. And of course there are many examples in C-land, where a large library can live behind a single header file. A project should only depend on a handful of those, and there should be few dependencies between them, so package management becomes easy enough to do by hand - just drop a file in your project's vendor/ directory.
As a bonus, this fixes the problem of having many fine-grained imports. If done right, your project's source files might not need any import statements at all. Anything inside the project could be available without ceremony, as if it was all one big file, and external libraries live in a handful of big namespaces which are also available without ceremony.
The pain is real. Create-react-app will dump 250 MB+ of files in node_modules
however, newer approaches are emerging and (hopefully) will be stable soon. few noteworthy ones are:
1. SnowPack[0] (in early access) 2. Vite[1] (from author of Vue.js) . It is in experimental phase. but is quie good. 3. Unnamed project by Author of Preact.
[0] https://www.snowpack.dev/ [1] https://github.com/vitejs/vite [2] https://twitter.com/_developit/status/1264062182326710273
You can build Vue applications without bundler... file is JS extension, you use
const template =` <you html stuff here> `
Usually that means picking up a subset of well supported frameworks that you like and find works well in the domain you’re in. It also means learning what language features not to use, or at least abstract away their use. People coming from highly opinionated languages with a large standard library tend to shoot themselves in the foot because they don’t understand this, and nobody really tells them. And inevitably a discussion turns into an argument with different sides becoming Balkanized because they use different parts of the possible language/library set.
I've been working in JS for years and I've never encountered a module containing a typescript file with a .js extension... That was extraordinarily unfortunate. I don't think I've encountered a module containing Typescript at all. Correct practice is to build to JS and include the optional type declaration files. In my experience people are pretty good about that.
[1] flow.org
This is not progress - as someone who has been professionally programming for 30+years, this state of affairs is atrocious. Its the equivalent of buying a 5-bedroom house for your kids to grow up in, only to go in to your kids room after 20 years and realise they are insane and should be committed.
I've run into this issue in every language. Nothing special about Javascript here.
There isn't a single Javascript project I've done in the last 10 years that I can return to and run again - they've all been borked by the eco-system. I dread the idea of even opening a package.json file to see what's wrong...
The language supported is ECMAScript 3 with some minor COM-related quirks, but with a few utility functions it's not too bad for simple scripts.
What about C#? One could argue it's pretty much the most bullet proof in terms of "just working" without any issues.
Open up visual studio.. start a project.. run it. There really isn't anything to break like everything else you are discussing.
Yeah, if you lock your children up for 20 years, they will go insane no matter your intentions.
Javascript is in this state for a number of reasons, but the fact of the matter is that it's here now and it's the lingua franca of browsers whether you like it or not. Maybe someone should have checked in on the kids every once in awhile so they didn't go insane, but it's too late to make more kids so love the ones you've got.
The only justification for the disaster of modern JS 'development' is: job security. Make this argument and all I can do is agree with you: its a hellacious mess because otherwise, it wouldn't be so profitable.
You could also explain it by a succession of well-intentioned-but-ultimately-unsuccessful attempts to reign in the insanity. At least for things like TypeScript and CoffeeScript.
Combined with a culture of high speed delivery of business value, which doesn't value going back and removing the earlier failed attempts.
Turns out your kids actually manage to use the tools they built just fine.
I'm sorry but I don't believe the issue is as bad in other environments.
I've managed to pick up and make small patches/enhancements to projects written in Java, C, Ruby, Python - none of which I use regularly beyond the bare minimum I need (usually to patch some tool I'm relying on).
"Modern" javascript is just a huge pile of WTF with "Are you fucking crazy?" frosting to my eye.
> Turns out your kids actually manage to use the tools they built just fine.
The kids have a "new tool" every week because the "old tool" from last week has some problem. That's hardly a sign of "just fine".
That is all.
You are in for a treat.
Its like .. Sure, meth might be fun, but I definitely don't think I wanna hang out when all the people in the room are doing it.
The situation in article is equivalent of trying to add maven dependency to raw java project without maven, because you dont know maven exists and then wonder why other dependencies are missing or project is not imported correctly to eclipse. That is literally John from article.
I think you misunderstood. I am talking about making patches/enhancements to tools written in languages I do not regularly use. So I didn't "know a lot" about the language or environment or toolchain involved, I generally knew nothing (from a dev POV) about it. The small exceptions there would be a Java project (StanfordNLP) and a C project (the PHP language/runtime), where I had use the language in question to write 'hello world' type programs as a student, as part of my Network Engineering diploma, close to 20 years ago.
> The situation in article is equivalent of trying to add maven dependency to raw java project without maven, because you dont know maven exists and then wonder why other dependencies are missing or project is not imported correctly to eclipse.
The first command "John" runs in the article is: `npm install packageName --save`, as recommended by the package’s README.
Likewise, java library would have "add this dependency" in its README followed by xml snippet. It would not start from "create maven project" nor explained how you get pom.xml. It is assumed you know what maven is.
> I am talking about making patches/enhancements to tools written in languages I do not regularly use. So I didn't "know a lot" about the language or environment or toolchain involved, I generally knew nothing (from a dev POV) about it. The small exceptions there would be a Java project (StanfordNLP) and a C project (the PHP language/runtime), where I had use the language in question to write 'hello world' type programs as a student, as part of my Network Engineering diploma, close to 20 years ago.
That is exactly what I am talking about. You do not need to know a lot. In java world, you need to know about maven existing and that maven dependency means you have to have maven project.
In JavaScript, you are expected to know that npm dependency means you have to have npm project.
The old tool(s) will actually still work just fine, and plenty of people use them. Kinda like Python 2 and Python 3. You're not forced to use the absolute newest set of packages. I'm not as familiar with Java and Ruby but the I know the C/C++ ecosystem has gone through many changes over the decades. Perhaps the situation with JS is currently overwhelming and maybe it will settle down over time, but I don't think it's a bad thing that lots of people are motivated to keep iterating and improving the tools. Personally I find the JS development experience very smooth and enjoyable, and I know many of the people building all these crazy new things do as well.
C has its problems, and in many ways has avoided this hell hole by solving them in clever ways, but they are nowhere near equivalent to the burning trash pile that is the modern Javascript developers stack and tooling.
If all you've ever done is become a professional Javascript developer, I'm sorry: you still have a long way to go before you'll match the style, elegance and productivity of basically any other language. Javascript dev is an atrocious mess, and anyone who has done anything productive in any other language or framework should know that by now.
As such I got to deal with getting our code to play nicely with the dozens of other scripts that inevitably existed on these sites as well. Being a third-party on a site with not just first-party code but also other random third-party code was truly a hostile environment.
Nobody was doing anything correctly like loading scripts in a way so that they'd never interfere. Some script would load the version of jQuery it wanted, which would shadow the version some other script wanted to use, and stuff would break (but only sometimes, because it depends on timing).
This was before anyone was using webpack. Bundlers thankfully solved this issue (unless you really go out of your way). I'm sorry to say what you consider the good old days were in fact quite bad. If you're making a personal website for yourself? Sure, all this seems like overkill. As soon as you introduce anything third-party? You need lots of tricks to be bulletproof. So from my perspective, things are much improved.
What a pity this was done within the browser-as-OS context rather than OS-as-OS, as a thing... What you described is just like the good ol' days of DOS were: you could write some code, sometimes, that would work on everyones machine - but then of course there were special cases and developers had to take into consideration other members of the ecosystem - standards had to be proposed, formulated, and met - competing players needed to play nice together, and so on.
The trouble with Javascript today is that precisely NONE of the lessons learned in any of the other places where PRECISELY these issues were experienced, have been applied - even less, paid any attention. And, especially not, by any of the so-called 'new school' of developers who think such disasters as the left-pad fiasco are Just Fine™.
The cognitive load of Javascript today is equivalent to that of, lets say .. assembly on DOS in the 80's. "Anyone" can do it, and no doubt there will be great advances in applications for the user - but don't come screaming when the big ball of mess starts costing you more than if you'd just written it properly in the first place. That means, packaging and abstracting things properly. It means putting the modules in a place where the world will find them over time. It means having release planning procedures that work, and aren't in the hands of a mindless entity. This was how it was on DOS, and then Windows, and now the Web .. less so on Linux, because Linux has always had great solutions to the kinds of problems Javascript is now manifesting.
I blame the OS vendors, personally: Apple, Microsoft, et al. If they hadn't had such a hard-on for removing basic compilation capabilities from a default OS install, we wouldn't have all been corralled into the web, and thus relieved to 'finally' have a dev tool for the common man available to us, in Javascript.
The cognitive load is the same. The ecosystem is a disaster, however. I'd rather just be writing plain ol' Linux apps, producing binary-file based installers, personally .. the tipping point for the effort to invest in Web development is there. I just need users willing to run real operating systems, and who realise that the web isn't just about the browser. I feel that is a more worthy investment of the intellectual capital of developers, today.
Of course, none of this matters to the billion-dollar Javascript churn industry. The customers don't need to know how bad it is: as long as they feel they're getting the user base they need/deserve for having paid so much/little for a bit of Javascript hackery ...
I was able to pickup PHP-Mysql with 22 years or so, and move from that to Python/Django, even some Ruby in-between.
Javascript? I just can't wrap my head around it. And I've tried.
If its hard for people who already have a background in programming and some basic computer knowledge to learn and pick up, I can't imagine how hard it would be for someone with no experience.
The moment you go beyond making a simple website like you might learn in a beginner javascript class (using just basic javascript embedded in an HTML document) you become pretty lost
Granted, once I understood the ecosystem more, I gradually began to grasp the reason these issues are around. But still, it does make it incredibly frustrating as a reasonably decent coder getting started in JavaScript.
Things have largely gotten much, much better for JavaScript though ever since Node and NPM came along. It's easier to find the right modules to use or at least the right ideas to borrow. Package overload paralysis still happens at times, but I'd personally always rather have more, rather than less choice.
The constant rate of change does make me feel like I'm always re-learning a new way to do the same old job, but luckily for me - learning potentially better ways of doing the same old thing continues to be enjoyable.
I mostly work on the backend.. However, I've done a decent amount of JS too. In fact, back in 2015, even built a lot of the core parts of an SPA using a mix of knockout & requirejs with minified bundles and dynamic loading and so on. Given that it stuff put together from scratch, I though picking things up after a couple of years away from js would be easy. Oh how wrong I was...
In 2017/18 sought to write a starter boilerplate with vue 2, Typescript and .NET Core. I would have probably spent an order of magnitude effort more fixing build issues and warnings than on the project. Once you hit bugs/issues with 3rd party webpack modules (which is almost a given), it is not fun at all.
I recently had to put up a one page visualization and was not looking forward to it. Surprisingly, create-react-app just worked out of the box. Not much of a data point - but still a pleasant experience.
create-react-app is the only thing I've used in the ecosystem that hasn't catastrophically broken for me due to some years-old issue.
Except for monorepos/yarn workspaces, that still doesn't have first class support[0]
[0] https://github.com/facebook/create-react-app/issues/1333
The upside of the JS transformation into just another compiler target is that there is little reason to use JS as the source language, IMO. These JSVM languages do suffer from the same problems to varying degrees.
There is no package.json, typescript, flow, javascript mix, with tens of things configured which change frequently.
Also continuing to work on a python project after a year often is not much of a hassle.
That being said: virtualenvs still seem to be complex matter, especially when you are a beginner.
You can't just distribute arbitrary binaries to users on the web, so web developers have to deal with a layer of complexity that other programs don't have to. That said, maybe WebAssembly will change this story.
yep, other programs totally don't need to deal with different OS, graphics APIs, GPU driverstacks and hardware architectures.
Callback hell around 2015. It used to be that if you wanted to do something async you'd have to create a new callback. This led into callback hell[1], which was specially bad back then on the backend.
Luckily after a migration that has taken many years, now most of the libraries use async/await instead of callbacks. There was some time where this was extra difficult because some code was using callbacks and some other code was using async/await, but it's almost totally solved in 2020.
Which brings us to the article on hand. This is probably one of the biggest issues, and a fake promise in Javascript right now: reuse code on the back-end and front-end. The front-end side has been using `import` for almost a decade with Webpack and friends but this was not easy on the back-end, so there was not a practical way of reusing the code in a project.
Luckily since last year Node.js supports import/export, and React supports it in libraries. It took a while because it was not an easy issue. I expect that more and more libraries will start to work only with import/export, and hopefully in 1-5 years this will also be a non-issue.
Is that true? I was looking to port one of my C# projects to TypeScript/Node and it uses gRPC and it's not async/await compatible. That's a pretty major library in my opinion.
In the end I didn't end up porting my project because the lack of elegance compared to the C# version was too depressing -- the C# code made heavy use of async and porting without that was just too messy. I'll take another shot at the project once this problem is totally solved.
[1] https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_...
[2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Please note that not all callbacks can (or should!) be converted to promises, e.g. events like `on('click', ...)` don't have a clear way to be promisified since a promise can only be resolved once and stays resolved.
If you want a language that requires zero learning to use, I am sad to say that they are very far and few between. Sure, we have a clusterf*ck of a module ecosystem and interoperability issues between preprocessors but it isn't like that is a particularly novel problem either.
Or, hell, how about the packaging systems in Go or Python? "Yeahhh, we don't really use X anymore, go ahead and use Y."
John certainly failed the perseverance test though.
In John's case, even after he got some help he still couldn't set up and run the project which is really frustating.
oh look, another one
I've used it for some personal projects, but doubt that I'll use it for anything paid anytime soon.
>The cmake build is doesn't work without -GNinja (you do have ninja installed, right?)
>No actually use Bazel/Buck/Pants/Meson
>Oh you installed $DEP, but not the right $DEP with $DEP-X support
>pkg-config can't find $DEP-X
>Pre-build $DEP-X was built with GCC N, and you have GCC N-1, try building from source
>GOTO 1 for DEP-X
I'm embellishing here, but I feel like I always do some version of this song and dance when trying to build a C++ project. And then after all that is done you somehow still end up with linker errors in your final project.
For most people installing some C/C++ library it's just "apt-get install libfoo" (and maybe libfoo-dev), and they never have to deal with ninja/autotools/cmake/etc, whereas for JavaScript you directly have to deal with the tooling by using "npm install libfoo".
The same task mentioned in the article would probably be a lot easier: install package, write some code, "c++ -lfoo main.cpp".
I'm not saying JS is perfect, or that other languages don't have these issues. I haven't used Rails in years but I remember spending a day trying to get a gem installed and figuring out why nokogiri wouldn't compile. Almost every language has these problems.
That's how you get quality user experience. It creates balance between developer of the library/tool and the user of the library/tool.
Most of the time we would create a minimal CMake file to build the library to our specs or adapt the existing CMake file.
With javascript? Well, for instance, take Expo's official release notes for each new SDK and it's right there, as the recommended practice: wipe out your `node_modules` folder and run `yarn` again every time. And good luck not having your `yarn.lock` file randomly changing versions after a while.
It's just a single silly example, but it tells how much more stable the ruby development experience is.
I don't get it. I really don't.
Learning a language involves learning a bunch of non-language arcana about the environment, for no particular reason. Ideally you should be able to write the helloWorld equivalent for any platform and have a single command to turn that one file into a working program, but alas we have tool chains, configurations and requirements standing in our way. I don't think it has to be like that, but it all too frequently is. Deno seems to be making an admirable effort towards making a thing that just works.
Developing for Android or iOS makes the JavaScript experience positively direct.
In Rust, all I wanted is to play an audio file... failed.
In C++ all I wanted is to play an MP3 file... failed. With an hours of work I figured out how resources worked in Visual Studio and got a WAV file playing.
In Rust I installed a creative coding crate, it had 314 dependencies and the deps folder was 540MB. My openframeworks C++ project is 1.6GB after a bit of playing around in it :) But yeah, node_modules is heavy.
Bottom line is, when you are new to an environment and you aren't prepared to fight a battle, you will bleed out quite fast.
subprocess.Popen(['cvlc','--play-and-exit','{filename_here}'])
(just being cheeky)Is "start a localhost" a generic term? If someone told me to do that, I would probably freeze in embarrassment -- no one has ever told me to do that in such context-independent terms. Since this was about node/JS, did John install express, or some other static file serving module? Or did he have an unrelated tool that makes this trivial?
python3 -m http.server
https://gist.github.com/willurd/5720255 ("Big list of http static server one-liners")
Anegdotally my perception is that people oftentimes think "It's just stupid JavaScript, let me paste it into HTML and run in a web browser, oh wait... why it doesn't work?!".
If you think it's confusing then add Angular to this tiny app (it's from Google so it must be good, right?).
Ironically had they run ng new followed by npm install the import instructions would have worked out of the box.
In today’s javascript landscape you have to pick the template to start your project from, because starting from scratch is way more difficult.
Also that the package is published to Node Package Manager with only a TypeScript distribution seems very odd.
I do agree that the Node ecosystem could be easier to use, especially with the myriad of transpilers and build tools. But this doesn't seem like a very compelling anecdote to demonstrate it. Unless the point is that NPM package authors should not be able to publish their package in languages other than Node-flavored JS?
If the c++ community had a tendency to name their java files with cpp, would you be so forgiving?
[0] https://github.com/airbnb/javascript/pull/985#issuecomment-2...
[1] https://bugs.chromium.org/p/chromium/issues/detail?id=659515
And perhaps this is why it didn't seem obvious for Dan (I'm speculating) that anyone would want to use multiple file extensions for things, but when you're outside of Facebook's ecosystem and you have to set up your own build tools and deal with all the pain it comes with, you realize stuff like this makes no sense. Because ya know, maybe targeting by file extension in your build system would make it easier to use the right transpiler (e.g. that's what Parcel does). But that's just been my perspective being in both worlds.
This is precisely how I’ve been building tableofsending.com and it’s been a lovely experience.
You do need some babel/tsc/etc build step to reach a reasonable audience.
The issue with module loading is a pretty fundamental one, though pretty unrelated to web components.
Once you understand it, there are a large number of tools that make them work. The core problem is that most modules available on npm are written with import specifiers that assume the environment supports Node's module name result. Browsers don't, so it won't load something like `import * as redux from 'redux';`
The solution is a tool that transforms package names into URLs. Webpack, Rollup, Parcel, es-dev-server, Snowpack, Vite, unpkg.com, Polymer CLI, and many more do this for you.
More and more of the ecosystem is moving to native modules and we're all going to have to understand this issue.
The particular point of this project was to prove that each successive simplification that my friend proposed, i.e. avoiding Webpack for native ES6 modules, using lit-html instead of React, etc. introduced its own complexity. I'm not saying that these were all bad ideas, but just that they're fundamentally tradeoffs. I'm quite sure lit-html is a great stack. But it's not "better" than React any more than React is "better" than Angular.
[1]: Lack of async/await, or its equivalent, let+ in OCaml 4.08, is a big one. Mediocre typings for browser APIs is another.
The ones who don't give up on the first night will likely have more luck (try, try again).
I ran into one with Go imports just the other day, and since I’m new to it, it wasn’t a 10 minute google fix.
Python packaging has historically been so bad that dotcloud invented docker in an attempt to make it usable.
Unless you have a Python version locally that doesn't support some features used in said .py file...
Just importing doesn't seem to work for millions of people:
- https://stackoverflow.com/questions/4383571/importing-files-... (1.5m views)
- https://stackoverflow.com/questions/14132789/relative-import... (215k views)
- https://stackoverflow.com/questions/72852/how-to-do-relative... (325k views)
- https://stackoverflow.com/questions/1918539/can-anyone-expla... (100k views)
- https://stackoverflow.com/questions/1260792/import-a-file-fr... (480k views)
- https://stackoverflow.com/questions/7505988/importing-from-a... (136k views)
- https://stackoverflow.com/questions/9252543/importerror-cann... (700k views)
- https://stackoverflow.com/questions/2325923/how-to-fix-impor... (430k views)
- https://stackoverflow.com/questions/15514593/importerror-no-... (250k views)
Nested `mod`s with sometimes `pub` and then `use` for other stuff certainly seems more complex to me than `import X from P`.
Package/crate management is fairly trivial in both cases, yes. `npm i [package]` isn't exactly a difficult process either.
i don't think it's possible to do that any more with Python, the genie is out of the bottle. but you can get close with things like Black (auto-formatting) and Poetry (nicer deps mgmt and so much more). of course, how would a beginner know this? hopefully some day tools like that will become the default answers
I hope someone builds a wasm based front end framework. I did a quick search and MSFT seem to be on it with their Blazor framework. Unfortunately, I am not in a hurry to go learn ASP.NET or C# anytime soon.
Maybe we need a frontend framework in Golang that compiles to WebAssembly. I am rooting for Golang here, cause after a decade in Ruby/Python/JS, I am really enjoying going back to typed languages.
But even a python/ruby to wasm web frontend framework will be awesome. Anything that keeps me away from node hell.
wasmbyexample has an example of how you can do it in Go right now - https://wasmbyexample.dev/examples/hello-world/hello-world.g... - you'll need to write that index.js file yourself, and that's when you'll be back to using modern JS tooling as soon as you scale up to a real app.
Does seem like we need some more tooling to avoid as much webpack pain as we can.
The big problem JS has is the same one PHP used to have when it was top dog. Everyone is a fucking noob, including all the people writing all the advice online. I find almost every JS resource to be unbearably bad, with the sole exception of MDN. The vast majority of my learning these days comes from work colleagues who also have a decent level of mastery.
So the real answer is probably that the people getting stuff done are happy with the current state of affairs, because it works for them. And the people that are unhappy are for the most part trying to change the current state of affairs without fully understanding it, and making it worse. I think every language suffers from this to some extent, JS just has a much worse ratio of masters to beginners so the effect is exacerbated.
- In the Browser:
- Using Parcel/Webpack/Rollup.js...etc
- From a CDN
- In Node: - Using CommonJS
- `const funcName = require('somePackage')`
- Using Native ES Modules
...etcOMG. Decades of life in emacs (emacs!) would never have prepared me for a world where my editor would helpfully lie about the filesystem to me.
Yeah, this was horrifying to read. Obviously some of it is just normal churn, and all environments have their own oral histories and weird quirks. But... yikes.
It's nice for Java style packages that are all "src/com/company/project" before you get into the meat of any code.
I agree though about how surprising it is.
JavaScript’s tooling will only get harder to work with as we push it to handle more.
Eventually we’ll need to find something better than HTML/CSS/JS for developing in the browser.
The neat "software distribution system" - the web browser became very popular. The wide adoption of the browser has forced js into the realm of the general purpose languages because it was the language of that VM-browser.
Before that it was all open up index.html template and import my js files for my projects.
I am currently going through the same thing with Python/Django Rest Framework. Another fairly well defined toolbox that some wouldn't like - but it helps with learning good practices and you can lean on a community of developers that have thought long and hard about how things are well structured.
> It is worth mentioning that many of our design decisions were made with two primary goals. Spec compliance and Web Compatibility. It is our belief that the current implementation offers a future proof model to authoring ESM modules that paves the path to Universal JavaScript. Please read more in our documentation.
Sorry guys, those are the wrong goals! Just make CommonJS and ESM be mix and match interoperatable. ESM wasn't designed to be a local disk build system. Just have CommonJS behavior with ESM syntax for god's sakes.
Obviously this flexibility has been good for progress of the JS ecosystem as whole, but I hope the next 10 years are more sedate than the last 10.
https://www.npmjs.com/package/esm
The package.json should have something like this if they are going to use import/export statements so anyone on older versions don’t have to worry about it (it’s not native to Node yet without .mjs extension).
We can blame whoever didn’t set that up, or the instructions should have been to just use require().
Since v13, you can use ES modules without the .mjs extension if the nearest package.json includes `"type": "module"`.
https://www.desktopbackground.org/download/1280x1024/2013/02...
I often wonder what the js ecosystem would look like with Google-working-on-Go levels of runtime and package management design discipline.
One would really think Google would do this, especially considering that Microsoft now has veto power over the npm repository and package format. Yarn was a huge improvement but is still dependent upon the same broken backend model.
AFAICT the success of the JS ecosystem is entangled with Google’s success.
Literally nothing about javascript-the-language is why package.json is in a file format that does not support comments, or why node_modules can’t be renamed or hidden or cached properly across projects, or why any of the cryptic import issues encountered by the author of TFA happened, or why yarn had to be made because npm is (or at least was) nondeterministic.
The js packaging tooling sucks, and, more importantly, has continued to suck contiguously for at least ten years. Much like Python and Ruby (cryptographic checksums, anyone?) and Debian/Ubuntu to some extent, I think nobody gives enough of a shit (or has the skills and experience and inclination) to unfuck it, or has just become blind to it over ten+ years of it sucking in the same way (much like autoconf).
It is entirely unfuckable. No part of it is baked into javascript. Go’s was fucked, and they did an epic job of unfucking it with the module and caching system. The same could be done for JS.
It would require forking node to handle imports sanely, and replacing npm/yarn packages (as well as the backend npm package repository they talk to)—surmountable tasks.
Side note: Go has a little bit of baggage. That community is in the process of going from multiple 3rd party package/dependency managers to one official one.
npm i pythag
npm i complex-sqrt
// then
var pythag = require('pythag');
var sqrtrt = (z) => require('complex-sqrt')(z,0);
let x = 3
const y = 4
var result = sqrtrt(pythag(x, y))It doesn't track with the narrative that it's difficult to get started with, in fact, it shows that the opposite is true since these skills are very common among novices. Native application development is much more challenging learning curve for novices.
>details. It arguably should be, and at one point it was very trivial.
Create-react-app and similar tooling make things very trivial, but the suggestion that things were trivial "at one point" and no longer so is obviously false since whatever trivialities you're referring to work just fine today as they did in 1998.