624 points · by LinguaBrowse · 5y ago · 271 comments
However... "Low CPU and memory footprint (...) memory usage is under 20 MB for a Hello World program" : I am the only one who still thinks this is huge ? (-> https://tonsky.me/blog/disenchantment )
IMO there's a tradeoff: we could be writing all our programs in C, still. But it would be enormously difficult and there'd be way more bugs. On the other end of the spectrum we can be lazy, use web tech everywhere and never optimise our ballooning JS codebases. This feels like it's at least somewhere in the middle.
OT but a bone to pick with that article:
> Modern text editors have higher latency than 42-year-old Emacs. Text editors! What can be simpler? On each keystroke, all you have to do is update a tiny rectangular region and modern text editors can’t do that in 16ms. It’s a lot of time. A LOT.
That isn't what my text editor is doing, though. It's doing autocomplete suggestions, linting code as I type... all sorts of things we never had a couple of decades ago and are huge productivity boosters. Sometimes I feel like people forget that.
I remember an article a couple of years ago where someone rigged up a camera to measure key press to screen update on different machines and the results were eye opening.
edit: found it http://danluu.com/input-lag/. The Apple ][ ties for first place with an iPad Pro.
What on earth have we done to ourselves?
That's a big part of what we've done to ourselves. And this makes computers better for a whole lot of people.
No need for that - you could use Zig or Rust. Though both need a better GUI frameworks, but it's certainly more efficient with them.
I moved from sublime to atom to VS code, but eventually settled on Vim because I was able to get the same features (that I used) while getting almost instant response. A feeling that has completely changed how much I enjoy writing any sort of text.
But eventually wasn't able to get the same code completion, and searching was also a bit more painful.
How do you go about that? Would you mind sharing your setup? :)
For C/C++, could use QT Creater or KDevelop too, which I think are pretty good in latency.
BEFORE the typed character shows up? Are you sure?
16ms should be an absolute upper bound for a character to show up. Everything else comes after.
Another example is the Enlightenment window manager. It was considered a little heavy, but good looking. But because there was a large hiatus in development, it got "stuck in the past" and now, it is one of the lightest there is.
I'm just kidding. Don't want to start a fight here.
We had them.
> we could be writing all our programs in C, still.
You don't need to use C, there are other languages. For example a hello world in Free Pascal[0] (a natively compiled language with no runtime or other dependencies, which supports object oriented programming and has RTTI rich enough to implement automatic object serialization, semi-automatic memory management, strings that know about their encoding, etc) is just 32KB.
Some time ago i wrote Fowl[1], a mostly complete recreation of the OWL toolkit that came with Turbo Pascal for Windows, the demo program of which is around 80KB.
Of course for a more realistic (and MUCH easier to use and develop with) approach, you'd need something like Lazarus[2]. A minimal application in Lazarus is 2.18MB. This might sound too big... and TBH it is, but the size doesn't grow too quickly from there. For example a profiler i wrote recently for Free Pascal applications is... 2.16MB (yes, smaller, why? Well, because i replaced the stupidly huge default icon with a smaller one :-P and without the default icon a minimal application is 2.05MB so the profiler added around 100KB of additional "stuff").
> It's doing autocomplete suggestions, linting code as I type... all sorts of things we never had a couple of decades ago and are huge productivity boosters
FWIW we had those, Visual Basic (or even QBasic) would format your code as you type it, Visual Basic 6 and Visual C++ 6 would profile auto-completion (VB6 even for dynamic stuff), etc. Only issue with C++ was that sometimes it wouldn't work around complex macros.
But modern editors do a bit more, still no excuse for being that sluggish. Lazarus does pretty much everything you'd expect from an IDE with smart code completion (e.g. things like declaring variables automatically, filling method bodies, etc) and code suggestions yet it runs on an original Raspberry Pi.
Now i'm not saying that you should not be using whatever you are using or that you should code on a Rasberry Pi or even to switch to Free Pascal / Lazarus (which honestly is far from being free of issues), but i think that you're overestimating what tools do nowadays and many people are so used to running slow and bloated software that take it for granted that things should be like that and cannot even imagine things being better.
[0] https://www.freepascal.org/
Even so, shouldn’t it be able to do that in 16ms?
Do modern graphics drivers for X or Wayland hand off font rendering to the GPU? They probably should -- it's maybe 100 or so small textures per font-selection, 150KB or less prerendered with 3-bit alpha, and maybe 100 loaded up into graphics RAM at a time -- 10MB is nothing, really.
It's just that text editors of the modern day are programmed by people who prefer to not write it that way - mainly because it's quite hard, and the modern OS doesn't usually fit well into this framework of rendering for multi-tasking. And it takes more effort too.
Much easier to rely on a UI framework which adds overhead. The expectation is that the user probably won't care, and prefer that the software be more feature rich.
Also, there was a really fantastic question asked in the last Cosmopolitan thread, but it wasn't answered; what's the answer to it?
Some friend of mine like it :D.
But I'd like that more if it was Scheme.
It might a bit rude to remind that, but the same person saying aforementioned words about huge memory usage promotes the Skija [1], Java-based GUI toolkit, which is even worse in memory consumption than electron (jb-compose provided examples, even in release builds).
[0] Memory Footprint of GUI Toolkits - https://szibele.com/memory-footprint-of-gui-toolkits/
[1] Graphics for JVM - https://tonsky.me/blog/skija/
Electron has been around what? 7 years?
I'm curious what kind of magic is happening where node.js is in the picture yet the executable comes out at ~20MB. Is it simply a bundle of wrappers for most of Qt with Node.js being required to be installed separately? Is it purely UPX compression?
[0] https://stackoverflow.com/questions/450455/minimal-qt-execut...
The entry point in ther starter kit calls qode (a fork of node), which talks to qt via napi (node's API for c++ bindings). It can be distributed as binaries via the *-deployqt toolchains.
So for distributable binary size in disk, we're probably looking at something in the ~100mb range with no UPX shenanigans.
So, tl;dr not as magical as I initially assumed. The trade-off between "bloat" vs ability to use web paradigms feels like a reasonable one. Overall pretty cool stuff.
(2560 * 1600 * 4) / 1024 / 1024 = 15 MB
So no, that is not huge for a modern GUI program.
IIRC on macOS it consumed less than 15MB.
This means that you can't use the OS provided facilities (as they all have different metrics) and have to bundle good font rendering engines (if you care about non-us-ascii people) - that means already ~7-8 megabytes at the bare minimum for that.
RAM is cheap and plentiful. If you don't use it, its value is almost zero (the "almost" comes from OS-level caching of files and CPU-level cache misses of code).
Yet if you use all of it, its value is also zero - to every other program on the same computer. Don't be a dick; Use what you need, not all you can.
The reduction of the complex trade-off between memory use, CPU, disk, development environment, ease of deployment, and the dozen other variables that go into a choice like picking what toolkit to use to "don't be a dick" is so absurdly simplistic. It's a trade-off - not a single-axis "good or bad" decision.
Moreover, 20 MB of memory usage is going to be an acceptable trade-off for the majority of HN users, who skew webdev, not embedded.
I have fond memories of my DOS days and the simplicity inherent in a single tasking environment, however nowadays operating systems allow for more than a single application to run at the same time and each application should play nice with the system resources, so even if RAM is cheap and plentiful it doesn't automatically mean that every application should feel entitled to it.
(and also even during the DOS days we had TSRs which had to be RAM conscious too)
Yes, you shouldn't be a bad neighbor, but the OS will generally move things around to accommodate you as necessary. RAM is an afterthought for most of these applications for a reason.
This attitude is like buying a sports car and never redlining it.
Also HN: "The MacBook Pro is worthless if I can't get it with at least 64GB of RAM."
But the value is also zero if you're using extra for no benefit. Actually it's negative, because it prevents other programs from using it.
You should try to use all your RAM, yes, _but in ways that are actually useful_. The OS can always use leftover RAM for caching frequently used files if you don't have a better use for it.
After doing web dev for years I wrote a desktop application with Qt.
It's not massively complex (but a lot more complex than a hello world) but when it's running the memory usage is very low even compared to 20mb
jart@debian:~/scratch/qtproject$ qmake -project
jart@debian:~/scratch/qtproject$ make
jart@debian:~/scratch/qtproject$ ldd ./qtproject | grep -Po '(?<==> )[^ ]*' | xargs ls -alH | awk '{x += $5} END {print x / (1024 * 1024.)}'
59.5916
That's bigger than I expected to be honest.- Emacs (with 251 open files and IRC running): 100MB
- Activity Monitor: 98MB
- Word: 227MB
- Spotify: 465MB
- Slack: 526MB
- Thunderbird (not Electron, but a similar weird browser hybrid thing): 663MB
- Teams (which appears to be Electron): 747MB
I'm not seeing too much of a blur here. The worst chat app (Teams) is using ~7x the RAM of my primary code editor that also is doing chat :).
Electron does not provide that much more desired features than apps from 25 years ago.
It can be assumed that anything running on the desktop has or will have vulnerabilities. The rise of web applications has been partially due to the assumption of great sandboxing.
I look forward to this project doing well, but it’s not the first time I’ve seen an electron competitor on HN promoting it being Node-based. Node isn’t sandboxed by default.
Apart from the consistent GUI layer, I think an underrated reason that many teams stick with Electron is the mature tooling for cross-platform builds and upgrades. It's pretty painful to DIY.
It looks like NodeGUI doesn't currently support cross-compilation--is that something that's on the roadmap? How about upgrade/auto-upgrade tooling? Code signing?
This is a super-interesting project though.
Agree with your final part, very exciting and gonna be interesting to see where nodegui goes, especially security wise.
You also need to need to redo your subscription/payments to support the stores and give a percentage of your revenue to Apple/Microsoft. On mobile you have no option but on desktop it's hard to justify giving up so much of your profit margin when there's a popular alternative.
BTW, Linux has the Snap Store.
That's already GTK+ and Qt, and the big GTK+ and Qt projects aren't switching over to Flutter any time soon.
That said, I am writing a Git desktop client in Flutter and I like it. But I don't expect to finish it for many years so hopefully by then they'll have ironed everything out.
Atul is licensing NodeGUI as MIT, so I’m licensing Svelte NodeGUI as MIT accordingly.
"In case of dynamic linking, it is possible, but not mandatory, to keep application source code proprietary as long as it is “work that uses the library” – typically achieved via dynamic linking of the library."
However, one thing to note: the OSS version of Qt uses the LGPLv3 license, which has additional restrictions (like the "Anti-Tivoization" clause) which make it incompatible with the iOS AppStore thus forcing you to use the commercial version of Qt in those situations. Not sure about the Mac and Windows 10 app stores, I am curious if anyone knows/has experience with LGPLv3 and those stores?
[1] https://github.com/chromium/chromium/search?q=%22kde.org%22
As for desktop only this is great. Great work. Many people are commenting on NodeGUI only. They have forgotten to mention how Svelte also contribytes to saving memory footprint and cpu cycles over other frameworks with a much easier way to write apps. Add a small learning curve to that.
If you use the Qt commercial license for either, then you don't need to worry about your app conforming to the LGPL.
[1] https://wiki.qt.io/Licensing-talk-about-mobile-platforms
So, my question is, how much work is there to convert a web app built with Svelte to a Svelte NodeGUI app? Will most things just work, or should I expect to have to rebuild a lot of functionality?
Second, my app will make use of WebGL (or possibly WebGPU in the future) and have done wasm components. Do these work with NodeGUI?
So, my question is, how much work is there to convert a web app built with Svelte to a Svelte NodeGUI app? Will most things just work, or should I expect to have to rebuild a lot of functionality?
2. Thank you for backing up your claims about a native implementation by actually providing one, unlike your competitors Tauri and Wx who constantly lie about the topic.
I actually happen to be struggling to get React Native in the NativeScript runtime right now – running it in the Node.js runtime would be if anything even more challenging. But there are other ways to make the two work together.
The project’s webpage has way too many tech listed to be of any help, and the video mentions a framework, an IDE, a debugging environment...
Do you have a good link where i could get a better understanding of the tech, and how it’s used in real world project ?
Edit: NodeGUI here: https://github.com/nodegui/nodegui
yep, basically you have to do :
auto window = QWindow::fromWinId(reinterpret_cast<WId>(/* HWND, NSView, X11 buffer, Wayland surface... /*));
auto widget = QWidget::createWindowContainer(window);
and then you can use the widget like any other Qt widget, put it in a layout, etc... (of course caveats may apply when you start doing transparency or other fun things).This is confusing for me. I think such a framework is either 'platform agnostic' OR 'native'. Maybe the API is platform agnostic and the rendering is done natively?
An example of native UI is libui or WxWidgets.
What I would have liked to have seen instead of Electron would have been a shim API that abstracted OSX/iOS/WinForms/QT webviews, and for those webviews to have a working API that would allow DOM manipulation, and allowed native sub-views to be inserted as block elements.
http://forums.apricitysoftware.com/t/why-is-markdownpad-spaw...
In any case you were still dependent on IE10/11 at the best, and certainly nothing as modern as the old Edge, much less the Chromium-based Edge. And on older Windows versions it completely depended on whether the user had upgraded IE.
You could write HTML/CSS/JS that was portable between IE10/11 and other native browsers, just as we all did in actual websites. I did this for Mac/Windows in the past and it worked, but it was fairly compelling for web developers to have a single browser version to target instead of the various incompatible native web views.
The situation is a bit different now, where you can get an Chromium Edge view on Windows 10 and a Safari view on Mac, but what do you get on Linux? I don't know.
You had to use JavaScript or VBScript but all the safety rails are off, this is pre-sand boxing, what do you mean websites might be malicious why would someone make one like that... you could do crazy things, and fully leverage windows APIs directly without much effort via VBScript, I once used the winforms(?) APIs to introspect field labels and names to automate the driving of multiple desktop apps from a crazy jquery and VBScript monstrosity. Made me twice as efficient at that job though so it was awesome.
You could control child iframes and pop up windows (remember these?) and VBScript let you shoehorn quite a bit of native UI type stuff whenever it was going to be easier than building something with simple forms, JavaScript, tables and frames. If you got really fancy you would Base64 some absurd binary into your app and unpack it on the fly with VBScript then call it from a temp directory in order to drive things like interacting with network services that didn’t have any sort of thing you could work with via HTML JavaScript and XMlHTTRequest (this was the very dawn of Ajax)
Binary is ~5MB, and that is HTML/CSS + QuickJS + NodeJS runtime.
Versus 50MB+ of NodeGUI that is Node.JS + QT.
And SvelteJS works in Sciter.JS out of the box too.
I recall a crowd-sourcing campaign to make this toolset fully open - did that succeed? What's the current state? For me a signal to use sciter would be it's inclusion into the debian/ubuntu repository.
https://github.com/c-smile/sciter-js-sdk/blob/main/LICENSE
The only unusual limitation is that you're not allowed to say "built with Sciter" without getting permission from the maintenaners. You can still use it for commercial projects though.
I envision something where you can just use your regular web app, have the user install the "Desktop Connector" which would be listening at say, port 8000 - then your web app can talk to the desktop via those APIs, instead of installing an Electron or related.
I must be missing/forgetting something crucial since that seems like the most straightforward solution imaginable.
It also has security implications if you are exposing OS functionality to websites. I remember Dell having a bad one a couple years ago.
There is also an antivirus browser extension that works in a similar way. It installs a native C++ executable that the extension interacts with. That has a huge security footprint. IIRC they rolled their own parser (HTML?, JSON?) and it went predictably bad.
There are lots of implications to consider. I'd like to see progressive web apps fill this niche on the desktop. They have various mechanisms for persistence of data and WASM will increase the practical use cases. Hopefully the APIs available to PWAs in the future will allow all sorts of new use cases.
Of course, it could run headless, too. But there is attraction in making it an app that opens like familiar executables.
I especially love the idea of Svelte (compiling to imperative JavaScript code), but since it's technically a "superset" of JavaScript, IDE support has been an issue for me. Also I've cut my teeth trying to find a solid UI component library. These two things have restricted my use of the framework to smaller projects.
Anyone have any suggestions?
At Monitoro[0] we bit the bullet and implemented the vast majority of our components from scratch. Apart from the obvious time to develop and test, and the trailing bugs that are hard to solve for small closed source projects, the experience wasn’t that bad.
Ultimately what helped us the most is writing our components using a state machine-like pattern, mixed with TailwindCSS to make styling easier.
In our case, the effort was worth it as we anyway needed several super specific components, and now that we’re over the hill we have complete control on our UX.
(Also having built component libraries/design systems before in different UI frameworks, doing it in Svelte was one of the best experiences so far)
There are some efforts in the Svelte ecosystem but they’re small and do not have much firepower behind, thus limited or of relatively low quality.
Wow, must mean the project is real important. I agree that svelte is interesting, but focusing on metrics and popularity is the wrong approach to new technology.
A component library is a bit much to come until Svelte NodeGUI gets a bit more attention. Even Svelte web projects are underpopulated on component libraries, I believe. But it’s worth trying out the built-in primitives first!
Perhaps a way to bootstrap that would be to align closer to react-native; at that point, we could use (js) components and libraries from react-native land.
The QT licensing question is also somewhat iffy; you need to put front and center what that implies for users of your library (do they need to open source their use of react-nodegui by extension of QT's licensing requirements for example).
Is it just way simpler to use, like electron? Or does QT offer a more consistent cross platform experience? Or is it more mature than react-native-macos? Or for when you want to run on linux?
All things that could be appealing to me if it did that.
However, react-native does have a sizeable addon ecosystem including UI frameworks (nowhere near web, but definitely more than nodegui's zero).
I didn't try react-native-macos, but I am using react-native-windows, which is functional enough and lets us share code between iOS, Android and Windows (I want to try react-native-macos but it looks like it doesn't get as much investment as windows).
Unfortunately the license of Ultralight is questionable, and it's not open-source either by bypassing the WebKit license (which is very questionable as well since WebKit itself is BSD-licensed).
Having such a project as a free open-source variant would be a huge game changer in my opinion.
> Low CPU and memory footprint. Current CPU stays at 0% on idle and memory usage is under 20mb for a hello world program.
20MB!
ex) nw.js, electron.
Then this project sounds perfect for you because it's not a browser, it's Qt5 but called via APIs that JS developers are used to.
To answer your question, there is no more HTML involved in this than in a React Native app. The result looks like HTML, but it’s really used to compose native OS widgets.
you think that would stop a zero day vulnerability? if you have browser that won't be updated for a long time and its connected to the internet, it is a huge attack surface.
Unless you were running local static file without ever talking to the internet.
Really impressive resource-wise, now let's get the UI components / frameworks ported...
It's using the same JavaScript engine as Chromium, which is of course developed by Chromium and is part of it, but without the rest of Chromium, as Node.js always has.
It's a great example of synecdoche [1]. :)
Anyway, it was just a misunderstanding based on poor writing on the web page.