Scalazine has written her “First Steps to Scala”. Here’s my own. I am so thrilled to do so. This is why: the best way to learn a programming language is just to teach it to others as you’ll be obliged to question and answer yourself about the what, the why and the how.
Scala’s installation is as easy as Rebol: just download and unzip except if you’re on Vista - you cannot install it just by copying and pasting the folder outside the program files directory.
You can then run Scala Console (the exe in the bin directory) and type the infamous “hello world”:
print("hello world")
You don’t need to add “;” at the end but you need the “(” and “)” around the print argument.
In Rebol you don’t need neither the “;” nor the parenthesis which will spare you 3 potential mystypo - if you write them thousands of time that counts !
print "hello world"
Let’s now use a variable in Scala …
var msg = "hello world"
print msg
… and in Rebol:
msg: "hello world"
print msg
Scala Console will output the variable msg’s type:
scala> var msg = "hello world"
msg: java.lang.String = hello world
scala> print(msg)
hello world
scala>

whereas Rebol will output the content of the variable:
>> msg: "hello world"
== "hello world"
>> print "hello world"
hello world
>>
Though Rebol doesn’t output the variable type, Rebol like Scala is strong-typed language as you can check by using the type? command:
>> type? msg
== string!

Strong typing is something Scala is very proud of achieving and there are more to say about types both in Scala and Rebol but we will delay the discussion in another lesson.
Now the problem with Scala output is that you cannot chain print and variable declaration in one instruction as I tried this:
scala> print(var msg = "hello world")
:1: error: illegal start of simple expression
print(var msg = "hello world")
^
scala>
whereas in Rebol this can be done very naturally:
>> print msg: "hello world second time"
hello world second time
>> msg
== "hello world second time"
>>
Before leaving with variable, Scala has another way to declare a variable using the val keyword instead of the var keyword, the difference being you cannot change the value of the variable later on (immutability):
scala> val msg = "hello world"
msg: java.lang.String = hello world
scala> msg = "hello world second time"
:5: error: reassignment to val
msg = "hello world second time"
^
scala>
In Rebol, you can also protect a variable (with protect function indeed) which will require two lines instruction instead of one in Scala:
>> msg: "hello world"
== "hello world"
>> protect 'msg
>> msg: "hello world second time"
** Script Error: Word msg is protected, cannot modify
** Where: halt-view
** Near: msg: "hello world second time"
>>
Remark that Rebol use msg to refer to the content of the variable and ‘msg to refer to the variable pointer or symbol which is of type word! in Rebol:
>> type? 'msg
== word!
>>
In Rebol it is also possible to unprotect a variable:
>> unprotect 'msg
>> msg: "Hello World Second Time"
== "Hello World Second Time"
>>
Unlike Scala, there is no option to strongly protect a variable in Rebol which, I confess, is a pity. It would be great if we could write something like this in Rebol:
>> protect/strong 'msg
strong would be so-called protect function refinement in Rebol.
That’s all for this first lesson as I haven’t much advanced on Scala yet. Hope you enjoyed it if you’re an absolute beginner in Scala or Rebol (do you realize you can learn two languages in one single trip ;)).
Oop I forgot … to close Scala and Rebol Consoles, just type :quit and quit respectively.


















Do you know much about functional languages? The idea is to avoid side effects, you would not want to do print msg: “blah” because setting msg to blah is a side effect of the print, and it messes with loop invariants.
A better way in scala just requires having defined the right function beforehand.
def PrintAndGet(msg:String) : String = {print(msg);msg}
And so if you want to do this weird functionality you want, it would be:
val msg = PrintAndGet(”Hello World”)
because no matter what, you’re trying to do:
val msg = {print(msg);msg}
Thanks you for your nice comment, I know perfectly about side effect. This is the first tutorial (I guess you didn’t read the next articles). There are others following and if you have read the scala founder’s book he starts like I did.
This is a tutorial site for beginners, things are introduced step by step. It’s not about showing off one’s knowledge.
And as usual there are extremists in everything in oop like in fp, so read this article on pure fp before flaming thanks:
http://www.rebol.com/cgi-bin/blog.r?view=0206