this post was submitted on 22 Sep 2023
25 points (93.1% liked)

Programming

16975 readers
1288 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
 

I mean, sure, that's probably heavily influenced by the need for bundling for the frontend.

But it isn't done blindly. Bundlers reduce the overall size of the code, either due to minification or tree-shaking (removing unused modules). It also removes the filesystem overhead of resolving and opening other modules.

Would bundling be useful in other interpreted languages?

I suppose you may count JVM's compilation to bytecode as being very similar.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 1 year ago

A lot of bundling in the JS world is also either because of TypeScript, or transpiling to old JS so that it's more compatible with old node / browser. JS has gone through quite drastic changes in syntax, from vars and prototypes to now let/const, ESM imports, classes, Promises, async/await. Lot of it which may run in an old browser. It also helps runtime speed, slightly, but it's not something that matters all that much on a server because you just wait a second or two for it to load.

JS is also kind of wild with how many libraries a given project may pull in, and how many minuscule files those tend to use, especially since each library also get their own versions of every dependencies too.

Python uses much fewer libraries and has code cache. PHP has code caching and preloading built-in so filesystem accesses are reduced. Bash usually doesn't grow that big. Ruby probably just accepts a second or to two to load up for the simplicity of the developer experience. Typically there's one fairly large framework library and a few plugins and utilities, whereas a big Next.js project will pull in hundreds of libraries and tools in.

A JS solution to a JS problem really. It needs to run in potentially ancient browsers, so we just make a giant JS file. For the other languages, you can pretty much just add it right to the runtime. If bundling was that big of a deal we'd read libraries right off a zip file like Java does with its jar files by default.

Plus, if you really care, you can turn on filesystem compression on your project directory and get the same benefits as