Memory is running out, and so are excuses for software bloat

https://feddit.org/post/23488392

Memory is running out, and so are excuses for software bloat - feddit.org

Lemmy

Yeah, gonna be interesting. Software companies working on consumer software often don’t need to care, because:

  • They don’t need to buy the RAM that they’re filling up.
  • They’re not the only culprit on your PC.
  • Consumers don’t understand how RAM works nearly as well as they understand fuel.
  • And even when consumers understand that an application is using too much, they may not be able to switch to an alternative either way, see for example the many chat applications written in Electron, none of which are interoperable.

I can see somewhat of a shift happening for software that companies develop for themselves, though. At $DAYJOB, we have an application written in Rust and you can practically see the dollar signs lighting up in the eyes of management when you tell them “just get the cheapest device to run it on” and “it’s hardly going to incur cloud hosting costs”.
Obviously this alone rarely leads to management deciding to rewrite an application/service in a more efficient language, but it certainly makes them more open to devs wanting to use these languages. Well, and who knows what happens, if the prices for Raspberry Pis and cloud hosting and such end up skyrocketing similarly.

Writing in Rust or “an efficient language” does nothing for ram bloat. The problem is using 3rd party libraries and frameworks. For example a JavaScript interpreter uses around 400k. The JavaScript problem is developers importing a 1GB library to compare a string.

You’d have the same bloat if you wrote in assembly.

Maybe you’re confusing memory (RAM) vs storage ? Because I converted some backend processing services from nodejs to rust, and it’s almost laughable how little RAM the rust counterparts used.

Just running a nodejs service took a couple of hundred mb of ram, iirc. While the rust services could run at below 10mb

Because I converted some backend processing services from nodejs to rust,

You converted only the functions you needed and only included the functions you needed. You did not convert the entire node.js codebase and then include the entire library. That’s the problem I’m describing. A few years ago I toyed with javascript to make a LCARS style wall home automation panel. The overhead of what other people had published was absurd. I did what you did. I took out only the functions I needed, rewrote them, and reduced my program from gigabytes to megabytes even though it was still all Javascript.

Yeah, you need to do tree-shaking with JavaScript to get rid of unused library code: developer.mozilla.org/en-US/docs/…/Tree_shaking

I would expect larger corporate projects to do so. It is something that one needs to know about and configure, but if one senior webdev works on a project, they’ll set it up pretty quickly.

Tree shaking - Glossary | MDN

Tree shaking is a term commonly used within a JavaScript context to describe the removal of dead code.

MDN Web Docs

On the one hand, tree shaking is often not used, even in large corporate projects.

On the other hand, tree shaking is much less effective than what a good compiler does. Tree shaking only works on a per-module basis, while compilers can optimize down to a code-line basis. Unused functions are not included, and not even variables that can be optimized out are included.

But the biggest issue (and one that tree shaking can also not really help against) is that due to the weak standard library of JS a ton of very simple things are implemented in lots of different ways. It’s not uncommon for a decently sized project (including all of the dependencies) to contain a dozen or so implementations of a padding function or some other small helper functions.

And since all of them are used somewhere in the dependency tree, none of them can be optimized out.

That’s not really a problem of the runtime or the language itself, but since the language and its environment are quite tightly coupled, it is a big problem when developing on JS.

Tree-shaking works on per function basis

“Mature ecosystem” it’s called in JS land.

I wish nodejs or ecmascript would have just done the Go thing and included a legit standard library.