Compiling a Rock Ballad that Compiles

Okay that last post was a bit of a heavy topic, right? Goodness me! Too stressful, too stressful, I’m telling you – I got nothing done ALL WEEK from terror after posting that! XD

You’ll be glad to know I’m back on cheerier stuff – you may or may not have heard of the Rockstar programming language. Until a few weeks ago, I had not. For one Saturday afternoon, it became my entire life. xD

So what is Rockstar?

It’s an esoteric (weird) programming language that reads like rock ballads!! Whaaat! It basically lets you write a rock song, and so long as you follow the rules, it should compile and run as code. On a scale of 10 to 10, how great is that?! (about a 9.8)

The Goal, The Dream, The Deepest Desire of My Heart

So when I set out to learn a new language or framework I like to find a little goal to work towards – “I want to use X to do Y”. For example when I made the pick-me-up quotinator in Python, or way back in the day when I made a dice roller in JavaScript. It was just something nice and simple and easy. Rockstar is not a language I want to get super into since I doubt it’ll ever be particularly useful, so I set myself a small goal. I decided to write a song asking what the meaning of life is, while returning the value 42.

But first, in case you want to have a crack at your own, I’ve laid out the simplest rules of Rockstar below. Feel free to skip to the song though! (There is no sound cloud of me singing it, but I did perform it in front of 20 people in standup and the general consensus was that I should never perform it ever again, for the good of Mankind.)

There is an official doc here, but tbh I found it difficult to get through as someone who doesn’t have much experience using different languages. This is Bruce’s Super Simplified Guide.


The Basics of Rockin Out

Variables

To assign a variable, you use the keyword “is” (or “were”/“are”/”was”). For example:

Bruce is the best
> Bruce = 34

“Wait what? 34?! Why does Bruce equal 34?” do I hear you ask?

Well, after the keyword “is” I added two words – the first being three letters long, the second being four letters long. Hence three four, 34. To get a 0, you need to use a ten letter word. Eleven-letter words go back to 1 et cetera.

Bruce is super duper awesome yo
> Bruce = 5572

Pears are satisfactory
> Pears = 2

Another rule you should be aware of is that variable names can have “the”/“your”/“my” in front of them, but if you do that then it’s not the same variable when you use it without that word!

Id est, you could have two variables – “pears” and “your pears” – which are not the same at all. In addition, you can make a variable have multiple words for its name so long as they’re all capitalised – like Undeveloped Bruce.

If you’d rather have a string than a number, then you can declare a string variable like this:

Bruce says “hey friend!”
> Bruce = “hey friend!”

Or you can make them null or undefined or booleans, arrays and all sorts – check out the docs for full info. It’s a Turing-complete language, which basically means it can do lots of data manipulation things (anything a Turing Machine can do, hence the name)((I think)).

Oh, and something I truly love is that if you want to change a variable after setting it, or your lyrics don’t look cool and you need an extra line in, you can use a whole range of pronouns to refer to the last variable you used (it, he, she, him, her, they, them, ze, hir, zie, zir, xe, xem, ve, and ver). Omfg look at those pronouns! So many to choose from, I love it. For example:

Bruce is great
> Bruce = 5
Ze is super duper great
> Bruce = 555

Manipulation

Okay so after knowing how to assign variables, you need to know how to manipulate them! There’s a bunch of ways of doing this, and they’re listed fully in the doc but I’m keeping it simple since it’s unlikely you actually wanna learn Rockstar to do anything complicated, if at all. This is enough to write a lil ol’ ditty, which I totally recommend you try. Please excuse my terrible examples though.

Addition uses the keywords plus or with:

Size is not a detractor from beauty
> Size = 31946
An aesthetic is determined from many factors
> AnAesthetic = 0447
But Jimmy is an aesthetic plus size
> ButJimmy = AnAesthetic + Size

Subtraction uses the keywords minus or without:

Excellent is the way I dream
> Excellent = 3315
A doubt is lying beneath unseen
> ADoubt = 576
You There are excellent without a doubt
> YouThere = Excellent – ADoubt

Multiplication uses the keywords times or of:

Her knowledge was incomplete
> HerKnowledge = 30
Patience was to her inconcrete
> Patience = 230
Unnecessary was her knowledge of patience
> Unnecessary = HerKnowledge * Patience

and Division uses the keyword over:

Love is something something
> Love = 99
Despair is something else entirely
> Despair = 948
My choice is love over despair
> MyChoice = Love / Despair

To increment or decrement a value, you just knock it down or build it up! Examples:

Brucey B Goode was a legendary goose
> BruceyBGoode = 195
Knock Brucey B Goode down
> BruceyBGoode = BruceyBGooode – 1
Build Brucey B Goode up, up, up
> BruceyBGoode = BruceyBGoode + 1 + 1 + 1

If statements and blocks

A block of code is not defined by brackets or anything, but by spaces. A code block ends when a new verse starts, essentially.

(What I mean by code block is for example, when you write an if statement in Javascript, you have brackets:

if(this thing is true) {then totally do this}

The code block ends with the closing curly brace, so that not everything you write afterwards forever only happens when the if condition is true.)

In Rockstar, an empty line does the same thing.

Comparisons

