Rockstar Introduction

by "Blag" - Senior Developer Evangelist

Return to Geeky Thursday

What is Rockstar?


Dynamically typed Turin-Complete programming language.


Source code of programs are also rock lyrics.


Built using JavaScript and Pegjs.


How to install Rockstar?


On Linux, the easy way is to do this


Download Rocky.jar


And then download and execute this install.sh


The are wrappers for Mac and Windows.

We can call it like this

rockstar name_of_file.rock


Rockstar has a REPL...


rockstar repl


And a debugger... rockstar debug name_of_file.rock

Who uses Rockstar?


Well...I don't think Rockstar has hit the mainstream yet...


But it has a nice fan base of developers using it


We'll see how it evolves...


Basic Concepts


Printing on the screen is easy...

We have one way to make comments...

				
shout "This is Rockstar"


whisper "This is Rockstar"



(This is a Rockstar comment)
				

Variables


This can be weird...but interesting...

				
The sun was hot 

("The sun" is the variable, and "hot" is the value)


Shout the sun


( 3 )



Davey was a fine man 

("Davey" is the variable, and "a fine man" 

is the value)


Shout Davey


( 143 )

				

User input


To get user input...we need to listen to it...

				
Whisper "What's your name?"

Listen to your heart

Shout your heart
				

Arrays are easy...although not exactly what we would expect


				
Let the clock at 0 be 1

Let the clock at 1 be 2

Let the clock at 2 be 3


Shout the clock at 1


( 2 )
				

Looping


We have only one way to loop


				
Let the clock at 0 be 1

Let the clock at 1 be 2

Let the clock at 2 be 3


The time was 0

While the time is weaker than 3 (weaker = less than)

Shout the clock at the time

Build the time up (add 1 to the time)

(space to end the while)


( 1 )

( 2 )

( 3 )
				

Functions


Functions always return a value...


				
Sum takes first and second

Put first with second into third (Could be "plus")

give back third



Shout Sum taking 5, 4


( 9 )
				

The "Stack"


We have a stack that works like this


FIFO (First In, First Out)


				
Rock the casbah with 1

Rock the casbah with 2

Rock the casbah with 3


Shout Roll the casbah

( 1 )

Shout Roll the casbah

( 2 )
				

Fibonacci List


Finally...we're going to make our first application...


So grab your favorite text editor and get ready...


Name your file "fibonacci.rock"


				
Fibo takes the stone and water and dirt

If water is nothing

Put water plus dirt into mud

Rock the mountain with water, dirt, mud

Knock the stone down

Give back fibo taking the stone mud dirt

(empty space to end the function)
				
				
If water is stronger than nothing and 

the stone is stronger than 1

Put water plus dirt into mud

Rock the mountain with mud

Knock the stone down

Give back fibo taking the stone mud water

Else

Unite the mountain into the rock with " "

Give back the rock

(empty space to end the IF-ELSE)
				
				
say "Enter a number: "

Listen to the stone

Say Fibo taking the stone, 0, 1
				

Open the Terminal and go to your source code folder...

rockstar "Name_of_File.rock"


When we run it we're going to see...


Making an LED Number App


This is one of my favorite codes of all time...


Name your file "LED_Numbers.rock"


				
Let the led at 0 be " _  ,| | ,|_| "

Let the led at 1 be "  ,| ,| "

Let the led at 2 be " _  , _| ,|_  "

Let the led at 3 be "_  ,_| ,_| "

Let the led at 4 be "    ,|_| ,  | "

Let the led at 5 be " _  ,|_  , _| "

Let the led at 6 be " _  ,|_  ,|_| "

Let the led at 7 be "_   , |  , |  "

Let the led at 8 be " _  ,|_| ,|_| "

Let the led at 9 be " _  ,|_| , _| "				
				
				
Night takes Moon and Sky

Put Sky into Big Sky

While Big Sky is less than Moon

Put Big Sky times 2 into Big Sky

(empty space to end while)
    


While Big Sky is as high as Sky

If Moon is as high as Big Sky

Put Moon minus Big Sky into Moon

(empty space to end while)



Put Big Sky over 2 into Big Sky
    

Give back Moon

(empty space to end function)
				
				
say "Enter a number: "

Listen to the sound

The moon was a complexity

The sun was 0

The sunset was 1

The zero was 0

The one was 1

The two was 2

While the sound is higher than nothing

Put Night taking the sound, the moon into the stars

Put the sound over the moon into the sound

Turn down the sound

Let the rock at the sunset be the stars

Build the sunset up

(empty space to end the while)
				
				
Put the sunset without 1 into rocker

While rocker is higher than nothing

Put the rock at rocker into the line

Put the led at the line into the stone

Cut the stone into pebbles with ","

Let the first at the sun be pebbles at the zero

Let the second at the sun be pebbles at the one

Let the third at the sun be pebbles at the two

Knock rocker down

Build the sun up

