Article Discussion
First Steps to Scala
Summary: In this article, you'll follow twelve steps that are designed to help you understand and gain some basic skills in the Scala programming language.
33 posts on 3 pages.      
« Previous 1 2 3 Next »
The ability to add new comments in this discussion is temporarily disabled.
Most recent reply: May 6, 2010 3:54 PM by
Admin
Posts: 15 / Nickname: admin / Registered: January 17, 2002 3:57 PM
First Steps to Scala
May 11, 2007 8:23 PM      
In this article, you'll follow twelve steps that are designed to help you understand and gain some basic skills in the Scala programming language.

http://www.artima.com/scalazine/articles/steps.html

What do you think of Scala?
Stanislas
Posts: 2 / Nickname: graven / Registered: May 3, 2007 8:09 PM
Re: First Steps to Scala
May 12, 2007 2:05 AM      
Personnaly, I like Scala, it looks like a very cute development effort. But I have to admit that hybrid languages aren't likely to have any future — they lack lazyness that is vital to the success of functional language.
Morel
Posts: 1 / Nickname: masklinn / Registered: September 11, 2005 7:44 AM
Re: First Steps to Scala
May 12, 2007 11:12 AM      
> Personnaly, I like Scala, it looks like a very cute
> development effort. But I have to admit that hybrid
> languages aren't likely to have any future — they lack
> lazyness that is vital to the success of functional
> language.

I fail to see how lazyness (as a core semantic of the language) is "vital" to functional language. Only one lazy functional language is even remotely widespread (Haskell, Miranda is also lazy but one can't say it's "widespread"), the vast majority of functional languages follow a strict evaluation model (pretty much every Lisp dialects, pretty much every ML dialects and derivatives including SML and OCaml, Erlang, ...) with the potential ability to include local lazyness (Scheme, D, Nemerle).

Not to mention that lazy evaluation still has huge execution-time and memory behaviour issues (which lead to the introduction of strict-evaluation operators and variants in Haskell for optimization purposes...)
Isaac
Posts: 51 / Nickname: igouy / Registered: July 10, 2003 7:42 AM
Re: First Steps to Scala
May 13, 2007 5:05 PM      
Morel Xavier wrote
> Only one lazy functional language is even remotely
> widespread (Haskell, Miranda is also lazy but one can't
> say it's "widespread") ...

Clean also.

http://clean.cs.ru.nl/About_Clean/Clean_Language_Features/clean_language_features.html
Tomi
Posts: 1 / Nickname: tmaila / Registered: May 13, 2007 7:49 PM
Re: First Steps to Scala
May 14, 2007 0:51 AM      
Nice article guys! It's really nice to see Scala being introduced in this extent here at artima! Keep up with the good work.
James
Posts: 128 / Nickname: watson / Registered: September 7, 2005 3:37 AM
Re: First Steps to Scala
May 14, 2007 5:08 AM      
This is really a great intro. I wish I had this when I was first trying to figure things out (not that I've figured it all out.)

Keep up the good work and thanks.
Daniel
Posts: 11 / Nickname: djimenez / Registered: December 22, 2004 0:48 AM
Re: First Steps to Scala
May 14, 2007 6:37 AM      
Great introductory article.

A question about the map examples. What is it about method -> that is better than just defining the tuple? I mean, why is (1 -> "value") better than (1, "value")?
James
Posts: 128 / Nickname: watson / Registered: September 7, 2005 3:37 AM
Re: First Steps to Scala
May 14, 2007 8:52 AM      
> Great introductory article.
>
> A question about the map examples. What is it about method
> -> that is better than just defining the
> tuple? I mean, why is (1 -> "value") better
> than (1, "value")?

Good question. The only thing I can think of is that you could perhaps override the -> method, if that's allowed. Not sure that would be a good thing, though.
Mark
Posts: 2 / Nickname: puzzler / Registered: June 9, 2006 11:07 AM
Re: First Steps to Scala
May 14, 2007 7:48 PM      
Good, lucid introduction overall. I still don't understand the order in which Scala calls the various overridden methods it inherits from its traits and superclass. I can't extrapolate from the exclamatorygreeter mixin example to understand how the chain would be resolved in general. Care to elucidate?
Andrew
Posts: 1 / Nickname: andrewom / Registered: May 14, 2007 6:04 PM
Re: First Steps to Scala
May 14, 2007 11:19 PM      
One advantage of the -> method is that brackets are not required (unlike the example in the article). This makes the syntax a lot more readable: e.g.

val romanNumeral = Map(1 -> "I", 2 -> "II", 3 -> "III", 4 -> "IV", 5 -> "V")

versus

val romanNumeral = Map((1, "I"), (2, "II"), (3, "III"), (4, "IV"), (5, "V"))
Ravi
Posts: 2 / Nickname: ravim / Registered: January 27, 2003 7:14 PM
Re: First Steps to Scala
May 15, 2007 5:49 AM      
I find I need to say Console.println("Hello") vs println("hello") as described in the article.

scala> println("j")
<console>:4: error: not found: value println
val line3 = println("j")



What am I doing wrong?
Ravi
Posts: 2 / Nickname: ravim / Registered: January 27, 2003 7:14 PM
Re: First Steps to Scala
May 15, 2007 6:13 AM      
Urgh it seems I had the wrong version. Scala 2.5RC doe sindeed have the "println" construct.

It would be nice if the scala interpreter could output the version number.

something like ...

$python
Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25)
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Lex
Posts: 3 / Nickname: lexspoon / Registered: October 9, 2006 11:13 PM
Re: First Steps to Scala
May 15, 2007 11:58 PM      
All the Scala tools accept -version. Since you usually should not care about the version so much, I am going to leave out the Pythonic display of the version at every invocation.

$scala -version
Scala code runner version 2.5.0 -- (c) 2002-2007 LAMP/EPFL
Lex
Posts: 3 / Nickname: lexspoon / Registered: October 9, 2006 11:13 PM
Re: First Steps to Scala
May 16, 2007 0:02 AM      
Anyway, doesn't the -> version look nicer? Identifiers are not in short supply, so I don't see why there should be any effort to conserve them, unless....

Ahh, maybe it appears to Artima readers to be a special case in the syntax. It is not. -> is just an operator, which in Scala can be used as a method name.
Lex
Posts: 3 / Nickname: lexspoon / Registered: October 9, 2006 11:13 PM
Re: First Steps to Scala
May 16, 2007 0:16 AM      
The details are in the spec.

http://www.scala-lang.org/docu/files/ScalaReference.pdf

By the way, this spec is readable as specs go. There is a ton of detail, but it is meant to be readable, not to be leverage for lawyers.

Anyway, the rule is that inherited classes and mixed in traits get linearized. Message sends invoke the first class/trait in the linearization that has a matching method, and super calls work their way up through the linearization. The precise linearization algorithm is in the spec, but it is an intuitive one IMHO.

Note that with this rule, you can evaluate all of the methods by simply chaining "super" calls. If the first method invokes "super", and so do all the others except for the last, then you will end up invoking each method one time. This pattern is practically impossible with multiple inheritance, and is awkward with the original traits from U. Berne.
33 posts on 3 pages.
« Previous 1 2 3 Next »