7 ms·
Best part: a hello, world GUI app (a dialog with a textbox and a button that pops up a message box) is ~2.5 Mb on Win32. This was something like 500 Kb back in
by int_19h 2y ago
Best part: a hello, world GUI app (a dialog with a textbox and a button that pops up a message box) is ~2.5 Mb on Win32.
This was something like 500 Kb back in 2000, but it's still a far cry from your ~200 Mb Electron hello world.
- mrweasel 2y agoCan't you still do much the same with WinForm, or maybe GTK?
- int_19h 2y agoWith WinForms you can do much better, in large part because .NET itself ships with Windows and thus the app can just rely on it being there, but also because C# compiles to bytecode rather than native code (so it's not exactly a fair comparison). Anyway, the identical hello world GUI app in C#/WinForms is ~11 Kb. With Gtk, no, because it implements all widgets by itself rather than wrapping Win32, so it'll necessarily be larger. Also, statically linking it can be a pain (and AFAIK isn't even supported in Gtk 4 anymore).
- pjmlp 2y agoEven if C# compiles to bytecode, NGEN has been part of the framework since version 1.0, although using strong named assemblies might be bit of a pain. Then there is .NET Native and Native AOT.
- int_19h 2y agoYou couldn't redistribute NGen'd binaries tho, it was basically a local AOT'd cache. As far as Native AOT, last I checked it requires trimming which breaks WinForms (and WPF) according to the official docs. I don't think this matters much, though. There's simply no practical reason to AOT-compile a WinForms app. Not when the framework is guaranteed to be there, and JIT compiler is plenty fast.
- spapas82 2y agoI remember some years ago that I was able to make this less than 1mb. It needed a little tweaking like upx but nothing very complex. Lazarus should have been the golden standard for creating desktop apps. Every other solution I've tried is subpar either in licensing or costs in general, executable size and resource usage, non native components, extra dependencies etc
- _mlbt 2y agoI think unfortunately what holds Lazarus back is the Pascal programming language. Although it is a very capable language that can hold its own against other languages, it suffers from a reputation of being obsolete. It’s a pity that the C family of languages won out over Wirth’s languages. Pascal’s superior string handling alone would have saved us from countless security flaws.
- anonzzzies 2y agoAnd complex compiling. Pascal compilers are very fast.
- never_inline 2y agoCan someone recreate it in Go?
- baq 2y agoGo is basically Pascal with curly braces anyway. Wonder if a Pascal to Go transpiler could work here...
- int_19h 2y agoDelphi/FP Component Pascal has a well-developed object model that is more expressive than Go in general (inheritance, virtual methods including virtual static methods etc), so it's not a 1:1 mapping. But all of these still have a straightforward mapping to Go, even if the output wouldn't be idiomatic, so it should be possible to transpile.
- csmpltn 2y agoThat’s a lot. I don’t know the specifics of Lazarus, but this typically screams static linking with everything and the kitchen sink being thrown into this one binary. Entire cross-platform runtime, GUI assets, metadata, etc. Could be a fat debug build, too.
- int_19h 2y agoThat's indeed a statically linked binary. Release, with smart linking (so only things that are actually used are linked; otherwise it'd be ~20 Mb), debug symbols stripped. Measuring .exe size when linking dynamically would kinda defeat the purpose of the experiment, since you'd still need to distribute the DLLs to the users for any real world app.
- p_l 2y agoIt was the common complaint about writing VCL apps in Delphi - that single message box app would be 0.5MB binary. But that was the static overhead of VCL core library and the benefits were considerable compared to writing raw WinAPI. And unlike MSVC 16kB WinAPI executable you didn't have chance of sudden surprise "oh, but you need to update msvcrt.dll to run this" because Delphi (and Lazarus/FPC) default to statically linking the runtime
- dist-epoch 2y agoDoes it have dark theme support and does it sync it's theme with the system one?
- int_19h 2y agoNot with the Win32 backend, since those widgets themselves don't have that notion. Qt backend should be able to do that, though (but then of course you need all those Qt DLLs).
- api 2y agoWindows widgets don’t have dark mode support on Windows?
- 0points 2y ago> Not with the Win32 backend, since those widgets themselves don't have that notion.
- okanat 2y agoWin32 ones don't only new WinUI ones do (similar to GTK2 vs GTK3+). You need to add that coloring manually. You can query the dark mode with Win32-only API[1] but you need to make your own styles or you can use undocumented APIs (that can break anytime) that Microsoft uses internally for the applications shipped with Windows[2] [1]: https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-wininichange https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-wi... [2]: https://github.com/ysc3839/win32-darkmode https://github.com/ysc3839/win32-darkmode
- notpushkin 2y ago(GTK 2 does support dark themes, of course, it just doesn’t have a concept of “light/dark theme variants” natively. And come to think of it, it’s the same in Win32: see e.g. the Zune theme for Windows XP.)
- scotty79 2y agoBest part for me that it's a single file executable. I chose to do a thing in Pascal last year just because of this one killer feature. I made some initial attempts to achieve this with something else but I didn't find any modern tool that could do that without some weird, sometimes involved, sometimes straight up experimental steps.
- superdisk 2y agoI think Go will do it, but I indeed enjoy Free Pascal for this as well. It's also nearly trivial to set up cross compilation using FPCUpDeluxe, so I've shipped applications to clients on Windows when I do all development and compiling on GNU/Linux.
- nanoxide 2y ago.NET can create self-contained executables pretty easily (via _dotnet publish_), both including the required framework assemblies and without them. But they'll still be comparatively large.
- neonsunset 2y agoFor JIT binaries it’s best to apply /p:PublishTrimmed=true which (sometimes massively) reduces their size. Applications written in AvaloniaUI or, nowadays, WinUI 3 can be compiled with NativeAOT which reduces the size and memory usage even further.
- maneki-neko 2y ago> written in AvaloniaUI or, nowadays, WinUI 3 Be aware that this is what you're getting into when you pick dotnet for GUI applications. It's been that way for decades at this point, there are many unfixed bugs in WPF for example, in spite of it being touted as the final word in GUI development in its time and still being used for some Microsoft applications like VS. Meanwhile, with Delphi you were using VCL 20 years ago, and you're still using VCL today, and its development velocity and performance is light years ahead of anything Microsoft put out during that time. This also applies to Lazarus's LCL.
- alok-g 2y agoMore generally, which all tools that can target multiple platforms, produce relatively small binaries for simple applications? And which of these are lean themselves? May be I am doing something wrong, but I had installed Android Studio, then Android emulator, SDK, etc., and before I could get a hello-world app to compile, some 30 GB were gone from my disk space. If it comes to it, I do not personally mind using multiple tools and code for different target platforms, as much as (a) both the tools themselves and the binaries generated are lean, and (b) the development tooling itself is on a single platform just so that I do not need to maintain multiple hardware. (I currently use Windows, would likely need to move over). Thanks.
- billfruit 2y agoJava perhaps? That was one of the core promises of the Java ecosystem.
- _mlbt 2y ago> produce relatively small binaries for simple applications The problem is that you need to have a huge Java runtime installed or use something like Jlink which still produces very large binaries for GUI apps. I think wxWidgets is the Lazarus alternative that is the closest to what grandparent was asking for. https://wxwidgets.org/ https://wxwidgets.org/
- Peter5 2y ago2.5 MB is for most of the Lazarus Component Library (LCL) with minimal size increases even as program complexity grows. For example, Dadroit JSON Viewer EXE is less than 6 MB while having complicated tree views, JSON handling, networking, and more. By the way, an empty CLI EXE on Windows is less than 50KB.
- klipt 2y agoWhy doesn't the linker strip out unused code?
- magicalhippo 2y agoI imagine it's for the same reason Delphi can't strip much, which is that it supports run-time reflection. You can create an instance of a class using a string of the name. Forms (windows) are deserialized during loading, which relies on this mechanism.
- zabzonk 2y agoNot Pascal but here is something I wrote on the same lines in C++: https://latedev.wordpress.com/2011/10/06/simple-windows-dialogs-from-c-part-1/ https://latedev.wordpress.com/2011/10/06/simple-windows-dial...
- dotancohen 2y agoMaybe you're the person to ask. My Python Qt app is sluggish when it loads tens of thousands of values from SQLite. Various variations of pagination and lazy loading hurt usability. But isolating the issue and testing with C++ and Rust show that those two languages don't have the performance hit of Python. I could use C++ and stick with Qt, but I'd much prefer Rust. Rust has no good Qt bindings. What are my options? The app makes use of QV/HBoxLayout, QWidget, Qdialog, QPushButton, and other really standard features. It reads from the filesystem, reads and writes to SQLite, and outputs sound from mostly ogg files at various speeds (through VLC behind the scenes). I stick with Qt because I like how it integrates with KDE and other desktops flawlessly.
- jpc0 2y agohttps://areweguiyet.com/ https://areweguiyet.com/ Also did you test similar functionality in C++, I haven’t compared many implementations but I app I use that has an SQlite db being read with Qt(C++) is pretty sluggish whenever you touch the DB. Maybe store the values in a dict and only read/write from sqlite when needed. Dicts are very fast in python.
- dotancohen 2y agoYes, that's what I'm doing. It's the initial load that is heavy. I've also tried implementing lazy loading and pagination, with a pseudo-infinite scroll technique based on SQL LIMIT pagination, but the resulting CPU and memory spikes are noticeable.
- prmoustache 2y agoThis website is useless if accessibility compatibility is not mentionned.
- jenadine 2y ago> I could use C++ and stick with Qt, but I'd much prefer Rust. Rust has no good Qt bindings. What are my options? There are several Qt binding for rust, for example cxx-qt. I haven't tried myself but it looks maintained. Why is it not good? Otherwise, the most promising equivalent to Qt in Rust would be Slint.
- jenadine 2y agoIs that statically linked or dynamically link? If the later, does it include all the libraries and assets it uses?
- KronisLV 2y ago> it's still a far cry from your ~200 Mb Electron hello world. I think that projects that ship packaged web apps but attempt to use the system native web views where available are really nice, like Wails: https://wails.io/ https://wails.io/ (so for example, on Windows it would use Webview2, so you don't have to package an entire Chromium install yourself) Here's a comparison of how the distribution sizes change, Wails in particular also has way faster builds than something like Tauri: https://github.com/Elanis/web-to-desktop-framework-comparison https://github.com/Elanis/web-to-desktop-framework-compariso... That said, I wish we got more native software, or even something like LCL that can target Win32, GTK, Qt or whatever else is available. Sure, writing components that are available on a lot of platforms and work similarly everywhere is a pain for the developers, but I applaud the effort regardless, since the above solutions like Wails don't actually do anything for the memory usage and CPU cycles, whereas native GUI software is better for most apps that don't try to be very interactive. I could even see myself using Lazarus/Pascal more if it seemed to have a more active ecosystem, right now I couldn't tell you what are the equivalents of something like Spring Boot for webapps, or even consuming Web APIs in client software, handling OAuth2/OIDC/JWT, seems like mORMot 2 would fit the bill the closest?
- int_19h 2y agoAs I understand, the main problem with native web views is that you now have to deal with all the inconsistencies of e.g. Blink vs WebKit. Also, browsers tend to be more aggressively updated, which translates to potential app breakage due to bugs or deprecated features. With respect to Lazarus, I agree that the ecosystem around it is not exactly great. It would be interesting to see LCL ported to something more modern that is reasonably simple, cross-platform and has good tooling. E.g. Go, much as I dislike it as a language, would probably be a great fit for something like that. And Pascal being fairly conservative and easy enough to parse, I suspect you could even automate this translation for the most part.
- WillAdams 2y agoOne thing I've always kind of wished for was a way to write the WEB dialect of Pascal in Lazarus --- then one could use Web2C --- if one could just link in platform-specific GUI libraries....
- lukan 2y agoBut if you don't target windows, but the web as target plattform, you will need just 53 bytes that will work, wherever a browser works. <input type="button" onclick="alert('hello world')" />
- int_19h 2y agoNow do a data grid backed by a database.
- lukan 2y agoJust some lines more? I am sure modern LLMs can print out tons of different versions for your specific usecase and it will be way less than 2.5 MB. HTML and JS is compact. The browser is not. But often installed already, so my PWA is very small as a result, but behaves quite native. (But if you mean, that Lazarus can do that easily with a GUI, that would still be cool. Can it?)
- Bolwin 1y agoEven if you do target windows, tauri apps can be a couple megabytes
- svdr 2y agoWho remembers Steve Gibson's 'little corner of the web'? He wrote super small Windows applications in assembly: https://www.grc.com/smgassembly.htm https://www.grc.com/smgassembly.htm
- jjkaczor 1y agoDefinately remember it fondly - and Jeff Duntemann who continues to update and publish his definitive works on learning assembly - the latest edition/revision is: "x64 Assembly Language Step by Step" - https://www.contrapositivediary.com/?page_id=5070 https://www.contrapositivediary.com/?page_id=5070
- WillAdams 1y agoVividly! In particular, his tech e-mail announcement/newsletter was where I first learned of a small startup w/ the unlikely name of "Google".