So to check if a statement is true or not, you have to be able to compare things. Maybe you wanna know if your courage is greater than your fear, or if the butterfly inside is stronger than the tiger of your enemy. Basically is X > Y?

To check if value A is greater than value B:

If the fire is greater/higher/bigger/stronger than your pants
> if(theFire > yourPants)
Do all the things until you encounter a blank line

To check if value A is less than value B:

If the ram is weaker/smaller/less/lower than the door
> if(theRam < theDoor)

To check if value A is greater than or equal to value B:

If the beat is as high/great/strong/big as the bar
> if(theBeat >= theBar)

To check if value A is less than or equal to value B:

If foxes are as low/small/weak/little as stoats
> if(foxes <= stoats)

Or to straight-up check that two values are the same:

If crisps are great
> if(crisps == great)

There are also concepts of true/false and truthy/falsy and tbh I have never delved into it so who even knows!

(Smart people know, that’s who.)((And me, if only I worked a little harder.))

Returning a value!

Right right, so you can write some maths and make variables change about, but how do you make the song actually return something?

Pants are dreams with cloth legs
Shout pants
> 6454


Drawing of me writing a song

Writing the song

Alright that’s enough of that. There’s loops and more complicated bits n bobs but I didn’t want to make the post too long (ahahahaha, Bruce you are so funny…) so let’s check out what I went through on one weekend to write this song!

I realised very quickly that with typical lengths of lines in song lyrics, the variables were going to be initialised (created for the first time) as four or five digit numbers. Which was going to make the background maths so much more annoying to get down to exactly 42 in the end.

Another thing I found early on was that it’s way too easy to make twenty variables while trying to get lyrics that make sense, most of which would never be used. Therefore I set myself the rule that I could only have one unused variable. Ideally 0, but for a quick little bit of fun I wasn’t gunna be too strict. XD

My first draft was just a meaningless few lines, minimum viable product:

Life is pie
The Meaning is a tart
Shout the meaning of life
> 42

Those lyrics don’t make sense, but they do show the basic way I decided I was going to get the Meaning of Life – because “the meaning of life” is “the meaning” multiplied by “life”.

All I needed to do was create two variables by those names, then moosh them around a bit until they had values that would multiply together to make 42. EZ PZ, I thought – except that, as I already mentioned, it’s difficult to make a variable that isn’t five digits long… And now I needed two variables that were one or two digits long.

And because I clearly hate myself, I wanted to make a song with two verses as well as a chorus, and for the lines to have a vague rhythm for speakability/singability… Aaaaaand also for the chorus to rhyme/near-rhyme. Because why not, it’s not like it’s already difficult to work this stuff out without having to make sure a line rhymes with something else while also consisting of words of a specific length in a specific order…

Here is my next draft, which was slightly more fleshed out:

Life is like a shooting star
It’s over before you know it
The blight is neverending, but
Your love is gunna set you free, Oh

If your love is greater than the blight
That’s what gives the star its light
If your love is greater than the blight
Shout “This is the meaning of life:”

The blight is blind who you love absolutely
Let the meaning be your love without the blight
life is el evenletters

If your love is greater than the blight
Shout The Meaning of Life

> This is the meaning of life:
> 42

I was vaguely happy with the first verse, even though it doesn’t rhyme. The chorus was also really pleasing because I could repeat it, once with speech marks to return a string, and another time to return the value 42. I really struggled with combining the simple mathematics and simple lyric-writing, especially when it came down to getting The Meaning and Life to have small values. Hence “Life is el evenletters”.

It is definitely not easy finding words that made sense in the song, rhyme, have the correct beat, and still come down to the right numbers in the end.

I did get there though!!

Final draft:

Life is like a shooting star
It’s over before you know it
The blight is neverending, but
Your love is gunna set you free, Oh

If your love is greater than the blight
That’s what gives the star its light
If your love is greater than the blight
Shout “This is the meaning of life”

Life is so double-edged
The blight’s where you can find yourselves
That’s not reason to
Knock life down
Let the meaning be your love without the blight

If your love is greater than the blight
That’s what gives the star its light
If your love is greater than the blight
Shout The Meaning of Life

Screenshot of the output saying
"This is the meaning of life
42
Program completed in 162ms"
Screenshot of the output of the code

So most of the song is just fluff, more lines of code are useless than useful, and I didn’t use anything more complicated that if statements. Regardless, it was a pretty good result for the amount of time spent on it. I was not up for spending a really long time riddling the ins and outs of the language, then designing a more convoluted and impressive way of getting the number 42, then attempting to write that into a singable song.

If you don’t wanna go through it and work it out for yourselves, the meaning of the song is written out here, in no particular language syntax:

Life = 4184
Life = 46342
TheBlight = 13
YourLove = 53342

If (YourLove > TheBlight) {
That = 453435} // < unused variable alert!!
If (YourLove > TheBlight) {
Return(“This is the meaning of life:”}

Life = 21 // (double-edged is all one word, hehe)
TheBlight = 53340
That = 362
TheMeaning = YourLove – TheBlight // TheMeaning = 53342 – 53340 = 2

If(YourLove > TheBlight){
That = 453435}
If(YourLove > TheBlight){
Return(TheMeaning * Life) // Return(2 * 21)

That’s it for this post.

ROCK ON!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.