Plwm – An X11 window manager written in Prolog

137 jedeusus 30 5/25/2025, 5:41:11 PM github.com ↗

Comments (30)

raron · 2h ago
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.

anal_reactor · 2h ago
I played with Prolog just a little long time ago, and I can't shake off the feeling that Prolog is basically a prank that went too far to be stopped. It requires a way of thinking that is compatible with neither how computers work, nor how maths works.
actionfromafar · 1h ago
But it sort of is maths.
eikenberry · 3h ago
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.
pyinstallwoes · 3h ago
I wish more things were protocols instead of APIs.
linux2647 · 2h ago
Could you explain the difference?
fnordpiglet · 19m ago
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 · 2h ago
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 · 1h ago
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.
neuroelectron · 1h ago
A protocol is like the line at Subway where an api is a bar & restaurant.
PeakKS · 1h ago
What? Wayland is a protocol. Not an API.
quotemstr · 22m ago
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?)
smikhanov · 2h ago
Looked at the source, it’s so compact, wow.
echelon · 2h ago
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!

summarity · 6m ago
Window management and constraints in general are a perfect fit for logic programming.
B1FF_PSUVM · 5h ago
Why am I reminded of the all-Erlang HN first page?
pona-a · 5h ago
Fun fact: the first version of Erlang interpreter was written in Prolog.
YeGoblynQueenne · 5h ago
Oh wow, I gotta try this.

Lots of documentation! Awesome!

gatane · 4h ago
Time to do one in Scheme, I guess.
pona-a · 4h ago
mhd · 4h ago
Done a while ago: https://en.wikipedia.org/wiki/Scwm

There was also "GWM", based on its own lisp dialect, "WOOL", which was around from at least the early 90s.

On the more popular side, you had sawfish (using an elisp-alike, IIRC) and stumpwm (Common Lisp).

igorhvr · 2h ago
This one is customizable in Lisp, and overall pretty neat: https://sawfish.tuxfamily.org/ - I have been happily using it daily for many years now. :-)
tmtvl · 4h ago
Already exists: https://github.com/mwitmer/guile-wm

There might also be ones in other Schemes, but as FFI hasn't been standardised across Schemes yet I doubt there's an implementation-agnostic one.

DonHopkins · 4h ago
Here's an X11 window manager, with pie menus and tabbed windows, entirely written in object oriented NeWS PostScript, from around 1991:

https://donhopkins.com/home/archive/NeWS/owm.ps.txt

And some design notes and emails on that NeWS based window manager for X11 windows:

https://donhopkins.com/home/archive/NeWS/i39l.txt

It incorporated NeWS tabbed windows written in PostScript, which could wrap around X11 windows (and frame NeWS windows too of course):

https://donhopkins.com/home/archive/NeWS/win/tab.ps

And NeWS pie menus written in PostScript, which you could pop up on tabbed window frames and manage X11 windows (and use in NeWS apps too of course):

https://donhopkins.com/home/archive/NeWS/win/pie.ps

There was also a virtual large scrolling desktop, and virtual multi-screen "rooms", both purely written in PostScript, which all plugged together with the tabbed windows and pie menus and X window manager seamlessly. They were all independent of each other and could be used separately, but worked together synergistically. Take that, ICCCM! ;)

Also here's a (pre-ICCCM, pre-X11) X10 window manager with pie menus, written in C and scripted in Forth, from around 1986:

https://donhopkins.com/home/archive/piemenu/uwm/fuwm-main.f

And some of my thoughts on X-Windows and ICCCM window management in general:

https://donhopkins.medium.com/the-x-windows-disaster-128d398...

>In summary, ICCCM is a technological disaster: a toxic waste dump of broken protocols, backward compatibility nightmares, complex nonsolutions to obsolete nonproblems, a twisted mass of scabs and scar tissue intended to cover up the moral and intellectual depravity of the industry’s standard naked emperor.

>Using these toolkits is like trying to make a bookshelf out of mashed potatoes." -Jamie Zawinski

agumonkey · 2h ago
First time I ever get the chance to see object postcript/forth, thank you
leephillips · 6h ago
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.
rclkrtrzckr · 4h ago
Isn't ".pl" actually used for perl?

Well, there might be a Prolog interpreter written in (a) perl (regex) ...

ajdude · 4h ago
Prolog was using .pl for a bit over a decade before Perl existed.
tikhonj · 3h ago
It's used for both which consistently confuses logic that guess programming language purely based on file extensions.
jimjimjim · 4h ago
Prolog is a older than Perl and there doesn't need to be any exclusive claim on file extensions.