But first: Context.
After some discussion, I decided that it might be nice to allow comments on Gwene. However, if people make public comments, there should be a way to display these comments to the public at large. “Here. I’ve made these comments about your crappy blog. See how wrong you were.” So Gwene would have to have a web interface.
I though extremely briefly about using the Gmane interface. However, it uses rather a lot of resources, and I didn’t want to use it for something as frivolous as this.
Besides, it would mean rewriting bits of it, since it would be Wrong for Gwene to show the entire contents of the RSS feeds. Doing so might mean that Gwene would (possibly) take away some traffic from the original sites. Besides: Legal stuff.
So I decided to write a new interface. Besides, I needed something to do while not being away on holiday for a few days.
I wrote a C program called warp that takes an inn overview file, parses the thread information, and outputs a (binary) index file suitable for parsing and squirting out onto the web. The main point of this program is to enable the web interface to do a O(1) lookup onto the index file on (SSD) disk, read a chunk of data, and output all the thread roots for the group.
I then wrote another C program called woof that takes a list of articles (stored in the binary index file created by warp) and outputs HTML of the article contents. The original RSS entries are shortened drastically (to 100 characters), while the comments originated on Gwene are presented in full.
The fun bits.
All fun and games, so far, but the thought of writing the server bits in PHP just made me gnash my teeth. There’s nothing much wrong with PHP, but it’s simply the most boring programming language ever. There’s absolutely nothing fun about it. Just a boring soup of mis-named functions.
So I looked into the most hyped of all hyped yesterday’s technologies: Node.js.
I looked at an example static server, copied the code to the local disk, pointed Node at it, and specified http://localhost:8080/../../../../../../../etc/passwd as the URL, and was promptly served my password file in the browser.
It just works!
After writing some functions to parse the binary index file by warp, I then had a complete working interface to the spool. It took me just a few hours to implement the Node bits. The async callback style for something as simple as this just had four levels or so.
People complain about the awfulness of programming with callbacks in Node.js. I think these people are, to use a technical term, retards. I can’t back that up with hard evidence, but I think it’s pretty self-evident.
In addition, I get a feeling of accomplishment when doing something — anything — in these languages. Implement a bank in Common Lisp? Eh. Whatevs. Parse a NOV line in C? Whoho! It doesn’t crash! Yes!
Writing a simple service in Node feels like programming, while doing the same in PHP feels like script drudgery. I’m not quite sure why that is, but there’s just something intrinsically boring about PHP that sucks all joy out of using it.
They’ve been trained to use one single crappy language, like Java or C#, and then they come into contact with The Other, and every way The Other differs from The One True Language I’ve Trained In is Evil.
So, to them, declaring local variables to avoid making them global is just moronic. No matter that that’s how it works in plenty of other languages they aren’t familiar with. Having several equality operators is just iNsAnE, despite all sensible languages having the same concerns (== is kinda like equal while === is very much like eq). And closures are just so incomprehensible. Boo hoo. And on and on and on.