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.
> a Space Invaders game
> a minimal roguelike in Forth
> 3-D rotating objects in ASCII art in 20 lines of Python
> an RPN calculator with forward-mode automatic differentiation
Those all sound pretty cool. Are those in the link you provided? I'd be interested in seeing how you did the 3-D rotations in only 20 lines, or what a minimal roguelike in Forth would look like.
Thanks! Two of them are there! Or, sort of, three of them.
The Space Invaders game is http://canonical.org/~kragen/sw/dev3/qvaders.html, built on the game engine in http://canonical.org/~kragen/sw/dev3/qj2d.js. An earlier version without the engine, the explosions, or the Xbox support is at http://canonical.org/~kragen/sw/dev3/invaders.html.
The minimal roguelike is http://canonical.org/~kragen/sw/dev3/wmaze.fs. It runs in a few different Forths (GForth is probably the easiest) but I haven't ported it to F83 yet. There's an asciicast at https://asciinema.org/a/672405. I'm kind of a novice at Forth, so I might not be doing things in the best way.
The ASCII-art rotating cube is http://canonical.org/~kragen/sw/netbook-misc-devel/rotcube.p.... It's actually only 15 lines of Python. A longer wireframe Unicode braille version is at http://canonical.org/~kragen/sw/dev3/braillecube.py with an asciicast at https://asciinema.org/a/390271. There's also a 41-line C++ ASCII-art version at http://canonical.org/~kragen/sw/dev3/rotcube.cpp and a 42-line semi-wireframe C version using my graphics library Yeso at https://gitlab.com/kragen/bubbleos/-/blob/master/yeso/cube.c.
The RPN calculator is at http://canonical.org/~kragen/sw/81hacks/autodiffgraph/.
Thanks! I upvoted you but forgot to reply. Those are as interesting as I thought they'd be.
Awesome, I'm glad you liked them!
I probably should have said in my original comment that the 3-D rotation itself was only 3 of the 15 lines:
The rest was ASCII art, animation, perspective projection, and geometry generation.> which accidentally did turn out to be useful
I hate when I'm having fun and accidentally make something useful :)
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 :-)
Just as a note, also to myself ;), the CAD stuff seems to be hosted in laser000.ps. Nice demonstration what PostScript is capable of!
Oh, that's mostly in http://canonical.org/~kragen/sw/laserboot/.