rockstarlang / rockstar Goto Github PK
View Code? Open in Web Editor NEWThe Rockstar programming language specification
Home Page: https://codewithrockstar.com/
License: MIT License
The Rockstar programming language specification
Home Page: https://codewithrockstar.com/
License: MIT License
The documentation is missing the specification that after Say or one of its aliases a literal is also valid. However, it's not clear if poetic numbers are allowed or if the rest of the line is parsed as a string. Requiring quotes at this would be useful for numeric output
According to the text If
has a Then
but the sample code doesn't.
So which is correct?
With any number of "e"s would be ideal.
Currently, increment, decrement and assignment are the only possible math operations. It might be somehow inconvenient that way to calculate roots. Especially if all the required functions have to be written in rockstar. This would be the lyrics for a day-long song...
Can we have this take STDIN and assign it to the variable me
?
The current example has
Give back your heart
{blank line}
{blank line}
Desire is a lovestruck ladykiller
It should be
Take your soul from your heart
{blank line}
Give back your heart
{blank line}
Desire is a lovestruck ladykiller
since it should return the the value after exiting the while
loop
I think we should make tommy
and gina
reserved keywords, in the spirit of Bon Jovi fans.
tommy
could denote a class, while gina
could denote an interface.
A lot of issues are math stuff, syntax proposals or example bugs, it would be great to organise them using the projects page...
hey now
Proper variables are proper nouns - any word that isn't a reserved keyword and starts with an uppercase letter. Proper variable names can contain spaces as long as each space is followed by an uppercase letter.
Put 'Hello World' into the message
will assign the value'Hello World'
to the variablethe message
.
as well as
My heart is true
- initialises the variablemy heart
with the Boolean valuetrue
and many others.
How is this valid?
"taking" doesn't sound so great for function calls.
Did you consider using "with"?
Just for fun, I've written an example using the with
syntax.
Looking Back takes Pain and All
Fear is Pain
Until Fear is nothing then
Knock Fears down
The Way is Looking Back with Fear and Pain
Until The Way is nothing then
Knock The Way down
Build All up
Give back All
That Guy is 22
All Of It is nothing
Looking Back with That Guy, All Of It
I think this is what I mean in python:
def LookingBack(Pain, All):
Fear = Pain
while Fear != 0:
Fear -= 1
TheWay = LookingBack(Fear, Pain)
while TheWay != 0:
TheWay -= 1
All += 1
return All
ThatGuy = 22
AllOfIt = 0
LookingBack(ThatGuy, AllOfIt)
I don't think there are else and else if keywords/blocks. This is indeed minimalistic, but it might be more practical to have them. Otherwise
could be an alias for else
(without if). I don't have a clue for a single keyword for else if
at the moment. In general, one word keywords are better maintainable. What if the parser expects a long keyword like take it to the top
and the code accidentally misses a letter? An error should be thrown instead of unexpected behaviour. This is clear, but during implementation, one might forget this at some point and this is not too easy to maintain, if you always have to check that again...
Just adding an idea to call threads, subroutines, etc as rounds
If single-quoted strings are allowed, words like isn't
and doesn't
become harder to parse. Even worse, wakin'
and 'bout
are impossible.
For Rockstar to become a semi-usable language there have to be imports, I would suggest using the taking X from Y in Z
for import syntax, where X
is a list of symbols to import separated by the and
keyword, or 'X' and from
are omitted and the symbols can be accessed via their file name and Y
and Z
are a relative path or an absolute path based on some pre-defined variable. We could then use them in multiple ways:
taking modulus and fiboacci from math in utils
and then modulus
and fibonacci
can be used as normal functionstaking math in utils
with this modulus from math
and fibonacci from math
can be used as functions.There probably should be a way to comment code, either to clarify blocks or allow better metric within the lyrics without compromising previously written code
The first use is meant for actual use of the language on real-world code, which isn't probably going to happen and so isn't as important
For the second use, maybe make the compiler ignore lines without any language keywords (I'm not sure if this is doable, don't know much about compilers).
love is gone
If the language specification is somehow stable, this could be published on esolangs.org from where interested developers might come from (at least those developers who are interested in languages like that)
That makes it possible to have something like this
My Life is nothing without you
Equivalent of
If not you then
My life is nothing
When the heart is strong
the love is on
if heart == 6:
love = 2
The specification declares:
My dreams were ice. A life unfulfilled; wakin' everybody up, taking booze and pills - initialises my dreams with the value 3.1415926535
it also declares
The single quote character in Rockstar is treated as a letter of the alphabet
by that measure, shouldn't the "dreams" value contain 3.1416926535 ?
A lot of languages add metaprogramming via macros to generate more code at compile-time. It might be useful to add something like this to the language to easily repeat a lot of similar code, but changing things inside it. I.e. change which variable something is assigned to after a wordy calculation.
It might also make more sense to add choruses instead as a simple anonymous function you can repeatedly call (until the next chorus is defined).
Hey guys do you have a roadmap for new GTA?
I love Rockstar <3
In the string literals section, a single quote is defined as being an a letter of the alphabet
The single quote character in Rockstar is treated as a letter of the alphabet. This seems unusual until you remember that
I ain't talkin' 'bout love
is a perfectly valid rock'n'roll sentence.
However, later on in the Poetic Number Literals examples, there is this example
My dreams were ice. A life unfulfilled; wakin' everybody up, taking booze and pills
- initialises my dreams with the value 3.1415926535
Which would suggest that the single quote in wakin'
is not counted as an alphabetical letter as the definition states
Other than the first period, any non-alphabetical characters are ignored.
If this is intended, then it may be worth clarifying this
In the example
Tommy was a dancer
While Tommy ain't nothing,
Knock down Tommy
And around we go
the usage/effect of around we go
is unclear. It could be an alias for continue. But it is definitely not needed because any line that doesn't start with And ends the block. For a parser this could be difficult if the file doesn't end with a newline, don't forget to clean up opened blocks or throw an error (unexpected EOF) if you write a parser
We could use wish
for assertions
I wish Your Love was true
It will throw/panic if Your love is not true
Some of the example loops have a comma at the end of them:
Tommy was a dancer
While Tommy ain't nothing,
Knock Tommy down
but others don't:
Tommy was a dancer
While Tommy ain't nothing
Shout it
Knock it down
Are these commas supposed to be here? If they are, do they do anything or are they just ignored?
I don't know how this can be applied, but please consider adding some syntax construction support that will allow to write next line of code:
Polly wants a cracker
How about the following syntax for negation?
turn {variable} upside down
flip {variable} over
What about a module / import syntax:
Setlist: Live at Waken 1998
Song: The Philosopher
.... ${RockStarCode}
Song: The Ace of Spades
.... ${RockStarCode}
from "Live at Waken 1998" import "The Ace of Spades"
Do we have any restrictions on file extension to indicate it is rockstar language? Like: .rock, .lyrics, .song or something else.
A composer
will take a Rockstar program, and generate a musical score.
This might be hard to do.
Are language elements is rockstar case sensitive. Some of the example suggest that keywords are case insensitive. Are proper nouns case insensitive except for there first letter? This should probably be clarified in the README.
The specification doesn't say whether "A" would be a proper variable name. It does start with an uppercase letter but that's all. It might be useful for short names like the i counter variable but I'm not sure if that fits with the aim of rockstar...
For if
blocks, Rockstar should support Meatloaf syntax:
I would do <function> for <condition>
But I won't do <another function>
This syntax would evaluate the <condition>
, and if it is true
, then call <function>
, else it will call <another function>
.
For example, you could declare two functions, anything
and that
, and a Boolean variable called love
, and the syntax would be
I would do anything for love
But I won't do that
For this to work, Rockstar would need to be able to call functions without parameters. Maybe a syntax where the function takes nothing
, for example:
Anything takes nothing and gives back truth
That takes nothing but gives back everything
Listen to your love
I would do anything for love
but I won't do that
This would listen on STDIN
, and set that value into the variable love
. Then it would evaluate love
, and if true call out to Anything
returning the value of the variable truth
, if false call out to that
and get back the value of the variable everything
.
I was thinking about various possible aliases for the increment and decrement. Reading through some random 80s rock lyrics I found a few possibilities.
Build {variable} up
Knock {variable} down
Many of them seemed to be able to be interchangeably used between increment and decrement.
So I propose that the syntax for increment and decrement be changed to.
Increment: [Ignored word] {variable} up
Decrement: [Ignored word] {variable} down
Perhaps default to "Move" or something else that is very generic and computer code like, as there are many possible variations on the word to use here.
Plans to support complex numbers?
Though it's not idiomatic to use Continue
, if one chooses to do so, it should be in the the proper style of the language.
Currently there is no documentation for an official way to comment out code despite you adding comments such as (blank line ending While block)
in the minimalist FizzBuzz example. I don't know if you intended those to be actual comments or just info for the reader in that specific example but I think comments are something that the language probably needs. If you don't want to use parenthesis for official comments may I suggest starting comments with the phrase By the way
or something else that's all words to continue the non-reliance on special characters.
Currently, Rockstar implements blocks as starting with If
, While
, Until
, or ... taking
and ending with a blank line. This requires multiple blank lines to end multiple blocks, and results in awkward-looking runs of whitespace.
Here's my 2¢ suggestion about how this could work instead:
If
, While
, Until
):
then
, let's
, i'll
, do
take it to the top
, end if/while/until
(additional keyword suggestions appreciated)
take it to the top
ends an If
inside a While
)Give back
ends the function. (Additional Give back
statements may be used in inner functions, but a function must always end with a return value.)Minimalist Rockstar example, full syntax:
Modulus takes Number and Divisor
While Number is as high as Divisor
Put Number minus Divisor into Number
Give back Number
Limit is 100
Counter is 0
Fizz is 3
Buzz is 5
Until Counter is Limit do
Build Counter up
If Modulus taking Counter, Fizz is 0 and Modulus taking Counter, Buzz is 0 do
Say "FizzBuzz!"
Continue
End if
If Modulus taking Counter and Fizz is 0 do
Say "Fizz!"
Continue
End if
If Modulus taking Counter and Buzz is 0 do
Say "Buzz!"
Continue
End if
Say Counter
End
Minimalist Rockstar example, leaving out unnecessary end statements:
Modulus takes Number and Divisor
While Number is as high as Divisor
Put Number minus Divisor into Number
Give back Number
Limit is 100
Counter is 0
Fizz is 3
Buzz is 5
Until Counter is Limit do
Build Counter up
If Modulus taking Counter, Fizz is 0 and Modulus taking Counter, Buzz is 0 do
Say "FizzBuzz!"
Continue
If Modulus taking Counter and Fizz is 0 do
Say "Fizz!"
Continue
If Modulus taking Counter and Buzz is 0 do
Say "Buzz!"
Continue
Say Counter
Ideomatic Rockstar 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 I'll
Build my world up
If Midnight taking my world, Fire is nothing and Midnight taking my world, Hate is nothing let's
Shout "FizzBuzz!"
Take it to the top
If Midnight taking my world, Fire is nothing let's
Shout "Fizz!"
Take it to the top
If Midnight taking my world, Hate is nothing let's
Say "Buzz!"
Take it to the top
Whisper my world
The only way that the fizzbuzz example works is if the line "While your heart is higher than your soul" is logically "while (your heart >= your soul)" yet comparative operators are described as being < and >
I'd love to see this developed to the point where a song version of RSA encryption would be feasible.
Loop examples included in the README:
Tommy was a dancer
While Tommy ain't nothing
Shout it
Knock it down
And around we go
and
Modulus takes Number and Divisor
While Number is higher than Divisor
Take Divisor from Number
Give back Number
Couple of problems:
Around we go
appears to be the "multi-line loop" statement, but that's not documented.And around we go
is one block with Knock it down
but Shout it
is also another block. OTOH the second example has no Around we go
but seems to just implicitly treat the Take Divisor from Number
as a single-block while loop?Thoughts?
I know this is a relatively basic language but I feel like you could make it more legitimate and allow for more complex programs with the inclusion of more complex data types such as an array.
Syntax could work where filled with
denotes the start of what to fill the array with and you separate the items with but
, and
, or or
. The value of the first data entry that isn't null
or an alias of it would determine what data type the array is.
a shout was loud
a scream was quiet
the nights filled with nothing but a shout and a scream
would fill the array the nights
with null
at 0, 4
at 1, and 5
at 2. Because a shout
is a number it makes the nights
an array containing number types, meaning accessing position 0 would return 0 because that is the number equivalent of null
.
You could also chose not to fill the array at it's initialization which would require stating how large it needs to be which could be done using poetic number literals that are preceded by the phrase full of
. The data type which is contained by the array would remain mysterious
until a non-null
value was input into it.
the nights full of darkness
would create the array the nights
of type mysterious
having 8 spots.
To reference a specific position in the array, to either get the value stored there or assign it a new value, you would state the array name, then the reserved word at
, followed by a poetic number literal, and then either is
to assign or into
to retrieve. To access the zeroth position you would have null
or any of its aliases following at
, this must be done because you obviously can't use a word of no length.
the man at dawn is "weary"
would fill the 4th position in the man
with the string literal "weary"
.
put the man at rest into a casket
would take the value in the 4th position of the man
and assign it to the variable a casket
.
And could be used to continue a string started in the line before using
{variable} says {string}
and {string+}
With and being converted to a space.
I would suggest right
, wrong
, eternal
and a lie
.
Currently there is no way to exit script.
My current proposal:
Goodbye (exit with code 0)
Goodbye world (exit with code 5)
You've got
My dreams were ice. A life unfulfilled; wakin' everybody up, taking booze and pills
- initialises my dreams with the value `3.1415926535'
Isn't taking
a reserved keyword here? Or does that not count during assignments?
I may be mistaken, but I believe your idiomatic FizzBuzz example is incorrect.
In the second stanza when you use the Midnight
function to make the logical comparisons you write Midnight taking Desire,
when it should be Midnight taking My world,
. This is because Desire
is set to the numerical value of 100
and functions like the Limit
variable in the minimalist example. My world
is the variable that is being increased and should accordingly be used in the logical comparisons.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.