Native desktop apps are far superior to Web/Electron
ajit.dhiwal.com
ajit.dhiwal.com
https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
Also, please don't rewrite titles to make them more baity - this is in the site guidelines: https://news.ycombinator.com/newsguidelines.html.
Sorry if the title now appears to be more baity, I was actually intending this to be a response to the Ask HN post on the front page. I figured it would be okay for post Authors to change the title since I can always change it in my original post. EDIT: I have changed the title of my original post.
Browsers and things like Electron are just run-times. The browser's main advantage is cross-platform compatibility. But only kinda-sorta as any web developer can tell you. Your code is usually targeting 3 different run-times at a minimum and there are always problems with anything non-trivial.
It is easy to imagine something much better, where your code runs on a nice tidy runtime native to the OS, with relatively easy layout tools and a language that is better than JavaScript (and really, what language isn't?). It'd be nice and fast, and rewarding to develop in.
If we are starting anew, with fresh eyes, and we were handed browsers, with JavaScript, CSS, and the DOM, we'd be like, "This is complete BS. Visual VB for DOS has this beat."
But because it grew organically, with instantly built in lock-in, and we're now thoroughly indoctrinated, the Stockholm Syndrome lives on.
If you can just take 3 steps back it's fairly obvious. But people would rather just keep making the next React or Bootstrap and digging the hole deeper than make something better.
Someday, make my words, there will be a cross-platform runtime that doesn't suck, that doesn't use JavaScript, and won't the stupid mistakes of the JRE, and developers will abandon web browsers as a platform in droves. I mean, can you really see this as the state of affairs in 2030? 2040? That'd just be sad.
Edit: typo
Yeah, cause that's how every native platform has been since the begining. Yet the web still needed to be invented. Why?
But now we have gone full circle to the browser being the operating system, and unsurprisingly, it's really bad, being in the position of being a "terrarium" for sandboxing all kinds of software behind an API of some sort.
Nowadays we have the alternative models of the curated package manager/app store and more extensive virtualization techniques available. Last night I wanted to try an old Windows 3.1 game. It took a few hours to gather and configure everything but I eventually got DOSBox and Windows 3.11 for Workgroups installed and configured with all the drivers, and the game worked. But the experience of installing this antiquated software reminded me of how Windows itself was a solution to a related kind of compatibility problem: Every program on MS-DOS had ended up in the position of shipping drivers for everything - printer drivers, sound card drivers, SVGA drivers. The solution of Windows was to build a ton of APIs to hide the hardware, just like the browser hides the native APIs. And this solution is a kludge, but a productive one for the near term. It's premised on I/O being bespoken enough that it doesn't have a standard, but not so much so that it can't be addressed in some standardized form. And emulators take that thought in the other direction, adapting new, more capable I/O to old.
But I don't think more terrariums (new runtimes) are necessarily the productive way forward. This always comes down to basic theories in and around CS - digital signal processing, Turing completeness, structured programming, relational data. The runtime is a certain endpoint of data that formats to an I/O medium, but it develops the terrarium structure when we start accommodating all forms of media and saying "well, you can set it up in any configuration".
> But building for the web(and electron) forces you to HTML/Javascript(and derivates).
This is incorrect. Electron supports Objective-C, C++, Rust, and obviously WASM (amongst others). If you want to build native code (and native UI) in any of these languages, go for it. Countless Electron apps have native components.
> It has no type safety, memory leaks are common and it’s slow due to its dynamic nature.
TypeScript has been a thing for a while now. [Citation needed] for the statement that memory leaks are more common than in, say, C++. Slow: Yes, it's slower, but probably by _a lot_ less than you think[1].
> And it’s laughable how weak the browser platform itself is. SQLite is available on raspberry pi, embeddable systems, mobile platforms and just about every other platform on the planet.
I agree, SQLite is fantastic. We don't really have to argue whether IndexDB will get thee job done, because native bindings to use SQLite with Electron exist. Just... use it.
And lastly...
> These days to send a text message over Slack I need over 1GB of RAM. [...] Even basic apps with all of their trackers, external javascript scripts and doms take up 100s of MBs in memory.
We're always working on performance and we're quite far from the place I'd like us to be at, but it'll send your message just fine if you have less than one GB of memory installed in your whole machine. Even if you're a heavy user, your memory _should_ be below one GB. To be clear, I'll say it again: Yes, things should be better and we'll keep working on performance. The post mentioned Instagram earlier, which I'd say goes a bit beyond the most basic app, and it's using a humble 40MB on my machine.
Disclaimer: I'm one of the maintainers of Electron and an engineer at Slack. I'm not here to argue opinions or which tool is better for which job, but we should get the basic facts right.
Yes, and typescript is great. But you do need a rigorous approach with it to get type safety on parr with languages like java and c++. And since that type information is lost by the time it gets to the interpretor, it provide any benefit to performance. For example, the js interpretor has to check the types if operands at runtime to perform addition. JIT compilation helps a lot, but if the interpreted language had stronger typing, the JIT compilation could probably do an even better job, since it could make more assumptions.
I just like to add that I never understood how when I just try to edit one of my Slack message (Windows client) it literally takes 100 % of 4@4ghz i5 cores and freeze my system for 2 seconds.
I mean, come on, I'm not asking the impossible here, just editing a single line of text.
I hope one day you go native like Telegram for example which is blazing fast, ultra light and also has clients on Android, Mac, etc.
Bests,
I worked on some heavy duty mobile apps like music streaming and unfortunately battery usage is the last thing we optimize for.
The platform even provides us with some ways to measure it, but it is just so remote from the metrics we do optimize for that except for major problems, we don't focus on it in the slightest.
>Mobile apps run at 60fps out of the box without much effort.
Technically fps is not the best way to measure this (we tend to focus on dropped frames instead, unlike most video games engines; mobile will not recompose your UI if nothing moves, saving cycles and heat) Lots of efforts have actually been made to optimize mobile apps. We are starting to reach a point where we do have a top to bottom approach for reasonable performances (try to scroll any app insanely fast .. you will drop frames, but in regular usage; dropped frame are not too noticeable on recent top of the line phones).
Agreed on the article though. Nothing more irritating than running a legitimately demanding application, seeing that it does not have enough resources and realize that a small web app in the background is using 37 cores and 50% of your cpu while you are not even using it (that was whatsapp just now).
Not even a company like Slack wants to get into the headache of maintaining a couple of native desktop apps, even if they probably have the money to do so.
I've seen great success with this approach for most platforms including mobile as it provides the end-user with a great user experience (you can use all the native UI APIs which provides an experience that the user is already familiar with) as well as extremely high performance with a high degree of code reuse.
Even that part makes it already more work than Electron and I can't think of any meaningful business benefit to not using Electron.
Because everyone optimized for "meaningful business impact" I have no space on my SSD to install your app.
(and even if I install it, it would cause my laptop fans go wild and I go for an alternative / use your app less.)
Even if setting up the code reuse among platforms was trivial, now you have to develop and maintain a new UI project for each platform with different languages, SDKs, dev environments, and other peculiarities.
With a web UI you can target 6 platforms at once with the same UI project: Android, iOS, ChromeOS, macOS, Windows, and web.
I'd add one thing, it's also used because it leverages existing web development skills.
I've made a couple of Electron applications because it simply lets me make a "desktop" app that is basically a web app that can use some local resources such as the file system, notifications, etc. Is it the best way to make a desktop app? Nope. Do I like the fact that Electron, when not optimized, is a pig? Nope.
But me choosing between Electron and a more native platform it is literally the difference between me shipping something or nothing at all.
Also, every situation is different, as some individuals/organizations have the existing skills to do a native app without learning/retooling and assume the situation is the same everywhere else.
Nope, it is because some bullshit MBA can't see beyond quarterly profits.
There is a need for native apps, however that need is shrinking and, in my opinion, will continue to do so. I also happen to think that's a good thing.
The issue is that developing for a particular OS is, generally, more difficult than developing for the web. The app delivery mechanism is also more convoluted (for native apps) than simply entering a web address in the browser. The web also seems to have more ubiquitous standards that abstract away the differences between OSs - you can, with a high degree of certainty, ensure that your app is usable by 99% of computer users, given the current software they have on their device - with native apps, there is no such guarantee, especially if you're relying on shared libraries.
Browsers are also becoming more feature rich. This has had a negative impact on their memory consumption, but given it's 2020, some may retort "memory is cheap" (I totally disagree with this way of thinking personally). And while some browsers (Chrome, looking especially at you) do a very poor job of memory management, I believe the competitive nature of the browser market will force a reawakening soon, where a lot of the inefficiencies in memory management will have to be eradicated (or vendors risk losing market share). Think back to 2014/15 when Node.js was really becoming established - the PHP team suddenly felt a need to re-optimise their engine for PHP7 (and with dramatic results)... Point is, only after ~20 years at the top did something spur PHP's team on enough to do something about their inefficiencies.
Finally, I can see a future where the line between web and native apps is even more blurred. WebAssembly is the first step, however things could get even more elaborate. Perhaps we could end up with the ability to start docker-like containers from within web apps (given the right permissions, of course) to spin up servers for audio/video/image processing on the client itself, and interact with them via a web page. If we get to this point, native apps may feel even more obsolete.
I know this post relates primarily to the current state, but I felt the need to talk about the future to highlight the marked difference in the rate of innovation in the web ecosystem (fast) vs the native ecosystem (slower). It would not surprise me if the web ecosystem ends up winning in the end. If I was building an app today, and it only requires features I can deliver via the browser, I would almost certainly go the web app route.
Now, if I was building a video processing app today, I'd almost certainly go native, but in a couple of years, my answer may be very different.
I'd say the "need" is shrinking because the number of viable options are shrinking. I'd throw out every single Electron app and replace them with native if it was possible. They're almost always either frustratingly slow or poorly designed. Oftentimes they're both.
I strongly believe we will see some major improvements in the performance of Web apps/Electron, since (a) there is a lot of incentive (b) there are many easy wins to be had in terms of performance.
You could even have the browser allocate a volume or two for the container to use (with the user's permission, of course) to store data locally. And users could be allowed to adjust how much space the volume may use (from some default minimum to unlimited).
And with containers, the client should be reasonably safe even if executing malicious software.
“And it’s laughable how weak the browser platform itself is.”
Which begs the question of why then do developers use web/electron?
Ubuiqity, cross-platform, distribution, updates... and, yes, some developers also prefer web api.
Perhaps the question is how do we bring a web/election experience to native apps?
This isn’t a great argument by itself. There are many reasons that web apps are superior and more convenient than desktop apps. If this wasn’t the case, then why are web apps winning?
I don’t want to download and execute a binary just to read my email, make a video call, or read the news. Web apps are also cross platform. You can pretty much guarantee that gmail will work the same on windows, Mac, Linux, Chrome OS, and even iOS and android (with some idiosyncrasies). Web apps also update themselves, they take up no space on your computer, and can be customized using browser plugins.
I’d take these advantages over saving a few gigs of ram, which I have plenty of.
That is, few, if any, technical advantages for users. Just fewer choices, as well.
Nope. This is the Java Virtual Machine promise all over again. It didn't work. It doesn't work the same in Safari or Firefox as it does in Chrome.
Because that’s usually all that’s being provided? I don’t think it’s valid to say web apps are “winning” when in many cases they’re the only 1st party option.
I don’t have any figures to back it up but I would not be surprised if the native app versions of Twitter, Facebook, Instagram etc. see far more use than their equivalent web app versions.
> I’d take these advantages over saving a few gigs of ram, which I have plenty of.
That’s all well and fine until everyone decides to make the same decision, and suddenly every application needs its own instance of Chromium to run.
There are bindings for it in many languages, like Node.js, Rust, Swift, Kotlin and more.
This is the replacement for Electron/Web.
Built on top of ReasonML which offers a JavaScript like syntax (and supports your favorite libraries too)
Revery UI can successfully target web, native desktop for Mac, windows & Linux with mobile coming soon. The case studies are great!
Sure, everyone loves hand-crafted, beautiful, native apps. But I will tell you this: it is possible to build a great app using any technology. It’s just a matter of taste & effort. My favorite tool that helps me get my day job done is VSCode. Do I care whether or not the damn thing is native or not? NO! Do I care that it gobbles some meager gigs? NO! Memory not being used is memory being wasted. Use my RAM, dammit. I can buy more. Use whatever you have to do to keep making this lovely thing that saves me so much time everyday and practically reads my mind as a JS developer! It has a elegant, raw beauty to it that totally fits my needs.
If it uses some hybrid web technology stack, what do I care? Is it great? To me, yes!
Make great apps. I don’t care how you do it.
if you have been using computers and applications that come with them for a while you have an intuitive sense how how big, how fast, and how much resources some of them should take.
that's what is happening here.
most people who are disagreeing with you know intuitively that it is not right, for a chat app -- going for an easy target here -- to grab all your available resources.
I also like that PWA and Electron made more tools on Ubuntu available. Postman and Gravit Designer are great examples.
Memory consumption and performance are problematic though for a lot of them - Electron apps especially.
Sure, Ableton Live and Final Cut Pro are pretty rad, but how much percent of the population uses such tools?
I even switched from Photoshop to Photopea and from Sketch to Gravit Designer, because they are good enough and much less hassle.
If the average user isn’t technical/is forced to use it, there is no business reason to care about user battery life. There is no business reason to care about user cpu usage.
Any reduction in user resource use would require greater business resource use (i.e one of their engineers needing to learn native). Are users willing to pay more for software that saves their battery life? Generally not, as most don’t even know why their battery is draining or their computer is slow.
They just blame it on viruses, Windows, or general belief that their computer is getting old.
The latest attempt is WindowsUI hosting React Native.
I think. This past week, I have tried to walk through a "Hello World" for this pre-release platform, but I have failed to get a build system actually working. Its the "keep installing software until it works or until your system breaks, whichever comes first" problem.
For now, I have chosen to preserve my ignorance of Visual Studio's build targets and project structure. I can only learn five new tools at a time.
But they are not universal for several reasons you fail to account for.
I won't bother categorically defending anything in this article, but I will leave a single statement:
good, fast, cheap - pick two.