A place to cache linked articles (think custom and personal wayback machine)
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

4 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. title: Electron considered harmful
  2. url: https://drewdevault.com/2016/11/24/Electron-considered-harmful.html
  3. hash_url: b9b6d921a44a7b2d1b01da6f20228667
  4. <p>Yeah, I know that “considered harmful” essays are allegedly <a href="http://meyerweb.com/eric/comment/chech.html">considered
  5. harmful</a>. If it surprises you that
  6. I’m writing one, though, you must be a new reader. Welcome! Let’s get started.
  7. If you’re unfamiliar with Electron, it’s some hot new tech that lets you make
  8. desktop applications with HTML+CSS+JavaScript. It’s basically a chromeless web
  9. browser with a Node.js backend and a Chromium-based frontend. What follows is
  10. the rant of a pissed off Unix hacker, you’ve been warned.</p>
  11. <p>As software engineers we have a responsibility to pick the <em>right</em> tools for the
  12. job. In fact, that’s the <em>most important</em> choice we have to make when we start a
  13. project. When you choose Electron you get:</p>
  14. <ul>
  15. <li>An entire copy of Chromium you’ll be shipping with your app</li>
  16. <li>An interface that looks and feels nothing like the rest of the user’s OS</li>
  17. <li>One of the slowest, least memory efficient, and most inelegant GUI application
  18. platforms out there (remember, we <em>tolerate</em> frontend web development because
  19. we have no choice, not because it is by any means <em>good</em>)</li>
  20. </ul>
  21. <p>Let’s go over some case studies.</p>
  22. <p><strong><a href="https://github.com/mifi/lossless-cut">lossless-cut</a></strong> is an Electron app that
  23. gives you a graphical UI for <em>two ffmpeg flags</em>. Seriously, the flags in
  24. question are -ss and -t. No really, that’s <em><a href="https://github.com/mifi/lossless-cut/blob/master/src/ffmpeg.js#L46">literally all it
  25. does</a></em>. It
  26. doesn’t even use ffmpeg to decode the video preview in the app, it’s limited to
  27. the codecs chromium supports. It also ships its own ffmpeg, so it has the
  28. industry standard video decoding tool <em>right there</em> and doesn’t use it to render
  29. video. For the price of 200 extra MiB of disk space and an entire Chromium process
  30. in RAM and on your CPU, you get a less capable GUI that saves you from having to
  31. type the -ss and -t flags yourself.</p>
  32. <p><strong><a href="http://1clipboard.io/">1Clipboard</a></strong> is a clipboard manager. In Electron. A
  33. <em>clipboard manager</em>. In order to show you <em>a list of things you’ve copied</em>, it
  34. uses <em>an entire bundled copy of Chromium</em>. Also note that despite the promises
  35. of Electron making cross platform development easy, it doesn’t support Linux.</p>
  36. <p><strong><a href="https://getcollectie.com/">Collectie</a></strong> is a… fancy bookmark manager, I
  37. guess? Another one that fails to get the cross platform value add from Electron,
  38. this only supports OS X (or is it macOS). For only $10 bucks you get to organize
  39. your shit into folders. Or you could just open the Finder for free and get a
  40. native UX to boot.</p>
  41. <p>This is a <a href="https://hyper.is/">terminal</a> written with Electron. On the landing
  42. page they say “# A terminal emulator 100% based on JavaScript, HTML, and CSS”
  43. like they’re proud of it. They’ve taken one of the most lightweight and
  44. essential tools on your computer and bloated it by orders of magnitude. Why the
  45. fuck would you want to render Google in your god damn terminal emulator? Bonus:
  46. also not cross platform.</p>
  47. <p>This is not to mention the dozens of companies that have taken their websites
  48. and crammed them into a shitty electron app and called it their desktop app.
  49. Come on guys!</p>
  50. <p>By the way, if you’re the guy who’s going to leave a comment about how this blog
  51. post introduced you to a bunch of interesting apps you’re going to install now,
  52. I hate you.</p>
  53. <h2 id="electron-enables-lazy-developers-to-write-garbage">Electron enables lazy developers to write garbage</h2>
  54. <p>Let me be clear about this: JavaScript sucks. It’s not the worst, but it’s also
  55. not by any means good. ES6 is a really great step forward and I’m thrilled about
  56. how much easier it’s going to be to write JavaScript, but it’s still JavaScript
  57. underneath the syntactic sugar. We use it because we have no choice (people who
  58. know more than just JavaScript know this). The object model is whack and the
  59. loose typing is whack and the DOM is super whack.</p>
  60. <p>When Node.js happened, a bunch of developers who never bothered to learn more
  61. than JavaScript for their frontend work suddenly could write their crappy code
  62. on the backend, too. Now this is happening to desktop applications. The reason
  63. people choose Electron is because they are <em>too lazy</em> to learn the right tools
  64. for the job. This is the <em>worst</em> quality a developer can have. You’re an
  65. engineer, for the love of God! Fucking act like one! Do they build square
  66. airplanes so they don’t have to learn about aerodynamics, then just throw on an
  67. extra ten engines to make up for it? NO!</p>
  68. <p>For the love of God, learn something else. Learn how to use GTK or Qt. Maybe Xwt
  69. is more up your alley. How about GNOME’s Vala thing? <em>Learn another programming
  70. language</em>. Learn Python or C/C++ or C#. Fun fact: it’ll make your JavaScript
  71. better, and once you have it in your toolbox you can make more educated
  72. decisions on the appropriate tool to use when you face your next problem. Hint:
  73. it’s not Electron.</p>
  74. <h2 id="some-electron-apps-dont-suck">Some Electron apps don’t suck</h2>
  75. <p>For some use-cases Electron is a reasonable choice.</p>
  76. <ul>
  77. <li><a href="https://code.visualstudio.com/">Visual Studio Code</a>, because it’s a full
  78. blown IDE with a debugger and plugins and more. It’s already gonna be
  79. bloated.</li>
  80. <li><a href="https://www.gitkraken.com/">GitKraken</a>, because HTML is a decent interface for
  81. rendering the sorts of visualizations git needs</li>
  82. <li><a href="http://www.soundnodeapp.com/">Soundnode</a>, because it’s not like any other
  83. music service’s app obeys your OS’s UI conventions</li>
  84. <li><a href="https://www.nylas.com/">Nylas</a> but for the love of god don’t use it to send
  85. <a href="/2016/04/11/Please-use-text-plain-for-emails.html">HTML emails</a></li>
  86. </ul>
  87. <p>Uh, that’s it. That’s the entire list.</p>