←back to thread

296 points reverseCh | 1 comments | | HN request time: 0.216s | 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. bazzargh ◴[] No.41924070[source]
https://hachyderm.io/@bazzargh/111891925700326448

writing code for the bbc microbot has always been a fun challenge - you have to fit your code inside a toot (formerly a tweet) tho it does have some tricks to help you compress the tokens a bit. Sometimes you'd just use the basic geometrical figures available in bbc basic to put together a picture, like the man in this version of the Vertigo poster: https://bbcmic.ro/?t=7uzei or everything but the letters in this Two Tone label: https://bbcmic.ro/?t=6UNhz

... but even when that gets to need a bit of trickery to fit in enough geometry, like this one, "This is Fine" https://bbcmic.ro/?t=6XGKK it's not that interesting to just have a table of shapes. What I like to do is try to fit 2 or more less obvious ideas into the code as well as the drawing, so with the "This is Fine" piece it's the little bit of maths that makes the piecewise circular curves smooth, in the Vertigo poster it's producing the curve in the same way Saul Bass did (with a pendulum), or the multiple letter sizes and xor plotting in the Two Tone label.

The Dragon in the first link tho seems improbaly complex because there's not a lot of code and none of it is table-driven. The core idea is that repetition makes a good subject for compact code to generate art; the dragon may look complex but the scales repeat so the body is just many identical segments and both the head and body have axial symmetry. The snakelike body needed to be curvy, but if it curves too sharply the segments would be split on one side and crushed on the other. I'd done some code previously working on Dubins Paths (https://en.wikipedia.org/wiki/Dubins_path) and realised that'd be a good fit - just use a single curvature and flip between curving left and right. I found a good set of random numbers to generate a body with that just by experimentation. The scales I knew the effect I was going for and tried both sine waves and circles in various combinations till I found one that looked scaly; then I just needed to repeat it.

The head proved difficult; I'd tried other things like the fractal I used for the wave in this Hokusai recreation https://bbcmic.ro/?t=aAh0m the "Christmas Tree" fractal used to make this Rudolf https://bbcmic.ro/?t=6TR6f and other things, but none were really working or took too much code. What I landed on was just using sin/cos to vary the radius around a circle, which made a spiky head shape, then wobblying the angle plotted at to make it less uniform. The nose and eyes were just selectively not plotting some pixels, and that accidentally created the glowing rays from the eyes and the wrinkles; serendipity is great.