Last month, I wrote about my experience building an emulator for the DMD 5620 computer terminal. Well, I’m going to revisit that, because my approach did not turn out the way I wanted it to.
The short version is that my use of ElectronJS to build a fully cross-platform front end did not go quite as smoothly as I’d hoped. It went fairly well on macOS and Windows 10, albeit with performance that wasn’t quite what I wanted. But when it came time to build it on Linux, I hit a brick wall: No matter what I tried, I could not get the native Rust NodeJS module and the native Electron NodeJS modules to rebuild cleanly.
See, there’s a problem when you use native NodeJS modules in ElectronJS: You have to make sure that both ElectronJS and the native modules have been built with exactly the same version of NodeJS. ElectronJS has some tools to help with this, but they were extremely flakey for me. There is a morass of complexity involving NPM, native compilers, and NodeJS. I spent a few days on it, but eventually I gave up in frustration.
I was upset about not having a functeional emulator on Linux, so I dove in and decided to learn some GTK+. If I couldn’t have an Electron app, I’d damn well build native front-ends myself, thank you very much.
The result turned out very well. It’s
a fully native GTK+ app that takes a few arguments on the command line and
has good performance. It’s written in C, and builds the dmd_core
from a
git submodule.
After this success, I wanted to see if I could do the same thing on macOS. I could have just used the same GTK+ code on Mac, but the performance of the Cocoa GTK+ bindings is somewhat poor compared to native frameworks like Metal and CoreAnimation that offload work to the GPU, so I built a native Cocoa app written in Swift instead. It went so well, in fact, that I’ve distributed it in the Mac App Store [Edit: For a number of reasons, this is no longer available as of late 2021. Maybe I’ll write about why at a later date.]
A brief aside rant: Apple, you need help. Your developer documentation is terrible. It took far longer for me to build the Cocoa app than it should have. All the way, I had to fight documentation that is embarrassingly sparse at best. Very few documents mention how to use an API or framework. Those that do are in the “Documentation Archive” and haven’t been updated in years. Some of those come with a deprecation warning. Most of the currently maintained docs offer nothing more than a function signature with no further discussion. I relied almost entirely on third-party tutorials and examples to help me understand how to use the Apple frameworks. Shameful. Please, do better!
My next task is going to be a native Windows front end. I’m sure it’ll be an adventure, just like the Mac version, but at least I’m learning some useful skills here.
Comments