Giter VIP home page Giter VIP logo

rooby's Introduction

rooby

Join the chat at https://gitter.im/rooby-lang/Lobby

Build Status Code Climate GoDoc Go Report Card codecov Readme Score

rooby is a Ruby-like object oriented language written in Go. You can think it as a simplified, compilable Ruby for now.

Goal

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.

Questions

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 ๐Ÿ˜ข). Here's a list of frequently asked questions.

Supported features

  • Can be compiled into bytecode (with .robc extension)
  • Can evaluate bytecode directly
  • Everything is object
  • Support comment
  • Object and Class
    • Top level main object
    • Constructor
    • Support class method
    • Support inheritance
    • Support instance variable
    • Support self
  • Variables
    • Constant
    • Local variable
    • Instance variable
  • Method
    • Support evaluation with arguments
    • Support evaluation without arguments
    • Support evaluation with block (closure)
  • BuiltIn Data Types (All of them are classes ๐Ÿ˜€)
    • Class
    • Integer
    • String
    • Boolean
    • nil (has this type internally but parser hasn't support yet)
    • Hash
    • Array
  • Flow control
    • If statement
    • Haven't support for yet
  • IO
    • Just puts for now

(You can open an issue for any feature request)

TODO

See github projects

Install

  1. You must have Golang installed
  2. You must have set $GOPATH
  3. Add your $GOPATH/bin into $PATH
  4. Run following command
$ go get github.com/rooby-lang/rooby

Usage

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

Try it!

(See sample directory)

$ rooby ./samples/sample-1.ro
$ rooby ./samples/sample-2.ro
$ rooby ./samples/sample-3.ro
$ rooby ./samples/sample-4.ro
$ rooby .....

Development & Contribute

See the guideline

References

I can't build this project with these resources, and I highly recommend you to check them out if you're interested in building your own languages

Sample snippet.

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

Build a stack using rooby

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

Block support

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.")

rooby's People

Contributors

st0012 avatar appleboy avatar gitter-badger avatar janczer avatar

Watchers

James Cloos avatar Mhd Sami Al Mouhtaseb avatar satnami-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.