3 ms·
Folks who write JavaScript today might not remember a time when it was normal to write JS and ship the same files verbatim to end users. We’ve seen a Cambrian e
by awhitty 4y ago
Folks who write JavaScript today might not remember a time when it was normal to write JS and ship the same files verbatim to end users. We’ve seen a Cambrian explosion of new syntax, new tools, and new ways to build applications using JavaScript in the last decade. Many of those features are now built into modern browsers, but static typing is one of the last Big New Ideas that hasn’t made it into mainline JavaScript.
We’re conditioned to expect there will be a compilation step between our source code and the code that runs in a browser. That forces many decisions about how we structure our projects and the kinds of tools we can use to deliver the software we write. Minimizing or eliminating the reasons why folks might need that build-the-code step between the code they write and the code their users run opens up doors and new ways of writing and delivering software, and that’s exciting!
Think, for instance, what would it take to get something like the TypeScript type checker in Chrome’s devtools? A first step would be to adopt the type annotation syntax.
- deleted 4y ago[deleted]
- 8n4vidtmkvmk 4y agoeven if we add types to js... minification, dead code elimination, and even precomputing or other performance optimizations will still require a compiler. not sure what typechecking inside chrome would add.... maybe it could be used for faster js execution like how asm.js works
- cphoover 4y agoI dunno I think there is a lot of historical revisionism happening in regards to how joyous coding in JavaScript used to be. I've been doing web-dev since the early 2000's, JavaScript is way more usable today than it's ever been in the past.
- awhitty 4y agoRight, I agree it’s much nicer to write JavaScript now than ever before. Merely pointing out that it’s not meant to be a compiled language. As a community we continue to expect a build step to exist when it really doesn’t have to for a broad class of projects. Transpilers were never the end-goal. It’s true that there are some optimizations done in the build step that benefit end users, and folks will probably (correctly) continue to choose to minify, tree shake, bundle + bundle split, eliminate dead code, etc. for serious applications. But to be able to write a modern web app without having to npm install a single module would be stellar! And it’s becoming more and more possible. How do you teach someone how to write a JS project in 2022? I imagine it starts with, “Well, first you’ll need to install node and npm - that’s gonna run JavaScript on your computer but don’t mind that much for now. Now we’ll install some dependencies required to build your code…” and so on. It takes a while and many conceptual hurdles to get to the part where someone can run the code they wrote in a browser.