Skip to content
This repository was archived by the owner on Jul 12, 2025. It is now read-only.

Features

Stan Lo edited this page Feb 18, 2018 · 2 revisions

Language

Perhaps Goby should be far easier for Rubyists to comprehend. You can use Ruby's syntax highlighting for Goby as well😀

  • Everything is object
  • Object and Class
    • Top level main object
    • Constructor
    • Class/instance method
    • Class
      • Can be inherited with <
      • Singleton class
      • #send new!
    • self
  • Module for supporting mixin
    • #include for instance methods
    • #extend for class methods
    • :: for delimiting namespaces
  • Variable: starts with lowercase letter like var
    • Local variable
    • Instance variable
  • Constant
    • Starts with uppercase like Var or VAR
    • Global if defined on top-level
    • not reentrant by assignment, but still permits redefining class/module
    • (special variables with $ are unsupported)
  • Methods
    • Definition: order of parameter is determined:
      1. normal params (ex: a, b)
      2. opt params (ex: ary=[], hs={})
      3. splat params (ex: *sp) for compatibility with Go functions
    • Evaluation with/without arguments
    • Evaluation with a block (closure)
    • Defining singleton methods
  • Block
    • do - end
  • Flow control
    • if, else, elsif
    • while
    • raise
  • Literals
    • Numeric literal
      • Integer: 100, -299, -0
      • Float: 3.14, -273.15
    • String literal: "candy", 'cake', :taffy
    • Symbol literal: :email
      • Symbol literal is String class and just a convenient representation for Rubyists.
        • So you can even do like: a = :bar.replace("a", "z"); puts a #=> bzr
    • Array literal: [1, "2", '3', :att]
    • Hash literal: { "email": 'goby@goby-lang.com', tel: '9909-999-999'}
  • IO
    • #puts
    • ARGV, STDIN, STDOUT, STDERR, ENV constants
  • Import files
    • require (Just for standard libraries by now)
    • require_relative
  • Thread (not a class!)
    • Goroutine-based thread method to create a new thread
    • Works with Channel class for passing objects between threads, like chan in Go
    • See this sample: One thousand threads
  • Very few keywords
    • def, true, false, nil, if, elsif, else, case, when, return, self, end, while, do, yield, next, class, module, break
    • Most are implemented as methods, including thread or raise

Native classes

Written in Go.

  • Class
  • Integer
  • String
    • Symbols like :a or hash keys {a: 1} are just another notation of String
  • Boolean
  • Null (nil)
  • Hash
  • Array
  • Range
  • URI
  • Channel
  • File
  • GoObject (provides #go_func that wraps pure Go objects or pointers for interaction)
  • Regexp and MatchData
  • MatchData (to hold the result of regexp matching)
  • Float
  • Decimal
    • Represented as a fraction internally
    • Number of digits has virtually no limit
    • You can get Decimal object as for now: a = "-99.99999999".to_d

Standard libraries

written in Go and Goby.

  • Concurrent::Array
  • Concurrent::Hash
  • DB (only for PostgreSQL by now)
  • Plugin
  • JSON
  • Net::HTTP
  • Net::HTTP::Client
  • Net::HTTP::Request
  • Net::HTTP::Response
  • Net::SimpleServer (try sample Goby app and source, or sample code!)
Clone this wiki locally