←back to thread

41 points reverseCh | 1 comments | | HN request time: 0.232s | source

I recently came across the concept of "useless" programs - pieces of code that serve no practical purpose but are fun, creative, or challenging to write. These could be anything from elaborate ASCII art generators to programs that solve imaginary problems. I'm curious to hear about the most interesting or creative "useless" programs the HN community has written. What was your motivation? What unexpected challenges did you face? Did you learn anything valuable from the experience? Some examples to get the ball rolling: 1. A program that prints the lyrics of "99 Bottles of Beer" in binary. A text-based game where you play as a semicolon trying to find its way to the end of a line of code. A script that translates English text into Shakespearean insults. Share your creations, no matter how quirky or impractical. Let's celebrate the joy of coding for coding's sake!
1. zahlman ◴[] No.41898051[source]
I guess the projects that stand out in my memory haven't been so much "useless" as just really niche. Also, while I've dabbled in a lot of esolangs, I don't really have a history of deliberately choosing the wrong tool for the job.

Back somewhere in the 1990s, I made a simple scrolling demo of a "platformer game level" in HyperCard. I didn't even bother designing a level or implementing any game mechanics - I just filled the level with random "tiles". The interesting part is that the tiles actually came from a custom bitmap font that I created with ResEdit (https://en.wikipedia.org/wiki/ResEdit) and manually added to the resource fork of the HyperCard stack. See, filling a text field and scrolling the entire field was the only way I found to get acceptable performance on 1st-gen Macs - certainly it was impossible by using a grid of button icons (even with screen locking), for example. The trick stopped working in System 7 and I never found out why but I was sad about it. I still have a text file that I've migrated from computer to computer, from 1999, with some notes about a purported way to display oversized "icons" on buttons using a PICT resource. I don't recall ever trying it.

In 2002, I developed some tools for working with DDR step chart edits, in Perl. Some online friends had hardware that allowed for transferring data between a computer and an PS2(?) memory card (which could also be used in an arcade cabinet), which they'd been using to share their edits; they were also involved in... some kind of precursor to Stepmania, which was using its own MML-like (https://en.wikipedia.org/wiki/Music_Macro_Language) format for step charts. I made a converter from that format to the "official" one, and an SVG renderer. I was also working on something that would attempt to give charts an "objective" difficulty rating programmatically, but I think I got too far lost in deciding the heuristics it should use. (I did have a working model of how the player's feet would be positioned while playing through the chart.)

In 2005, I implemented a "choose your own adventure" book engine - twice: in C++ and Python, for comparison purposes. The input was just an alternating sequence of blocks of prose for a "page" and directives for options the user could choose; the engine would parse this, present a menu after each page of book text, and go to the next page as appropriate. An empty menu section denoted the end of the story.

In 2007, I wrote a Python script that opens and parses an indexed PNG file at the byte level (no libraries), and modifies the palette (the version I found appears to just increase brightness a bit, but I remember having a version that applied a sort of pastel effect using varying amounts of desaturation and gamma correction).

In 2010, I implemented a non-recursive Towers of Hanoi solution.

In 2014, on Stack Overflow (https://stackoverflow.com/questions/21297887/), I did a simple radix sort implementation in Python specifically for Burrows-Wheeler transforms - rather than actually creating the rotated byte-string inputs, it just sorts according to the hypothetical rotated versions (i.e., according to the element value at certain indices, modulo the length of the elements). That wouldn't be particularly noteworthy or practical (it's just not a problem you'd expect people to ask about on Stack Overflow very often - although I did just now find one unclosed duplicate from 2018 and cleaned it up ;) - and would probably have been better asked on softwareengineering.stackexchange.com), but it did happen to get the attention of a certain Tim Peters.

In 2016, I did a bunch of work on optimized text compression for retro video games. My target corpus was about 1MB of text, but split into thousands of short strings (varying from a few bytes to a few kilobytes) - and the game needs to be able to extract arbitrary strings on demand, individually and efficiently. I developed a system that would develop a rather complex tokenization scheme (with tokens varying from a short prefix or suffix, to several words in length) based on a variety of heuristics, then store the tokens as an optimized overlapping string pool and use a custom optimized Huffman tree representation to index the pool. Oh, and the pool itself is also Huffman-compressed again, this time with simple one-byte symbols.

In 2022, I had the shower thought that any divide-and-conquer algorithm can be reimagined as a graph traversal problem, where the function calls are nodes in the graph; and I made... this thing: https://github.com/zahlman/larch. If you can figure out how to do anything useful with it, congrats; I don't remember, myself.