10
HnDev
5y

How is it a thing that developing a desktop app nowadays requires an enormous amount of RAM? I stared working on an electron project and the whole thing takes up 3-4 GB of RAM when running, and that does not factor in my IDE or anything else.

But the packaged app does not go over 400mb, although we have had memory leaks in the past

Comments
  • 4
    All the debugging and instrumentation in a huge framework like electron, with so many parts like V8 and the JS bits and the system interface code and so on takes up quite a bit of space.
  • 3
    So what happened was, Web technologies which were originally invented for displaying documents could be contorted more easily into user interfaces than all current desktop-based UI frameworks. They also has the bonus of bring portable across all devices - kind of like Docker except from 1990 and each device has subtle bugs in its implementation.

    Anyway - due to this, the fastest way to build something that runs on as many devices as possible from Day 1 is to base it on Web technologies.

    Web technologies use a shit-ton of RAM because of things like the DOM and the Javascript engine - in general, the more complex / nested the interface is, the more RAM it will use.

    Some genius came up with the idea to create a kind of "web browser host" shell to host applications built on Web technologies but allow tighter integration with the host system - and called it Electron.

    There is some overhead involved with this, which uses up more RAM.

    tl;dr: RAM is cheaper than developers
  • 2
    @unsignedint I think "more easily contorted into user interfaces" is a fiction perpetuated by the costs being more subtle and harder to notice, especially with the "ease" of development. People forget that everything has a trade-off. Web technologies come with inefficient use of resources, massive software stacks (which often are poorly understood) and limited UI capabilities (despite the promises, true native UIs are almost always more flexible and therefore easier to fit to any particular purpose - web UIs can often limit what can be presented and how). Native UIs also tend to require greater knowledge of how a platform does things, which encourages better code.

    In other words, people adopt things like electron because they seem easy. The hidden costs are paid by needing devices 10 times more powerful than might otherwise be necessary. (Some hyperbole might be included.)
  • 4
    Scrap electron, you will see significant performance increases.

    Plus you're complaining as a dev, how do you think the users will feel?
  • 1
    The reason electron requires so much ram is the Javascript Engine's (V8) optimisations. To make Js faster the engine creates optimised versions of the code in multiple stages, each stage assuming more about types, branching, etc. The problem is that when these assumptions are broken, for instance by calling a function which was previously only called with floats with a string as an argument, the engine needs to revert to a more general form of the code. To do that the engine will keep copies of that code in ram, which eats up all of it.
  • 0
    Try react native for windows with vnext branch. Its better than electron.
  • 0
    repeat after me:

    ELECTRON IS NOT A DESKTOP PLATFORM.

    now go to your room and learn c#.
  • 1
    @Batburger will using typescript make it better?
  • 1
    @Midnigh-shcode not my call
  • 0
    @HnDev I dont think so, but I am not to sure. At the end of the day type script just gets turned into Javascript, which is what the engine sees. Also one can write type script in a way where one isn't strict about typing, so the engine cant assume types to be definite anyways....
Add Comment