Plwm – An X11 window manager written in Prolog
76 comments
·May 25, 2025raron
davidcox143
This is one of the best resources for “real” Prolog:
https://www.metalevel.at/prolog
His YouTube videos are also incredibly good.
ioma8
I have to concur. Markus Triska is best Prolog resource out there nowaday. Extremely well explained, using modern notations etc.
sidkshatriya
I'll second that. Incredibly good quality videos. The precision of the narration is simply amazing. Even if you don't intend to practice Prolog in your programming life, it's worth a listen.
raron
Thanks.
anal_reactor
[flagged]
i80and
I'm curious how you figure a language whose central verbs and nouns are logic "isn't math".
arnsholt
Many people, when they say math, mean continuous math.
At work, my colleagues are almost entirely statisticians and actuaries, and I sometimes joke that my only math course at university was Calculus 1. I have of course done lots more math, but it’s all CS type stuff like logic and discrete structures like graphs and trees which is a very different world from continuous stuff.
actionfromafar
But it sort of is maths.
eikenberry
I'm hoping one day someone will write a window-manager service for Wayland that replaces the compositor API with a protocol. To once again enable window managers to be implemented in any language, regardless of it having a Wayland/compositor library.
mackeye
have a look at river, theyre currently working on something like this!
lugu
eikenberry
Great news! I'd seen river before (already had it bookmarked) but was unaware (or forgot) that it planned a feature like this. As long as they don't make it to tiling specific, which doesn't look likely given the wording of the Features section, it should be almost exactly what I want. Thanks!
pyinstallwoes
I wish more things were protocols instead of APIs.
linux2647
Could you explain the difference?
fnordpiglet
A protocol defines a set of primitives and their interactions, along with prescriptions where necessary, but is otherwise pretty loose generally. Especially in a Postels law world. APIs tend to be highly prescriptive with a highly specific interface and a lot of black box.
Think of the difference between an IETF RFC on say SMTP vs an email API - the RFC describes how clients and servers for mail routing interact through an almost dialog, while a typical email API has highly structured interfaces. Another wat to cut it is an API can be tested as it has inputs and return values dependent on those, while a protocol you can generally only assert compliance with the specification of the protocol.
People often assert protocols have something to so with RPC of some sort but that’s not true. Many language support protocols, which can be very similar to interfaces, but don’t have anything to do with OOP, etc. In language protocols it’s slightly different than network/IPC protocols but the intent is similar.
spicybright
I'm not the most knowledgeable, but a protocol talks to another process through a specific format.
I personally think its more powerful than writing a new process to replace and existing.
My favorite example is an X11 windows manager implementing in about 18 lines of python.
Obviously there's dependencies to talk to the X server, but the power of a protocol comes from any program written in any la gage communicate with existing code.
packetlost
They're both poorly defined, but what I think GP meant is they want something that you use something like a socket instead of FFI to interface with. You need an extra data description layer for a 'protocol' in this context because you can't rely on something like the C data model and calling convention as a given.
rewgs
A couple ways to look at it:
- Protocols are descriptive, APIs are prescriptive
- Protocols are implemented, APIs implement
neuroelectron
A protocol is like the line at Subway where an api is a bar & restaurant.
PeakKS
What? Wayland is a protocol. Not an API.
quotemstr
The OP wants to decouple the compositor from the window manager and have them talk over a protocol. Totally doable, but not with the current Wayland protocol or (AFAIK) any proposed extension. (Although I guess the shell protocol has the start of something like this?)
eikenberry
I mean a higher level, window-manager specific protocol. Skipping all the lower level controls.
major505
I don't know what amazes me more. The fact that someone used prolog to write a window manager, or the fact somone uses prolog at all.
DaiPlusPlus
> or the fact somone uses prolog at all.
I'll point your attention to 6 years ago: https://news.ycombinator.com/item?id=19279088
Another fun Prolog fact: Between 1996 and 2000, a Prolog program was distributed to tens of millions of users as part of Windows NT 4: https://web.archive.org/web/20040603192757/research.microsof... (via https://news.ycombinator.com/item?id=29528921 )
So do people use Prolog today? Given it's demonstrable that people use NT4 today, even if only for frivolous nostalgia trips or just an appreciation of _retro_-computing because if we can enjoy a mid-1990s abstract geometric screensaver today then it's no different to appreciating a 1960s Lava Lamp if you lived in the 1990s (presumably sat on the same desk and computer you're trying to install NT4 on).
major505
prett cool to know that. Guest is something you need to be in the middle to really know about. Like cobol.
leephillips
Very nice. If you’re used to dwm this should be natural. Unless you use dwm’s tags as more than workspaces, which I do. The author does not, so he implemented workspaces instead of tags. So this can not replace dwm for me.
ninjin
Tags are indeed a wonderful idea once it clicks, but I have to admit it took me about a year to get somewhat comfortable with how to work with them.
B1FF_PSUVM
Why am I reminded of the all-Erlang HN first page?
pona-a
Fun fact: the first version of Erlang interpreter was written in Prolog.
smikhanov
Looked at the source, it’s so compact, wow.
Y-bar
Not just compact, but it also has lots of clearly written comments, love to see it!
echelon
It looks nothing like the Prolog I've seen before.
I'm quite amazed the author took a declarative language meant for logic and turned it on its head for managing windows as an actual application.
Bravo!
YeGoblynQueenne
Oh wow, I gotta try this.
Lots of documentation! Awesome!
5-
this looks very impressive. forgive me a stupid question as a prolog outsider:
is this actually using any logical prolog features, or mostly just the 'functional' subset of prolog?
on a cursory look almost all annotated predicates are either 'det' or 'semidet', and none seem to have ? argument modes, so on the surface it looks like this is mostly straight functional code.
am i missing something important?
to be sure, prolog has much to recommend it even as a non-logic functional language: great syntax with probably the most flexible grammar out of all non-research languages (e.g. prolog's operator definition facility makes the ilk of haskell's seem like a toy), homoiconicity, etc.
but at least my expectation is perhaps for prolog code to make use more of the logical facilities.
null
mbrock
I actually started hacking on a Prolog X11 WM last year, got distracted by other things but what I started with was a module to define BSP-style partitions using rational constraints, so you would be able e.g. to easily cycle between valid pane layouts.
Jerry2
Are there any WMs that are implemented in JS and CSS? Or at least allow you to use JS/CSS? I’d love to be able to use web technologies to manage and decorate windows.
bolangi
Aside from the choice of language, I will be interested in what window managers are similar, or an inspiration for plwm.
jimmaswell
I installed all the libs and compiled this on Gentoo, but all I'm getting is a mouse cursor on a black screen.
johnisgood
That is literally most tiling window managers. Check the keybindings. Start a terminal or something.
jimmaswell
I did read all the keybindings (as well as the entire README.md) hoping to find a "launch" or similar command but there was nothing relevant. "Increase number of master windows" was most promising but nothing happened. The only command that responded was super+shift+q to quit. Nothing abnormal going on in the Xorg or plwm logs.
ayrtondesozzla
You've never used ratpoison, I see
rabiescow
Some of you hold on to X11 harder than Gollum and his ring...
Does someone know a tutorial or something which explains how to get from "tutorial Prolog" to "real project Prolog", because that's not look anything like tutorial Prolog.
Prolog seems interesting, but any time I tried to do anything more than toy examples on my own, I got infinite recursion, unsolvable problems.