DEV Community

Cover image for Programmatically output lyrics on a tee-shirt

Programmatically output lyrics on a tee-shirt

Corentin Girard
Self-taught and then in an engineering school, I love (too much) best pratices. mainLanguages == ["C#", "TS", "JS"]
Updated on ・1 min read

Some years ago I re-wrote the lyrics of a song as a JS script. I ordered a tee-shirt with this "art" of mine (I actually find it quite beautiful 😅).

But everytime someone looked at my tee-shirt, they would ask me if it really means or does something. I would answer "no, it doesn't work, it's just a representation".

My tee-shirt with source code art

But now, I've implemented it!

I chose C++ to be able to overload operators exactly as I wanted... My goal was to not change anything about this source code, which I designed without knowing I would implement it.

So in the main.cpp file, all I have is the following:

#include "logic.cpp"

int main()
     * Guess the song... 😌 😎

    imagine(!heaven) == "easy";
    us.below = !hell;
    us.above = sky;
    imagineAll("living for today");

    imagine(!countries) != "hard";
    (kill || die).reasons.length == 0;
    religion = undefined;
    imagineAll("living life in peace");

    chorus(); //🎵🎶

    imagine(!possessions) ? "😀" : "😥";
    need(greed || hunger) == false;
    men.reduce([]() { return "brothers"; });
    imagineAll("sharing all the world");

    chorus(); //🎵🎶
Enter fullscreen mode Exit fullscreen mode

All the logic is included in another file.

As you can see, the only differences are the double quotes for the string literals and the syntax of the lambda expression. Apart from that, it's the exact same thing as my tee-shirt.

Here's the output of the program, without any hardcoding:


Here's the repo:

So, did you guess the song?

Discussion (0)