[HN Gopher] Ask HN: What's the most creative 'useless' program y...
       ___________________________________________________________________
        
       Ask HN: What's the most creative 'useless' program you've ever
       written?
        
       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!
        
       Author : reverseCh
       Score  : 43 points
       Date   : 2024-10-20 11:56 UTC (2 days ago)
        
       | nasmorn wrote:
       | A program making images in the style of Mondrian.
        
         | davidddavidson wrote:
         | Like Piet? https://esolangs.org/wiki/Piet
        
       | bitwize wrote:
       | A toy BASIC interpreter written in Guile Scheme.
        
       | krm01 wrote:
       | A fast paced startup founder simulator
       | (https://sillycovalley.com)
        
       | eloisius wrote:
       | About 10 or 11 years ago I wrote a bot that sat in our company
       | Campfire chat training a Markov chain for each person. Then you
       | could command it to imitate someone and it would spit out
       | hilarious madlibs. This would likely not be amusing anymore, but
       | back then it made people laugh.
        
         | franklin_p_dyer wrote:
         | This is so much fun. I did the same for a Discord server full
         | of philosophy nerds, and the bot would say all sorts of things
         | that started out profound-sounding and ended up absurd (one of
         | our favorites: "I think therefore I am not italian")
        
         | mysterydip wrote:
         | I did the same thing with a webchat I made for a bunch of my
         | friends (back before discord was a thing)! Lots of fun.
        
       | chubot wrote:
       | I learned in college Geometry class that you can transform a
       | square to an equilateral triangle in 11 cuts or so
       | 
       | So I wrote a matlab program to draw the shapes, and cut them out,
       | and it works
       | 
       | It's mathematically exact, not just approximate
       | 
       | Still surprises me after 20 years, so I want to find this old
       | program again lol
        
         | chubot wrote:
         | This got a downvote and I wonder if it's from a person who
         | doesn't think it's true
        
           | mike-the-mikado wrote:
           | Or perhaps from someone who doesn't think it's useless
        
           | Someone wrote:
           | It more likely s from a person whose fingers are much larger
           | than the distance between the up/downvote triangles on their
           | device (that's about everybody)
        
         | quuxplusone wrote:
         | The dissection of a square into an equilateral triangle (or
         | vice versa) is sometimes known as the haberdasher's problem,
         | and can be done in three straight-line cuts.
         | 
         | https://mathworld.wolfram.com/HaberdashersProblem.html
        
           | chubot wrote:
           | Hm interesting, I thought it was 11 pieces, not 11 cuts, but
           | that one looks like 4 pieces, which is surprising
           | 
           | Now I am more curious to find this program
           | 
           | Either I didn't do it optimally, or there is some variation
           | like a triangle/rectangle/square
           | 
           | I think there are some problems that have 3 shapes, or it
           | could be triangle/pentagon or something
        
       | abrudz wrote:
       | I wrote a program to launch and kill tight loop threads such that
       | Windows Task Manager's performance graph would spell out text
       | (though of course with spaces below lines in letters filled out).
        
       | fanf2 wrote:
       | A combinator reduction evaluator with a translator from lambda
       | calculus to combinators. The creative part was getting a C
       | compiler to parse combinator expressions with the traditional
       | syntax, where function application does not have an operator and
       | is left-associative, like S K K.
       | http://www.ioccc.org/years.html#1998_fanf
        
         | tromp wrote:
         | Winning an IOCCC contest is far from being useless though:-)
        
           | 0xf00ff00f wrote:
           | Hey, I've seen some of your IOCCC entries. Even had some fun
           | trying to understand them back in the day.
           | 
           | IOCCC gang rise up. This is mine:
           | https://www.ioccc.org/years.html#2005_persano
        
       | AlotOfReading wrote:
       | Many years ago I wrote a text editor in brainfuck. It wrote out
       | the file in memory as the user typed, and it'd shift its data
       | structures successively farther in memory to avoid overwriting
       | them as it went. A friend gave it one of the best compliments
       | I've ever received and called it beautiful after watching it
       | execute in a memory editor.
        
       | incanus77 wrote:
       | This is marginally useful, but I wrote a small 'subleq'
       | playground -- it's an instruction set with just one instruction,
       | "SUBtract and branch if Less-than or EQual to zero".
       | 
       | https://github.com/incanus/subleq
       | 
       | It was fun to see how simple a model of computation could
       | actually be.
        
       | bilater wrote:
       | Recently did a standup comedy app where an AI laughs at my jokes:
       | https://github.com/btahir/standup-comedy
        
       | neya wrote:
       | A decade and a half ago, I came across this beautiful bar in
       | Bahrain (online) that was visually appealing to the eye with
       | contrasty colors. I was so fascinated by it that I started
       | writing a simple algorithm to just extract out the dominant
       | colors in the image, just for fun, but mostly because I was so
       | lazy to open Photoshop and pick the colors out manually.
       | 
       | Turns out, this is actually a real challenging task for computers
       | - what the eyes perceive as dominant, computers do not and vice-
       | versa. For example, if you draw a small circle on a black board
       | with white chalk, take a picture of it and ask a computer, it
       | will tell you black is the dominant color because it covers most
       | of the pixels. Whereas, any human would tell you the white
       | drawing is the dominant color because it stands out.
       | 
       | There are some ways of guiding the computer to get the color
       | palette you want out of an image, but they are never as accurate.
       | Over the years, I would from time to time, throw a bunch of
       | images at it - ranging from portraits to beautiful flowers from
       | gardens to see how my algorithm would perform and improved it bit
       | by bit. I would say, it is close to 90% accuracy now and I still
       | work on it over the weekends. It has no use cases so far (for
       | me). It just exists as a pure passion project that got me excited
       | about programming such algorithms.
       | 
       | Recently, I did a Fashion degree just out of passion and I
       | realized this code has so much applications for things like
       | making mood boards and color palettes from inspiration boards.
       | However, none of my professors nor fellow students were impressed
       | or saw utility in it because they believed no algorithm can match
       | or replace a true creative process. They are pretty old-school
       | about this, so, there's that. But, they just didn't seem to
       | understand the technical challenge about this seemingly simple
       | task.
       | 
       | However, over the years, I did build an API around this
       | algorithm, kept fine tuning it and even made some marketing
       | material for it. For no purpose other than reminding myself of
       | why I am excited about programming.
       | 
       | If you're interested, here is a decade old snapshot of the
       | algorithm's output:
       | 
       | https://ibb.co/SvYLLG3
       | 
       | https://ibb.co/tHKf9T8
        
         | bittwiddle wrote:
         | Hey this is pretty cool! Have you thought about putting it
         | online? I've occasionally used tools like Adobe's color scheme
         | finder, where you upload an image and it suggests a fitting
         | colorscheme derived from the photo. Though honestly theirs
         | doesn't perform too well.
         | 
         | Yours looks like a nice improvement.
        
       | tromp wrote:
       | I recently managed to fit Loader's number, which is about the
       | largest finite number ever conceived of that's still computable
       | by a small program, into a mere 233 bytes of code. No practical
       | use except as an entry in golfing contests [1].
       | 
       | [1] https://codegolf.stackexchange.com/questions/176966/golf-
       | a-n...
        
       | pizzafeelsright wrote:
       | Short URL generator with emoji as characters.
       | 
       | Communicating via paste would work but speaking or typing was
       | near impossible.
        
       | xamuel wrote:
       | My Library of Ordinal Notation Systems shows a way you can
       | systematically write more and more complex code, with no end---
       | even if you had access to strong AGIs, they could never "finish"
       | the exercise. https://github.com/semitrivial/IONs
        
       | simonsarris wrote:
       | I like inserting art, like the header to https://simonsarris.com
       | 
       | A village pops up. There is no point to it. You can click to make
       | more houses. You can right-click to drag things around. When I
       | touch it again I think I'll add a sun and moon that track the
       | time of day for wherever the user is located. Actually the footer
       | has art too, each page has a semi-randomly assigned illustration
       | from public-domain (old) art that I've found. Like drawings from
       | James McNeill Whistler, for instance. I use his illustrations in
       | 'useful' websites too.
       | 
       | Actually, I experimented with the sun/moon a few years ago, in
       | this version: https://simonsarris.github.io/simeville/
       | 
       | If you left-click drag the sun downwards, you'll see the moon
       | come up. That one is open source, but the code is quite slapdash
       | compared to the new one. Also you have to click ITS TIME TO BUILD
       | to get the buildings.
       | 
       | In general I think websites could be a lot more pretty (gorgeous
       | even), silly, interesting, and a lot less _corporate chic_ than
       | they currently are.
        
         | sshine wrote:
         | I like having this kind of animation on my homepage, too.
         | 
         | Currently I just have an animated GIF background, but I've had
         | some animated ASCII art in the past.
         | 
         | I'm currently working on animating a fractal drawn with HTML
         | Canvas.
         | 
         | Your houses and pencil style are very cute, I feel inspired to
         | make something similar.
         | 
         | I'd like if clicking in the same place would grow whatever's
         | there.
        
         | laksmanv wrote:
         | I have to agree, I really miss the 90's when websites had more
         | of a fun artistic creative and personality feel than templated.
         | I see the use for both, but I miss it :)
        
       | thibaut_barrere wrote:
       | For me it is for instance my involvement in the demo-scene in the
       | 90's.
       | 
       | A concrete example is Nikki, a demo released in 96 and captured
       | (with some technical difficulties) by a friend here
       | https://youtu.be/t8o-uuq73UU?si=4dlTla0s2mDCVzCK
       | 
       | Working on anything "useless" is profoundly life changing and
       | "useful" on the long run!
       | 
       | Only now am I able to do more similar stuff (my current research
       | is around music + code + lightning and videos, this time
       | connected to real life performances), and it is massively
       | pleasurable (and also likely one of the most technical types of
       | work I will be working on for now!)
        
       | adityaathalye wrote:
       | "The Matrix" raining characters, but really bad, and in Bash (:
       | 
       | https://www.evalapply.org/posts/bad-matrix/
        
       | kragen wrote:
       | 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 s-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 mKanren 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.
        
         | mysterydip wrote:
         | > which accidentally did turn out to be useful
         | 
         | I hate when I'm having fun and accidentally make something
         | useful :)
        
           | kragen wrote:
           | 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 :-)
        
       | lep wrote:
       | I have written a lua interpreter in JASS (the language used for
       | WarCraft 3 maps). It's useless because at that point WC3 gained
       | native lua support.
        
       | Fethbita wrote:
       | I made a small C program that would use GMP to generate a prime
       | number from a bmp image. I was inspired by a Youtube video but I
       | can't remember what it was anymore.
       | 
       | https://github.com/Fethbita/BMP_to_Prime
        
       | neilwilson wrote:
       | Solving the Dining Philosophers problem using systemd
       | 
       | It gave me the chance to play with some old unix concepts in an
       | nspawn container.
       | 
       | https://github.com/brightbox/systemd-dining
       | 
       | As well as incorporating the Philosopher's Song and some profound
       | statements into the journal.
        
       | rhyperior wrote:
       | Twofer
       | 
       | I wrote a flame simulation in x86 assembly language. Total hoot.
       | 
       | I also wrote an Easter egg that shipped in a major software
       | company's software and is immortally burned onto thousands of
       | DVDs slowly rotting in landfills. This one was fun and
       | challenging because I had to mask the names of the product team
       | from easy detection, I had to convert string text to my own
       | custom 8x3 pixel font for rendering, I played with palette
       | animation to create some fun raining effects, and I packed it
       | into just a few Kb of the DOS end of a Windows executable (back
       | in the day, 16-bit Windows apps could be linked with a custom DOS
       | loader in case you tried to run the Windows app from the cmd
       | line).
        
         | mysterydip wrote:
         | What kind of trigger did it have? some kind of key sequence or
         | certain day of the year?
        
           | rhyperior wrote:
           | You passed a phrase on the command line. Honestly I made it
           | all too hard to find, but Easter eggs were a bit dangerous
           | for one's career :)
        
       | hu3 wrote:
       | Writing programs that play games for me.
       | 
       | I enjoy that more than playing the games.
        
         | yen223 wrote:
         | Peter Norvig's post on solving sudoku puzzles helped kickstart
         | my love for programming
         | 
         | https://norvig.com/sudoku.html
        
       | lormayna wrote:
       | Around 10 years, in Italy a very populistic party was raising and
       | he was leaded by a very stupid leader that used the social a lot.
       | Then I wrote a Twitter bot (it was possible at that time) that
       | looked like a militant of the party and that was trained over the
       | leader's tweets (nothing fancy, just a big Markov chain). It was
       | so funny when people, also high level of the party start liking
       | and retweeting the bot posts, I ended having several thousands of
       | followers just writing bullshits.
       | 
       | I would like to learn how GAN are working, then I scraped the
       | official pictures of Italian politicians since 30 years and try
       | to generate new faces with a GAN trained to this dataset.
       | Unfortunately I need a lot of computing power to obtain an
       | acceptable face, and I did not want to spend money for that.
       | 
       | Several years ago I wrote a Tinder bot to collect spam messages
       | and malicious links. I stopped early because I got messages from
       | several of people that I know personally in a relationship or
       | even married
        
       | horsellama wrote:
       | getting on top100 on https://code.golf/
        
       | zahlman wrote:
       | 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.
        
       | yen223 wrote:
       | One of my earliest web projects was a Lorem Ipsum text generator
       | that pulled text from the /r/nocontext subreddit
        
       | johnea wrote:
       | I didn't write them, but I <3 xsnow and xeyes !!!
       | 
       | Totally useless and very fun!
        
         | hyperjeff wrote:
         | although on multi-monitor setups, xeyes helps me quickly find
         | my pointer location, if i've lost track, in an enjoyable way.
         | almost anything can be useful to someone.
        
       | candleknight wrote:
       | I have a repository where I make classic programs (game of life,
       | sudoku solver, brainfuck interpreter, etc) but entirely within
       | Typescript's type system
       | 
       | https://github.com/ruyili/cursed-typescript/
        
       | deburca wrote:
       | When working for a bank we had daily jobs where we had to input
       | the date of the previous working day manually. This led to some
       | human errors.
       | 
       | I wrote code that automatically calculated the previous working
       | date - including those floating dates around Easter.
       | 
       | I generated calendars for future years to compare to know
       | calendars to prove no discrepancies.
       | 
       | My code worked. My management did not understand how it worked or
       | how it could work.
       | 
       | We continued using manual input.
        
       | jonathanknight wrote:
       | Way back in the 1990s when you could write directly to screen
       | memory in Windows I wrote an Excel macro that made an animated
       | dog run all over the screen -useless but fun.
        
       | mikewarot wrote:
       | I wrote a clone of TECO[1] (Text Editor and COrrector) for MS-DOS
       | back in the 1980s.
       | 
       | Teco was something the CS upper classmen were using to prove
       | their hacker creds back at Rose-Hulman in 1981. It's a horrible
       | editor, but it does macros, and was good enough to build the
       | first version of EMACS.
       | 
       | [1] https://github.com/mikewarot/teco
        
       | rishikeshs wrote:
       | I was learning how to work with Cloudflare Workers and
       | implemented something called a Pixel Mosaic:
       | https://rishikeshs.com/mosaic/.
       | 
       | It's a live pixel mosaic where anyone can change the color, with
       | the color being chosen randomly, so the chances of two adjacent
       | tiles having the same color are quite low. I also log the country
       | to see where people who have clicked it are from.
       | 
       | I am currently working on a desktop 8x8 LED grid to sync the same
       | pattern on my desk.
        
       | skei wrote:
       | During my postdoc, I wrote some code running parameter
       | optimisation on a large dynamical system. It wasn't clever code,
       | it was closer to a grid search than anything else. I spun it up
       | across 200 cores of the local supercomputer, I waited 72 hours...
       | and then nothing. I had forgotten to write the results to disk.
        
       | rapjr9 wrote:
       | I used to write very short programs for the Amiga that would scan
       | through all the pixels on the screen and assign a color to them
       | based on whatever math functions I felt like writing. They took
       | hours, sometimes days to run, but the results were often
       | interesting, sometimes radial gradients, sometimes random noise,
       | sometimes things that looked like musical notes on a random
       | background. Then I'd load a color table and color cycle the
       | resulting image. Sometimes this created movement in the image,
       | sometimes it animated the noise so it looked like old-fashioned
       | TV static. Just did it for fun, only took a few minutes to write
       | the code, and sometimes the results were great. It was often very
       | difficult to predict what the final image would look like, unless
       | I started with a program I'd run before.
        
       ___________________________________________________________________
       (page generated 2024-10-22 23:00 UTC)