Assigning
Assigning is different, I prefer Rebol way since you don't confuse assigning to evaluation.Rebol | Ruby |
---|---|
>> a: 3 | >> a = 3 |
Methods vs refinements
They seems different, but they are quite the same.
On Ruby side you may invoke something with a special method (.):
dir.entries
On Rebol side you use the refinement (/):
read/lines
There isn't difference.
Math
Rebol | Ruby |
---|---|
>> 2 + 2 | >> 2 + 2 |
>> 10 + 4 * 10 | >> 10 + 4 * 10 |
>> 10 + (4 * 10) | >> 10 + (4 * 10) |
>> 40 / 3 | >> 40 / 3 |
If you don't use parenthesis with Rebol, math expressions are wrong evaluated. This is due to Rebol order evaluation form left to right.
On the other side Ruby use integer as standard result, so results are generally wrong. You have to add floating point to a number to get correct results (i.e. 20.0). Too bad!
String manipulation
Rebol | Ruby |
---|---|
>> reverse "Hello word" | >> "Hello word".reverse |
>> length? "Hello word" | >> "Hello word".length |
>> loop 5 [append "" "Hello word"] | >> "Hello word" * 5 |
>> reverse 40 | >> 40.reverse |
>> reverse to-string 40 | >> 40.to_s.reverse |
>> a: "My hairs are black, your hairs are red" | >> a = "My hairs are black, your hairs are red" |
As you noted function and error are pretty similar, Rebol code is more intelligible. Even Rebol errors a clearer than Ruby ones.
Ruby substring substitution command is very cryptic.
Long text manipulation
We need to invert lines order of the following text:
Hello this is a test
What language do you prefer?
Rebol or Ruby?
Are you sure?
Rebol | Ruby |
---|---|
|
|
|
|
Ruby way is more concise. Even finding is more concise:
Rebol | Ruby |
---|---|
|
|
Rebol doesn't have the equivalent of Ruby's include?, so you must use find and true?.
Moreover Rebol found? has nothing relatinve to find, but it declare if a variable is set, this is a bad repetition since Rebol has also value? for the same purpose.
Rebol | Ruby |
---|---|
|
|
Note that Rebol lowercase function modify the input string, on the contrary Ruby's one not. Rebol behavior should be improved.
Block
A block is a series of commands contained between bracket, Rebol uses square brackets, Ruby uses curly brackests:
Rebol | Ruby |
---|---|
|
|
Array / Series
Rebol | Ruby |
---|---|
[ 12 47 35] | [12, 47, 35] |
maximum-of [ 12 47 35 ] | [12, 47, 35].max |
sort a | a.sort! |
Note that maximum-of function return all the series after the maximum value, to isolate the value you need the first function:
>> maximum-of [ 47 52 20 1 2 3]
== [52 20 1 2 3]
>> first maximum-of [ 47 52 20 1 2 3]
== 52
This behavior is strange and may lead to big confusion to users.
Ruby distinction of function is better than Rebol, if a method (function) end with an exclamation mark (!) it changes the input. On the contrary the exclamation mark in Rebol is used just for variables types (money!, date!, etc.). I prefer Ruby way.
Words vs symbol
Ruby has symbols, words not evaluated; Rebol has words. Both ways memory isn't wasted.
Rebol | Ruby |
---|---|
|
|
Objects vs hashes
Ruby has hashes, Rebol doesn't have them. Hases that are very similar to Rebol objects:
Rebol | Ruby |
---|---|
|
|
Even if Ruby's style it's longer to type, Ruby's hashes are more flexible than Rebol objects. You may add or remove items to an hash, on the contrary an object it's more static.
You may access to the element in very similar ways:
Rebol | Ruby |
---|---|
|
|
Functions vs methods
Ok, I admit, both ways are practical identically:
Ruby:
def mymethod(temp)
temp = temp * 2
temp
end
A method declaration start with def and end with end.
Rebol function way is:
myfunc: func [temp][
temp: temp * 2
temp
]
Class vs object
Ruby class and Rebol object are the same thing. Ruby way creation is more complicated. For example let's create a blogentry class/object empty:Rebol | Ruby |
---|---|
|
|
|
|
|
|
|
|
GUI
Even Ruby's GUI is on every OS as Rebol 2, Ruby GUI uses Tk libraries, but there are other libraries available. Rebol 3 GUI works only on Windows OS:
There are many other GUI library available for Ruby, the most famous are:
- FXruby
- QTruby
- Shoes
- wxRuby
- GnomeRuby
- RubyCocoa
- Winforms
Documentation
The open source essence of Ruby, mixed with a good site and documentation create a huge community. Here is the available documentation:Rebol | Ruby |
---|---|
Branches
The Ruby's developer has been always pleasant with forks of his source, so we have:
Rebol | Ruby |
---|---|
|
|
Verdict
Rebol and Ruby give you the same tools to create your application. Rebol is elegant and a little more simple to write, on the other hand Ruby is better documented and known. You can find anything you want about Ruby on internet, the source, documentation, binaries and libraries. All is open, so it's easy to improve it.
On the contrary in the last 10 years Rebol lost all support, learning Rebol is very difficult and at the present no one know very well the just released code of Rebol 3. Moreover at the present only Rebol 2 is totally cross-platform.
For big project, Ruby is mature and complete, while Rebol needs a big community to reach Ruby level. What you can do? Spread Rebol!
value? and found? are different. value? returns true if the given word HAS a value (ie. not unset!)
ReplyDeleteAnd in control structure no need to use true? or found?
>> if find "test" "s" [print "ok"]
ok
You are right, my concern is that I would expect "found?" to be relative to "find". Instead "found?" is very similar "value?" and "none?".
DeleteHowever I like that this post shook the Rebol community :-)
Show me any programming language easy to learn?
ReplyDeleteREBOL is difficult to learn, but JAVA, C#, C++, VB, F# LISP, COBOL, Pascal, Assembler, APL, SQL etc are difficult too:)
You are right. Difficulty of a language in my opinion is the result of 2 elements:
Delete- language itself (Rebol is extremely easy)
- documentation (Rebol lacks of good documentation)
Ruby: a.sort!
ReplyDeleteREBOL: sort copy a
Ruby: a.sort
REBOL: sort a
About lowercase and other action! function, the Ruby way to notice with an exclamation point functions that modify the argument is good. Rebol sort, lowercase, uppercase, etc., modify the input, but you have to read the help to know it. If I try:
DeleteA: [ 3 4 1 2]
B: sort A
both B and A are changed, but user may not know it.