This post will go over some thoughts that I've been mulling over about choosing the right tools for my own personal linux desktop desires.
Lately, I've been diving deeper into userspace of the OS stack. Mostly involving making my own command line utilities and desktop apps. With the ultimate goal of making my own Desktop Environment. Surprisingly, this involves making a lot of choices about tooling, libraries, and even distros. After a bit of research, I started testing some of my previous notions to see if they still stood. The one change that I have made is in the preferred programming language which I will get to.
I will break this up into 3 sections: distro, app toolkit, and programming language.
The most significant change in the Desktop Environment space is the transition to Wayland from X11. If you are going to make a DE in this day and age, you have to target Wayland, or else you are wasting your time. X11 is fun for toys, but if you want something that will stand the time for at least the next couple of decades then Wayland is the way to go.
That being said, a pure Wayland desktop experience doesn't really exist except for sway, or maybe Gnome. In order to run most apps you still have to use xwayland because the apps themselves depend on X11. If you use app toolkits like Gtk or Qt these details can be abstracted away. Where this matters the most is with the window manager. The reason XFCE will never be on Wayland is because of xfcewm. The xfcewm is literally the most core component of XFCE with most of the settings config being related to it. Sway is basically just a window manager, and there is a library called wlroots that helps you build a Wayland compatible window manager. This is still early, but I expect people to make a variety of window managers with this.
To truly make your own desktop environment you have to make your own window manager. Anything else is just a utility that doesn't necessarily depend on the specific desktop environment. If you want to make your window manger, you should do it for Wayland. Which finally brings up the point about which distribution to develop on. This is because some distros support Wayland and wlroots better than others.
Currently, my personal use distro is Debian stable. I like it because it is FOSS, has a great history, and it just works. However, the creator of sway uses Alpine, so I thought maybe there is some logic to that. Perhaps, the Alpine ecosystem would support Wayland better. With my experiences of trying to install sway, I can assure you this is not the case. The sway Debian package actually booted up in QEMU for me. The other more important thing is that wlroots already has a package in Debian, even if it is in experimental.
People who use Alpine are digital equivalent of mountain folk if you ask me. The one thing that is nice is the use of musl over glib. I hope to see that used in Debian one day. For now, I will continue to be directing my knowledge and effort towards Debian.
When looking into making your own desktop app for Linux you are faced with a few options. You can go hardcore opengl graphics or you can use an app toolkit. The options are Gtk and Qt. My concerns with these libraries go beyond the tech. What kind of license do they have, what kind of organization runs it, what is the community like?
I chose Gtk originally because I like the GNOME foundation as an idea, and I liked XFCE which used Gtk. However, I was curious if Qt was a better option. It seems that Qt is actually more complicated than Gtk. Gtk is also more focused on Linux as opposed to cross platform which is fine with me. People also complained that Qt apps can be a bit bloated. None of this was enough for me to want to make a change. I will be continuing to put my effort into the gtk toolkit.
Sidenote: Based on my readings it seems that the direction of the gtk library is very much based on the GNOME DE. People have complained about breaking API changes, and not feeling like they have a say in the library. Which sort of supports other evidence to suggest that GNOME just cares about GNOME. I'm not super unhappy about this, but I can see why it might upset people.
The next thing you have to decide when building a desktop app, is what language do you want to write it in? Gtk is written in C, so it is a natural fit. C is awesome, and it is great for systems, but it stops being fun after a couple of hours. I'm looking for something that I don't mind hacking with in my free time and actually following through with my ideas. Rust is currently entering the fray, and has a lot of enthusiasm from the GNOME community. My original intentions have been to use Rust to build out my desktop apps. That was the idea until I actually tried to build some gtk apps with Rust.
The thing with Rust is it has a really strict compiler and it makes doing mutable state programming quite difficult. In order to just get a button to click in Rust requires the use of a macro to control strong and weak pointers. The fact that I have to grok this, just to get a button to click was a real turn off for me. The whole point of not using C is so it wasn't complicated, but Rust makes it complicated. Rust is complicated, there are 10 million ways to do the same thing. This lead to a real crisis for me. My whole plan was to support Rust gtk so more people might be willing to contribute. But if the easy stuff is hard, then this whole plan goes down the drain.
Then I found Crystal. On Hacker News I ran across an entire OS implementation in mostly Crystal (some C). This blew my mind. Then after reading about Crystal more, it blew my mind again. Crystal really feels like you can have your cake and eat it too. It has seamless interop with C, it is performant, and can be compiled into an easy to install binary. And the syntax looks like Ruby but with types. After making a few apps in Crystal I have become a big fan. There is even a usable gtk binding in Crystal already. I can make a simple desktop app and I don't have to worry about strong/weak references. I can just click a button and make a thing happen.
In principle, I think the Rust approach is better. Rust pushes you to write code the correct way. The relm project is a step in this direction. I built an app with it, however, I found myself doing state bashing and it doesn't support Glade yet...
So yeah, I've made my decision to build my apps in Crystal using Gtk and to make sure that it can be Wayland compliant.
Content for this site is CC-BY-SA.