rooby-lang / rooby
- понедельник, 24 апреля 2017 г. в 03:11:49
Go
A new object oriented language written in Go aim at developing microservice efficiently.
rooby is a Ruby-like object oriented language written in Go. You can think it as a simplified, compilable Ruby for now.
I want to build a language that focuses on developing microservices. Which should be performant and easy to write. This is why rooby has Ruby's user friendly syntax and is written in Go.
A lot people have questions about rooby
since it's a new language and you may get confused by the way I describe it (sorry for that
.robc
extension)for
yetputs
for now(You can open an issue for any feature request)
See github projects
$ go get github.com/rooby-lang/rooby
Execute rooby file using VM
(might see errors on sample-6 since vm hasn't support block yet)
$ rooby ./samples/sample-1.ro
#=> 16
Compile rooby code
$ rooby -c ./samples/sample-1.ro
You'll see sample-1.robc
in ./samples
Execute bytecode
$ rooby ./samples/sample-1.robc
(See sample directory)
$ rooby ./samples/sample-1.ro
$ rooby ./samples/sample-2.ro
$ rooby ./samples/sample-3.ro
$ rooby ./samples/sample-4.ro
$ rooby .....
It will be actively developed for at least a few months. Currently I'm working on building a vm that supports some basic features in Ruby (block, module...etc.). And I will use github project to manage rooby's development progress, you can check what I'm doing and about to do there.
I will appreciate any feature proposal or issue report. And please contact me directly if you want to get involved. rooby is very young so we can do a lot interesting things together.
class User
def initialize(name, age)
@name = name
@age = age
end
def name
@name
end
def age
@age
end
def say_hi(user)
puts(@name + " says hi to " + user.name)
end
def self.sum_age(user1, user2)
user1.age + user2.age
end
end
stan = User.new("Stan", 22)
john = User.new("John", 40)
puts(User.sum_age(stan, john)) #=> 62
stan.say_hi(john) #=> Stan says hi to John
class Stack
def initialize
@data = []
end
def push(x)
@data.push(x)
end
def pop
@data.pop
end
def top
@data[@data.length - 1]
end
end
s = Stack.new
s.push(1)
s.push(2)
s.push(3)
s.push(4)
s.push(10)
puts(s.pop) #=> 10
puts(s.top) #=> 4
class Car
def initialize
yield(self)
end
def color=(c)
@color = c
end
def color
@color
end
def doors=(ds)
@doors = ds
end
def doors
@doors
end
end
car = Car.new do |c|
c.color = "Red"
c.doors = 4
end
puts("My car's color is " + car.color + " and it's got " + car.doors.to_s + " doors.")