This repository was archived by the owner on Jul 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 175
Features
Stan Lo edited this page Feb 18, 2018
·
2 revisions
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!
- Can be inherited with
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
orVAR
- Global if defined on top-level
- not reentrant by assignment, but still permits redefining class/module
- (special variables with
$
are unsupported)
- Starts with uppercase like
- Methods
- Definition: order of parameter is determined:
- normal params (ex:
a
,b
) - opt params (ex:
ary=[]
,hs={}
) - splat params (ex:
*sp
) for compatibility with Go functions
- normal params (ex:
- Evaluation with/without arguments
- Evaluation with a block (closure)
- Defining singleton methods
- Definition: order of parameter is determined:
- Block
-
do
-end
-
- Flow control
-
if
,else
,elsif
while
raise
-
- Literals
- Numeric literal
- Integer:
100
,-299
,-0
- Float:
3.14
,-273.15
- Integer:
- 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
- So you can even do like:
- Symbol literal is
- Array literal:
[1, "2", '3', :att]
- Hash literal:
{ "email": 'goby@goby-lang.com', tel: '9909-999-999'}
- Numeric literal
- 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, likechan
in Go - See this sample: One thousand threads
- Goroutine-based
- 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
orraise
-
Written in Go.
Class
Integer
-
String
- Symbols like
:a
or hash keys{a: 1}
are just another notation ofString
- Symbols like
Boolean
-
Null
(nil
) Hash
Array
Range
URI
Channel
File
-
GoObject
(provides#go_func
that wraps pure Go objects or pointers for interaction) -
Regexp
andMatchData
-
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
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!)