17 ms·
Notice the binary size of the app is only 64KiB. In the demoscene this would be a disqualification as it's 676 bytes over the limit, but in this case I'll over
by userbinator 7y ago
Notice the binary size of the app is only 64KiB.
In the demoscene this would be a disqualification as it's 676 bytes over the limit, but in this case I'll overlook it because of the sheer awesomeness of what you've done (and I'm sure trimming off 676 bytes wouldn't be too difficult ;-)
More seriously, this is an excellent proof-of-concept that a Slack client does not need to use hundreds of MB of RAM and consume most of a modern CPU core to provide its basic functionality. I'm a long-time Win32 programmer who started in the tail-end of the Win16 days and one of the things I've wanted to write if I had the time and need was a Win32 native Slack client, to show that it can be done with far less resources, but you've gone even further with Win16. Win32 has native TLS support (via SChannel library, not well-documented but examples exist) and you'd be able to even use it practically (32-bit applications will run on all current versions of Windows, both 32 and 64-bit.)
Note that C89 only prevents declarations of variables in the middle of a scope; you can simply create an inner scope with new variable declarations at its start. Like so...
case WM_PAINT: {
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
...
}
Another small tip: if you make it a dialog-based application, you won't have to bother with WM_PAINT and drawing text yourself --- you can just make the "statusText" and "settingsText" edit controls, and use SetWindowText (or SetDlgItemText) to set their content. They will paint themselves automatically just like the listboxes that you used for the chat contents and userlist. At least you'll save some of those 676 bytes that way...
- tomjen3 7y agoI can't help but agree with you. Honestly I think it went to hell when we decided that it was acceptable to call an electron app native, but that may have been a symptom, not a cause.
- DaiPlusPlus 7y agoBefore Electron people had the arguments about bloated apps when it came to WPF and Qt. And Java apps, like WPF (and most Qt apps I’ve used lately) lacks true integration with native OS widgets so as a user I get an uncanny-valley feeling. At least with Electron you’re essentially forced to style everything - and ever since Windows 8 (or Windows Vista) Microsoft has been actively uglifying native widgets.
- jcelerier 7y ago> Before Electron people had the arguments about bloated apps when it came to WPF and Qt. which is funny when you see that Qt runs on microcontrollers now.
- tomjen3 7y agoI did consider Java as I was writing it, but at the same time Java is actually pretty fast, but there is no doubt that it doesn't use native components most of the time (there is a gnome toolkit bindings for Java, so it is possible). Still Java feels speedy, I think because it is compiled and doesn't need wacked workarounds like not having non-floating point numbers.
- DaiPlusPlus 7y agoI’ve never seen Java running on Windows 3.x - how long did they maintain it for? Or did it use Win32S? Update: ah, Microsoft released their own port in 1997: https://www.cnet.com/news/ie-gets-java-for-windows-3-1/ https://www.cnet.com/news/ie-gets-java-for-windows-3-1/ - I wonder how long they maintained that for.
- zanderz 7y agoSome years ago I worked on a very popular Windows desktop C++ program that had to stay small and backwards compatible, which meant only Win32 APIs and homemade libraries. Designers by the dozens would be hired, then get fed up with these limitations and quit, complaining that they wanted to have the freedom to make UIs in HTML and CSS, and that users are used to interacting with Web UIs so everything should look like that. Later, at a different job, the UI was Electron based, but designers no longer worked in HTML, they used some other tools and it had become the job of engineers to write the HTML and CSS to match. These trends seem to be driven partly by conventional wisdom about the lowest common denominator among young people in the workforce, e.g. javascript and html are so much easier, let's build everything on those, and next thing you know those have become a given and the next crop of kids will use something new on top of that. Or maybe something like QT will win and native code will become a first class citizen again with secondary support inside browsers via WebAssembly?
- userbinator 7y agoSome years ago I worked on a very popular Windows desktop C++ program that had to stay small and backwards compatible, which meant only Win32 APIs and homemade libraries. That's funny, because it's exactly the type of job I'd love doing --- and I have been working on stuff like that (native code, mostly Win32, with some hardware/drivers/embedded stuff) for a long time; if you haven't guessed already, I try to stay very far away from the web stuff, even though I know HTML/CSS/JS and can use it if needed.
- tomjen3 7y agoI mean I am not a fan of C++ (though I don't hate it either), and I love how easy and well libraries for e.g Python works together and how easy they are to find and install, but I don't think it is necessary to go all the way to native code -- Java/Kotlin on the JVM performs pretty well (and you can always outsource the heavy parts to C).
- rvanmil 7y ago> More seriously, this is an excellent proof-of-concept that a Slack client does not need to use hundreds of MB of RAM and consume most of a modern CPU core to provide its basic functionality. If you’re so sure that this is possible, then where is the Electron competitor which allows us to build cross platform applications like this, with the same levels of productivity and a consistent and decent user interface? No one needs to be convinced that a native Slack client for each platform would be much better, I wish they would build those clients. The problem is most companies can’t reasonably justify the costs of building multiple native clients when a single cross platform one is good enough.
- bonzini 7y agoQt and to some extent GTK+ come close. GTK+ can be programmed in Vala which is a fine language that transpiles to C and supports idioms such as asynchronous programming.
- marton78 7y agoThat's cross platform for Windows, Mac and Linux, but what about Web, Android and iOS?
- tjoff 7y agoYou do not want the same UI on desktop and mobile.
- shakna 7y agoIgnoring that you probably _don't_ want the same interface across all of those... Qt, as well as Windows, macOS and Linux actually can do Android [0] and iOS [1], and Web is halfway there [2]. [0] https://doc.qt.io/qt-5/android.html https://doc.qt.io/qt-5/android.html [1] https://doc.qt.io/qt-5/ios.html https://doc.qt.io/qt-5/ios.html [2] https://wiki.qt.io/Qt_for_WebAssembly https://wiki.qt.io/Qt_for_WebAssembly
- danShumway 7y ago
- stevefan1999 7y agoIt feels a lot closer to write for MCUs if you write for 16-bit programs nowadays. The only difference is that MCUs are much more barebone and so less managed, but the constraints set by hardware however is the most distinctive common spot.
- DaiPlusPlus 7y agoMCU?
- markus92 7y agoMicrocontroller unit.
- stevefan1999 7y agoThink MCUs are of the kinds like Arduino and microBit. There are also SBCs where bigger and more power hungry devices like Raspberry Pi belongs to.
- that_jojo 7y agoSuper late, but the term MCU refers to the actual chip -- analogous to SoC for the main chip on a raspi. You don't call the raspi an SoC, and it's debatable that you'd call a prototyping platform like Arduino an MCU. The MCU is the main Atmel AVR, Microchip PIC, or similar part that drives such a board.
- AdrianB1 7y agoThere is no direct correlation between the size of an executable (64kb) and the size of the RAM usage (can be hundreds of MB). I could not find any information about the total memory usage of the application, is it described anywhere?
- amiga-workbench 7y agoIts running on a ThinkPad 390e, 64mb as standard, and tops out at 256mb, so there is your upper bound. Even at an absolute worst case it still beats the pants off Slack.
- yeokm1 7y agoYou are correct. My 390E has 384MB of RAM but only 256MB is accessible by Win 3.1. An earlier blog post shows this http://yeokhengmeng.com/2016/09/windows-for-workgroups-3-11-on-vintage-and-modern-hardware-in-2016/ http://yeokhengmeng.com/2016/09/windows-for-workgroups-3-11-...
- StavrosK 7y agoAnd is probably quite a bit faster, too.
- cwyers 7y agoIt's also lacking so many features as to be unusable.
- yeokm1 7y agoWin 3.1 apps can also access memory in 64K segments which I only use 1 to hold the humongous HTTP+JSON reply from Slack. Wikipedia says "However, no single process can use more than 16 MB.". Not sure where is the source of that though. https://en.wikipedia.org/wiki/Windows_3.1x https://en.wikipedia.org/wiki/Windows_3.1x
- deleted 7y ago[deleted]
- yeokm1 7y agoHey thanks for the tips. Let me adjust the blog post to mention this point
- bluedino 7y agoIt's kind of silly compare a bare bones get/post to an entire app. This reminds me of my attempts to write an IRC client in an evening. Creating a native Windows app to mimic the Electron Slack client would not be a trivial task.
- shaan7 7y agoHis point is that this bare bones get/post app in Electron will be much, much "larger".
- harshitaneja 7y agoAnd that is why it would foolish for them to post a barebones slack client in electron. But they don't publish that. They have published a full featured client that is cross platform. I am not a fan of electron and would very much prefer a desktop app. But we are finally seeing emergence of desktop applications from major players for Linux because of electron. It's not ideal but so wasn't the previous solution.
- Snetry 7y agoExisting frameworks like Qt or GTK could also be used for a Cross-Platform solution And just because it's electron doesn't mean it's inherently Cross-Platform look at discord for example It took too long for a initial desktop client to be released and then it ha issues with things like screen sharing not working as expected
- tjpnz 7y ago>Existing frameworks like Qt or GTK could also be used for a Cross-Platform solution They could but finding engineers with that kind of experience would be harder and cost a lot more. Far easier to retrain web frontend engineers.
- mileycyrusXOXO 7y ago