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 176
Features
Shozo Hatta edited this page Jun 10, 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 by
.initialize - Class/instance method
- Class
- Can be inherited with
< - Singleton class
-
Class.ancestors #» [Class, Module, Object]-
Class.newis possible
-
#send
- Can be inherited with
self
- Module for supporting mixin
-
#includefor instance methods -
#extendfor class methods -
Module.newis possible- but cannot perform
#newon modules' instances Module.ancestors #» [Module, Object]
- but cannot perform
- Modules cannot inherit classes/modules
- Modules cannot be inherited by classes
-
- Namespace
-
::for delimiting namespaces for class/module/constants
-
- Variable: starts with lowercase letter like
var- Local variable like
mail,tel - Instance variable like
@mail,@tel - Class variables: unsupported
- Local variable like
- Constant
- Starts with uppercase like
VarorVAR - 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 parameters are strictly determined:
- normal params (ex:
a,b) -- default value with=is optional - opt params (ex:
ary=[],hs={}) --[]or{}cannot be omitted on the callers' args - keyword params (ex:
mail:tel:) -- default value=is optional - splat params (ex:
*sp) for compatibility with Go functions
- normal params (ex:
- Evaluation with/without arguments
- Evaluation with a block (closure)
- Defining singleton methods
-
attr_accessor,attr_reader,attr_writer
- Definition: order of parameters are strictly determined:
- Block
-
do-end
-
- Flow control
-
if,else,elsif whileraise
-
- Literals
- Numeric literal
- Integer:
100,-299,-0 - Float:
3.14,-273.15
- Integer:
- String literal:
"candy",'cake',:taffy - Symbol literal:
:email- Symbol literal is
Stringclass 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": '[email protected]', tel: '9909-999-999'}
- Numeric literal
- IO
#puts-
ARGV,STDIN,STDOUT,STDERR,ENVconstants
- Import files
-
require(Just for standard libraries by now) require_relative
-
- Thread (not a class!)
- Goroutine-based
threadmethod to create a new thread - Works with
Channelclass for passing objects between threads, likechanin 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,get_block - Most are implemented as methods, including
threadorraise
-
Written in Go.
ClassInteger-
String- Symbols like
:aor hash keys{a: 1}are just another notation ofString
- Symbols like
Boolean-
Null(nil) HashArrayRangeURIChannelFile-
GoObject(provides#go_functhat wraps pure Go objects or pointers for interaction) Regexp-
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
-
Block- This can perform
.newtaking a block to generate a block object (similar to Ruby's proc object) - The block object can perform
#callto execute the block
- This can perform
written in Go and Goby.
Concurrent::ArrayConcurrent::Hash-
DB(only for PostgreSQL by now) PluginJSONNet::HTTPNet::HTTP::ClientNet::HTTP::RequestNet::HTTP::Response-
Net::SimpleServer(try sample Goby app and source, or sample code!)