It's not
rocket science. Is it?
Started as a joke to learn the inner mechanics of a interpreted language, RocketLang quickly evolved into a long running project with more and more ambitious goals, such as being used forΒ Advent of Code to test it's limits.
π Β» puts("hello from rocket-lang!")
"hello from rocket-lang!"
Β» nil
π Β» langs = ["ruby", "go", "crystal", "python", "php"]
Β» ["ruby", "go", "crystal", "python", "php"]
π Β» langs.pop()
Β» "php"
π Β» langs.push("rocket-lang")
Β» nil
π Β» langs
Β» ["ruby", "go", "crystal", "python", "rocket-lang"]
Get started quickly
You can also install RocketLang via APT, RPM, as a binary or from source. See Β the install guideΒ for more detailed information.
- JSON
- HTTP
- Math
- Time
- Closures
π Β» JSON.parse('{"test": 123}')
Β» {"test": 123.0}
π Β» a = {"test": 1234}
Β» {"test": 1234}
π Β» a.to_json()
Β» '{"test":1234}'
def test()
puts(request["body"])
return("test")
end
HTTP.handle("/", test)
HTTP.listen(3000)
π Β» Math.E
Β» 2.718281828459045
π Β» Math.Pi
Β» 3.141592653589793
π Β» Math.sqrt(3.0 * 3.0 + 4.0 * 4.0)
Β» 5.0
π Β» Time.format(Time.unix(), "Mon Jan _2 15:04:05 2006")
Β» "Mon Oct 31 00:08:10 2022"
π Β» Time.format(Time.unix(), "%a %b %e %H:%M:%S %Y")
Β» "Mon Oct 31 00:28:43 2022"
π Β» Time.parse("2022-03-23", "2006-01-02")
Β» 1647993600
π Β» Time.parse("2022-03-23", "%Y-%m-%d")
Β» 1647993600
newGreeter = def (greeting)
return def (name)
puts(greeting + " " + name)
end
end
hello = newGreeter("Hello");
hello("dear, future Reader!");
Β» "Hello dear, future Reader!"
Strong and stable builtins
RocketLang ships some neat builtins such as handling HTTP requests and responses, marshalling and unmashalling of JSON objects.
It also comes with support of closures, modules and context sensitive variables in order to create complex programs.
Everything is an object
Inspired by Ruby, in RocketLang everything is an object.
This allows to treat unknown input in the same way and figuring out what kind of information your function passes on the go. Every object supports the same minimum default subset of methods to achive this.
π Β» "test".type()
Β» "STRING"
π Β» true.to_s()
Β» "true"
π Β» 1.4.to_s()
Β» "1.4"