Literate programming in Ruby

12 juillet 2026

In 2012, I was handled a small programming challenge. I decided to solve it in Ruby, using literate programming.

The challenge

This small programming challenge was proposed by a defunct SSII company (original source):

Challenge #3 – Apps wall

In our offices, we display a mosaic of the most downloaded apps from the App Store on a screen. To prevent the TV’s pixels from burning out, it’s important to shuffle the icons regularly. Could you write a program that takes a list of apps as input and outputs that same list, randomly shuffled, while ensuring that every app has changed places?

Each application would be represented by an integer, both as input and output:

echo "1,3,2,5,4" | ./murApplis => "3,1,4,5,2"

Literate programming

Literate programming is definitely not new – but I was curious to experiment with this format, and explore the tooling available for writing literate programs in Ruby. Beside that, I felt the challenge required an explanation of why the very short code actually answered the requirements, and literate programming felt like a good fit for this.

I found Rocco, a port of Docco for Ruby programs. It worked well, and produced a nicely styled HTML output. Moreover, 14 years later, the output is still perfectly good, without having to edit or recompile anything. Yay for static HTML pages!

The result

Last week I found this code again, and decided to host it online.

More interesting than the repository or the code is the literate programming output: a nice web page, explaining:

It reads like a blog article, and I quite like it.

Read the literate programming solution here

In the end, even if the tooling seems deprecated, I would definitely like to revisit this approach to programming in the future.

Kudos

Discussion, liens, et tweets

J’écris des sites web, des logiciels, des applications mobiles. Vous me trouverez essentiellement sur ce blog, mais aussi sur Mastodon, parmi les Codeur·euses en Liberté, ou en haut d’une colline du nord-est de Paris.