←back to thread

41 points reverseCh | 3 comments | | HN request time: 0.684s | 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. kragen ◴[] No.41896766[source]
Given that this site is called "Hacker News", it's worth mentioning that '"useless" programs - pieces of code that serve no practical purpose but are fun, creative, or challenging to write' is one of the central definitions of ”hack”.

I've written some: a programming language interpreter based on Abadi and Cardelli's untyped ς-calculus; a two-kilobyte web server in assembly (which accidentally did turn out to be useful); a self-compiling compiler from a sort of Forth dialect to i386 ELF executables; a translator from standard English orthography to an ASCII alphanumeric phonetic orthography I designed; a one-kilobyte programming language interpreter with dynamic multimethod dispatch and pattern-matching; a base-3 calendar based on the Sierpinski triangle; a C interpreter in Python I used for bytebeat livecoding; several implementations of Tetris, one of which is a 2K ARM executable; an operating system for ARM consisting of five instructions; a few raytracers; a Space Invaders game; a minimal roguelike in Forth; a library for manipulating Boolean functions as Zhegalkin polynomials; many symbolic differentiators; a sort of polyrhythmic drum machine called Pygmusic; a parametric CAD system in PostScript for laser-cutting MDF; 3-D rotating objects in ASCII art in 20 lines of Python; Karplus-Strong string synthesis in one line of C; an audio PLL in one line of C; an RPN calculator with forward-mode automatic differentiation; a slide rule in Tcl/Tk; a port of the logic-programming EDSL μKanren to OCaml; several fractal renderers; a decoder for the "gridfonts" Hofstadter and his research group designed; a Hershey font decoder; several maze generators; a generator for balanced-nonary multiplication tables; a vocoder; a Doom-like first-person raycaster; a teapot mod for the Minetest game; a compiler for a subset of Scheme written in itself; etc.

A lot of this is in http://canonical.org/~kragen/sw/dev3/ which you can clone with Git. I'd be happy to elaborate on any of these if you are interested.

replies(1): >>41897564 #
2. mysterydip ◴[] No.41897564[source]
> which accidentally did turn out to be useful

I hate when I'm having fun and accidentally make something useful :)

replies(1): >>41897719 #
3. kragen ◴[] No.41897719[source]
It was more that I thought the approach I was taking would doom it to being uselessly slow, but it turns out Linux is actually pretty fast at forking, especially when your process's entire memory map is 20K :-)