(empty space to end the while)
				
				
Unite the first into uno with " "

Unite the second into dos with " "

Unite the third into tres with " "

Shout uno

Shout dos

Shout tres
				

When we run it we're going to see...


Random Names


This App will generate 100,000 random names using two 16 elements arrays


We will measure the runtime


Name your file "Random_Names.rock"


Rockstar doesn't have Random Numbers, so I'm using pseudo ones...


				
Let the first at 0 be "Anne"

Let the first at 1 be "Gigi"

Let the first at 2 be "Blag"

Let the first at 3 be "Juergen"

Let the first at 4 be "Marek"

Let the first at 5 be "Ingo"

Let the first at 6 be "Lars"

Let the first at 7 be "Julia"

Let the first at 8 be "Danielle"

Let the first at 9 be "Rocky"

Let the first at 10 be "Julien"

Let the first at 11 be "Uwe"

Let the first at 12 be "Myles"

Let the first at 13 be "Mike"

Let the first at 14 be "Steven"

Let the first at 15 be "Fanny"
				
				
Let the last at 0 be "Hardy"

Let the last at 1 be "Read"

Let the last at 2 be "Tejada"

Let the last at 3 be "Schmerder"

Let the last at 4 be "Kowalkiewicz"

Let the last at 5 be "Sauerzapf"

Let the last at 6 be "Karg"

Let the last at 7 be "Satsuta"

Let the last at 8 be "Keene"

Let the last at 9 be "Ongkowidjojo"

Let the last at 10 be "Vayssiere"

Let the last at 11 be "Kylau"

Let the last at 12 be "Fenlon"

Let the last at 13 be "Flynn"

Let the last at 14 be "Taylor"

Let the last at 15 be "Tan"
			
				
Night takes Moon and Sky

Put Sky into Big Sky

While Big Sky is less than Moon

Put Big Sky times 2 into Big Sky

(space to finish the while)    

While Big Sky is as high as Sky

If Moon is as high as Big Sky

Put Moon minus Big Sky into Moon
    
(space to finish the if)

Put Big Sky over 2 into Big Sky

(space to finish the while) 

Give back Moon

(space to finish the function)
			
				
The sound was 0

The time was 0

The power was 0

The seed was 0

The answer was 0

The seedless was 0

The answerless was 0

The note is power heartbroken

The noteless is damn brokentime

While the power is weaker than 100

Put 0 into the time
			
				
While the time is weaker than 1000

Put Night taking the sound, the note into the seed

Put the seed of 7 into the seed

Knock the seed down

Put Night taking the seed, 15 into the answer

Put the answer plus 1 into the answer

Put Night taking the sound, the noteless into the seedless

Put the seedless of 7 into the seedless

Knock the seedless down

Put Night taking the seedless, 15 into the answerless

Put the answerless plus 1 into the answerless

Let the music at the sound be the first at the answer plus " " plus the last at the answerless

Build the time up

Build the sound up

(space to finish the while)
			
				
Build the power up

(space to finish the while)
			

When we run it we're going to see...

How this behaves in Python?

And what about Go?

Decimal to Romans


This App will create a Roman Numeral based on a decimal number


This will include some nice commands...


Name your file "Decimal_to_Roman.rock"


				
Let the roman at 0 be "M"

Let the roman at 1 be "CM"

Let the roman at 2 be "D"

Let the roman at 3 be "CD"

Let the roman at 4 be "C"

Let the roman at 5 be "XC"

Let the roman at 6 be "L"

Let the roman at 7 be "XL"

Let the roman at 8 be "X"

Let the roman at 9 be "IX"

Let the roman at 10 be "V"

Let the roman at 11 be "IV"

Let the roman at 12 be "I"
			
				
Let the keys at 0 be 1000

Let the keys at 1 be 900

Let the keys at 2 be 500

Let the keys at 3 be 400

Let the keys at 4 be 100

Let the keys at 5 be 90

Let the keys at 6 be 50

Let the keys at 7 be 40

Let the keys at 8 be 10

Let the keys at 9 be 9

Let the keys at 10 be 5

Let the keys at 11 be 4

Let the keys at 12 be 1
			
				
say "Enter a number: "

Listen to the sound

The key was a day

The funk was 0

While the sound is higher than nothing

The counter was 0

While the funk is weaker than the key

If the sound is as strong as the keys at the counter

Let the music at the funk be the roman at the counter

Put the sound without the keys at the counter into the sound

Build the funk up

Break it down

(Space to finish the while)
				
				
Build the counter up

(Space to finish the while)


Shout ""

Unite the music into the grace with ""

Shout the grace
				

When we run it we're going to see...


That's it for now


Rockstar is still new but full of surprises


It's fun to code and will give you a couple of headaches


It's worth learning for sure...


Go ahead and Rock & Roll!

Contact Information


Blag --> blag@blagarts.com

@Blag on Twitter

Go back home...