I'm not a Rust zealot but even I recognize that this blog post (which is about the difficulty about writing generic library code wrt lifetimes + Rust async) is pretty much a meme now that's thrown around without any sort of context.
Can you explain how this blog post relates to the difficulty of using Rust for writing a window manager?
I think posts like these are why I haven’t even looked at rust as an alternative.
Here the author has boiled the problem down to its minimal form, and it’s still 10s of lines of code.
It is this weird overlap of over-verbosity a-la c++ and extreme succinctness a-la Perl. You have to spell everything out and every bit of punctuation matters.
> Worm is a tiny, dynamic, tag-based window manager written in the Nim language. It supports both a floating mode and master-stack tiling with gaps and struts.
What do dynamic, tag-based, floating mode, master-stack tiling, gaps, and struts mean here?
dynamic = automatic layout as opposed to manual like in i3
tag-based = instead of separate workspaces, you have tags, which let you do things like have the same window stored in multiple spots, so you can have a firefox + terminal tag and then switch to a firefox + video player tag without really moving the firefox window, like dwm/awesomewm, but again unlike i3
floating mode = you can make a window appear over others and be moved around freely in addition to the default state of tiling windows
master-stack = a popular dynamic layout where you have a big main window and other smaller windows beside it, and you can cycle them to change which gets the big space
gaps = empty space between windows, mostly for aesthetic purpose (there is a whole i3 fork called i3-gaps just to add this)
I am not sure about "struts". Maybe has to do with leaving an empty space somewhere. I know stumpwm allows that, and I can't think of what it's called.
Not sure about struts but here's what the rest mean.
Dynamic tiling: When a new window is created, the window manager automatically decides where to place the window based on it's rule. This is usually contrasted with manual tiling where the user usually has to decide where a window should go before creating it. In this case, the ruleset Work uses appears to be master-stack based tiling. Which leads to that.
Master-Stack Tiling: A layout where once window is considered the master window, taking about about half the screen. And the rest of the windows stack up on top of each other on one side.
Floating mode: A lot of tiling window managers also allow you to designate a window as floating like a traditional desktop environment such as Gnome where every windows is floating by default and can be dragged around into any position. This is useful for certain applications, for example I like to have my media player be floating. Also I set up a certain terminal type to be floating so I can quickly popup or dropdown a terminal to run a quick command in it before dismissing the terminal.
Gaps: Tiling window managers traditionally take up the entire screen. For example, with only one window it will be fullscreened. With 2 windows, they will be tiled side by side with no space in between, etc. Gaps means that the window manager allows spacing in between these tiled windows (and often between a window and the edge of the screen as well). This can allow bits of your wallpaper to peek through. Some people find this more aesthetic.
Tag-based: Some window managers just call their implementation of traditional virtual desktops (workspaces), tags. They make no differentiation. However more accurately, a tag is a label that is put on a window. Most implementations allow a window to have multiple tags put on it. That's the most generic definition of tags. Usually window managers use these tags to allow for interesting virtual desktop workflows. One way this can be useful is if a window has tags 1, 4, and 5. Then if you were to switch to workspace 1, 4 or 5, that window would show up. More advanced implementations would allow you to adjust how that window looks per tag. For example in workspace 1, that window might be fullscreen, but it 4 it's tiled on the left and it 5 it's floating on the bottom half. There are other implementations of the tag concept but it gets complicated fast.
Hope that helps. This is just my general understanding of these concepts. I have no idea how Worm defines or implements them.
Good to see more ambitious Nim projects. I find Nim easy to prototype, cycle through a lot of revisions before finding the "ideal" way to express a solution. All an all it's an elegant language, which I hope gains more traction.
I have been using Nim for everything lately. If I have a problem I would typically write a shell script for, I'll use Nim with nimcr. If the problem expands beyond a single file, I'm in a good spot to create a project and have production-ready solutions.
The interoperability with other languages makes it a safe choice if I find I need to integrate into an existing project. I'm never coding myself into a corner.
I've never used a language as versatile as Nim. It's my secret weapon at work. I want more people to use it, but I do like my advantage...
it is _just_ dwm for wayland, though, so it's not what most people would call "feature-rich". it's suckless, so "features" are just "patches passed around the community" and "configuration" is "modify config.h and re-build". it can't really be packaged for re-distribution in any useful way.
i use a few other pure-wayland components as well to make it more like a full desktop environment rather than just a window manager.
Slightly off-topic but by "can't really be packaged for re-distribution in any useful way" did you mean binary packages? Because there are build systems/package managers that let you easily build a package with minor tweaks.
you're right, i did mean as a binary. and yes, for example arch users can install it from the aur with e.g. paru/yay, inserting their own changes to the pkgbuild. it's also in the freebsd ports tree (under x11-wm, even though it's wayland-only).
It also seems like the author originally wrote it in Rust and then switched to Nim. If they are around, would love to understand the motivation.