The Rockstar Programming Language

It is AWESOME!

I mean check out the FizzBuzz example:

Midnight takes your heart and your soul
While your heart is as high as your soul
Put your heart without your soul into your heart

Give back your heart

Desire is a lovestruck ladykiller
My world is nothing
Fire is ice
Hate is water
Until my world is Desire,
Build my world up
If Midnight taking my world, Fire is nothing and Midnight taking my world, Hate is nothing
Shout "FizzBuzz!"
Take it to the top

If Midnight taking my world, Fire is nothing
Shout "Fizz!"
Take it to the top

If Midnight taking my world, Hate is nothing
Say "Buzz!"
Take it to the top

Whisper my world

Here’s that code run through a Rockstar to Python transpiler:

def Midnight(your_heart, your_soul):
    while your_heart >= your_soul:
    your_heart = your_heart - your_soul
    return your_heart

Desire = 100
my_world = False
Fire = 3
Hate = 5
while not my_world == Desire:
    my_world += 1
    if Midnight(my_world, Fire) == False and Midnight(my_world, Hate) == False:
        print("FizzBuzz!")
        continue
    if Midnight(my_world, Fire) == False:
        print("Fizz!")
        continue
    if Midnight(my_world, Hate) == False:
        print("Buzz!")
        continue
print(my_world)

That’s not bad! Of course, changing the problem definition from “FizzBuzz” to “Fuck you” is waaaay more rock n’ roll (and funny).

Interestingly, the “minimal Rockstar” version (i.e., using only basic features and programming oriented variable names) isn’t terrible:

Modulus takes Number and Divisor
While Number is as high as Divisor
Put Number minus Divisor into Number
(blank line ending While block)
Give back Number
(blank line ending function declaration)
Limit is 100
Counter is 0
Fizz is 3
Buzz is 5
Until Counter is Limit
Build Counter up
If Modulus taking Counter, Fizz is 0 and Modulus taking Counter, Buzz is 0
Say "FizzBuzz!"
Continue
(blank line ending 'If' Block)
If Modulus taking Counter and Fizz is 0
Say "Fizz!"
Continue
(blank line ending 'If' Block)
If Modulus taking Counter and Buzz is 0
Say "Buzz!"
Continue
(blank line ending 'If' Block)
Say Counter
(EOL ending Until block)

Indeed, it’s basically verbose Python.

My favourite part is the “poetic” syntax for number literals. This is where the magic happens:

A poetic number literal begins with a variable name, followed by the keyword is, or the aliases was or were. As long as the next symbol is not a reserved keyword, the rest of the line is treated as a decimal number in which the values of consecutive digits are given by the lengths of the subsequent barewords, up until the end of the line. To allow the digit zero, and to compensate for a lack of suitably rock’n’roll 1- and 2-letter words, word lengths are parsed modulo 10. A period (.) character denotes a decimal place. Other than the first period, any non-alphabetical characters are ignored.

That’s crazy! Consider the first example: Tommy was a lovestruck ladykiller. Tommy is the variable, was is an alias for the assignment operator. The rest of the line is a numeric literal. a has length 1, so it represents the digit 1. lovestruck and ladykiller each have length 10, so given that 10 mod 10 is 0 each represent a 0. Thus the whole line assigns 100 to Tommy.

Love it!

It’d be interesting to design a folk variant.

Advertisements

One thought on “The Rockstar Programming Language

  1. Pingback: Rockstar Rainfall Problem | Mitigated Frenzy

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