Two recent post of mine were ridiculed on r/programmingcirclejerk:
- Building a Simple Stopwatch App with Electron – Submitted by someone as Building a 100MB stopwatch app.
- Compile Node.js to Native Binaries – Submitted by me as Making 60Mb ls clone in JavaScript.
I submitted my own post, because I enjoyed the humor in those threads. At the same time, I am concerned that a lot of people are genuinely missing the bigger picture.
JavaScript is definitely not perfect, but it is not a joke. Far from it.
Electron Apps
My Electron example – a simple stop watch was over simplistic on purpose. I wanted to see how hard it was to build a “native-like” app with Electron. Turns out, extremely easy. Copy some HTML and JS into the index.html file and run the build tool easy.
Some of the top criticism I received was:
It’s not a real native app – true, Electron is a wrapper around Chrome browser. However, while the app may be not native, it appears to be native to the end user. I think this is “good enough” for a lot of use-cases. All I wanted was for my app to be downloadable as a Mac or Windows application, and for users to be able to add that app into their Dock.
It uses a lot of memory – true, Electron apps have to run a full instance of a browser, which is a HUGE overkill for a simple stopwatch app. But I was not trying to build a performant stop watch, nor was it my intention to share my stop watch with anyone else as a real product. I just wanted an interesting example to experiment with Electron.
The bundle size is large – true, it is a big overkill for a simple stop watch. Hundred megabytes size, however, is very reasonable for complex applications.
Speaking of complex applications, Slack, Spotify and Visual Studio Code are all Electron apps. I don’t think I need to say anything about popularity of Slack and Spotify. VS Code is currently one of the most popular text editors, surpassing much more performant Sublime Text.
Why would (relatively) slow and resource hungry VS Code become more popular than Sublime Text? Microsoft’s deep pockets aside, I think the real secret is good developer experience. Both for the core VS Code developers as well as for people writing plugins.
Update: I suffered from a confirmation bias. According to the survey Visual Studio Code only has 7.2% of users, while Sublime Text has 31%. It was Visual Studio, not Visual Studio Code (2 different projects) that had 35.6% of users. Visual Studio Code still is a great editor and I highly recommend it. Together with Atom (the original Electron editor) they have 19.2% of all users. Which is a significant number, but not as high as I initially thought.
Slack already had a great web app, so instead of writing a brand new native application, they wrapped the existing app into Electron. This allowed them to consolidate their efforts into making one app, instead of having to chase multiple tech stacks.
I am not sure why Spotify chose to develop with Electron. but this decision speaks in Electron’s favor, considering that Spotify is mostly a Java shop. Update: It was pointed out to me that Spotify does not use Electron, but an Electron “like” framework.
Native Binaries for Node Apps
My Compile Node.js to Native Binaries (making ls
clone) post received similar criticism. It is easy to draw parallels between Electron apps and compiled Node binaries.
Yes, they are big. Yes, they use more resource than compiled languages. But they are very easy to create and there is true value in developers’ productivity.
Another criticism unique to my simple ls
example, was that I installed a third party library to help me convert the file sizes to a human readable format. Again, I think some people missed the point. I did not do it because I was lazy (well may be a little). I did it to demonstrate how easy it was to leverage the full potential of NPM, which with close to half a million packages is one of the most popular package managers ever.
Conclusion
I have no hopes of convincing hardcore JavaScript skeptics in benefits of JavaScript. I, however, do believe that for a lot of real-world business use-cases Electron and Node apps are good technology choices. There are a lot of real world applications that support this point.