News for hackers. Stuff that matters.
Re:Graham’s Guide to Learning Scala by bad_user on Friday November 23, 2012 @02:04AM (#4821218)
I don't think this is a good guide for Learning Scala.

The Introduction from scala-lang.org and a Tour of Scala are not good introductions. They are meant as a TL;DR that will leave you scratching your head and reading the list of features without the larger context of a language is an awful way to learn about that language.

IntelliJ IDEA with the Scala plugin is a good IDE, but the article should have included a link to the Scala-IDE plugin for Eclipse. It's not friendly for beginners to make them install a plugin, which is why Typesafe is already providing a download of a completely configured Eclipse here: http://typesafe.com/stack/scala_ide_download

Also, when starting out with a language I would rather use a plain text editor and the compiler directly, because complicated tools bring with them complicated problems ... Hello World with just the compiler is just one text file that you can directly execute, versus the notion of whatever a project is in an IDE. And you should start with the REPL anyway.

"Scala for Java Refugees" is an article series that's out of date and not that good frankly. There already is a comment here from somebody saying he was scared when he saw in that series the usage of implicit conversions - a feature that in Scala 2.10 is considered experimental, for really advanced use-cases and that has to be enabled manually, as for most purposes there are better solutions available - but on the other hand, the context of a feature matters a lot. Implicit conversions are great for dealing with the "expression problem" and through their means, Arrays (a fundamental JVM data-structure with a broken interface) behave like plain Seqs in Scala, while Strings are considered to be lists of chars (as in Haskell or Lisp).

I didn't like Alex Payne's "Programming Scala" book. It's boring, it's poorly organized and it's out of date - for instance a big part of it involves dealing with Scala's Actors, but Scala's Actors were terrible, which is why in Scala 2.10 the implementation in the standard library gets replaced with Akka, which is the defacto standard anyways, but it also has a slightly different API and concepts. Actors are also the kind of powerful construct that's not easy to tame, being an awful way to start learning Scala ... before Akka Actors, look into Scala's Parallel collections, or into Akka's Futures and Promises or into ScalaSTM.

Speaking of Parallel Collections and Futures and Promises, no mention of Scala's Documentation project?

http://docs.scala-lang.org/overviews/

A much better introduction to the language is "Scala for the Impatient", a book that wasn't mentioned and one third of the book (enough to get you started) is available from Typesafe's website: http://blog.typesafe.com/free-pdf-from-typesafe-scala-for-th...

You also cannot write about learning resource, without mentioning "Programming in Scala" by Odersky, a wonderful book also meant for human beings. Its only problem is that it's a tome of information and you may not have the patience for that, but it's not a hard to digest book so if you've got the time and patience, then this is THE book you should read: http://www.artima.com/shop/programming_in_scala_2ed

And you must also mention "Scala in Depth" by Joshua Suereth, which is like the equivalent of "Effective Java", a ~ 300-pages book you definitely must read once you're done with "Scala for the Impatient": http://www.manning.com/suereth/

On the other hand the Coursera Course taught by Odersky on Function Programming is awesome. I've took it and it was worth every minute of it.

Re:Graham’s Guide to Learning Scala by irahul on Friday November 23, 2012 @02:34AM (#4821259)
> You also cannot write about learning resource, without mentioning "Programming in Scala" by Odersky, a wonderful book also meant for human beings. Its only problem is that it's a tome of information and you may not have the patience for that, but it's not a hard to digest book so if you've got the time and patience, then this is THE book you should read: http://www.artima.com/shop/programming_in_scala_2ed

+1

The book is huge, but that's more to do with the fact that Scala is one kitchen sink of a language than the writing.

Re:Graham’s Guide to Learning Scala by bad_user on Friday November 23, 2012 @02:41AM (#4821270)
The book is huge because it goes to great length at explaining good design practices, the rationale of features in the language and how they are implemented under the hood, not mentioning functional programming and OOP concepts ... many of the exercises from SICP also appear in this book.

It's a complete reference to the language and I've never seen a reference that isn't huge.

Scala is not a kitchen sink. The number of features included is quite small and for the most parts orthogonal, but because those features are very powerful, their combination is a little overwhelming for beginners. This happens in every language that's not meant for assembly lines. Even for Java, learning is not complete without reading another book on patterns and another one on effective usage of it.

Re:Graham’s Guide to Learning Scala by jeremyjh on Friday November 23, 2012 @10:10AM (#4822414)
They also spend time on external libraries, such as Akka. Part of the appeal of Scala is that its design for extensibility can make libraries feel like part of the language and Akka is one of the best examples of this (and indeed was designed with input from Odersky as a replacement for native Scala actors).

It really is a great book. I never thought I would read this type of technical book on a Kindle but it reads really easily and I have read far more of it than I would on paper (even though paper is better for a reference book, I don't want to read a big heavy book in bed but I really do with the Kindle).

Re:Graham’s Guide to Learning Scala by bad_user on Friday November 23, 2012 @10:25AM (#4822462)
Totally forgot to mention the standard library, which is getting quite big. Just yesterday I read the chapter on parser combinators. Good book :)

Although I haven't encountered mentions of Akka in Programming in Scala by Odersky. There is a chapter on Actors but I skipped it and went straight to http://akka.io

Btw, for technical books I'm using an iPad, as you can read PDFs with colors on it and it's easier to go back and forth between pages and zoom-in, zoom-out, being closer to the way I normally read technical books. I then put PDFs I buy in Google Drive and open them in Acrobat Reader, also available on iPads.

So don't buy eBooks from Amazon, prefer the original publisher instead, to also get a DRM-free PDF in addition to the Kindle format (you never know when you'll use it).

Re:Graham’s Guide to Learning Scala by jeremyjh on Friday November 23, 2012 @11:08AM (#4822633)
You are right, they don't actually cover Akka - the concurrency chapter covers Scala actors. My memory failed me.
Re:Graham’s Guide to Learning Scala by silentbicycle on Friday November 23, 2012 @11:54AM (#4822801)
> It's a complete reference to the language and I've never seen a reference that isn't huge.

Lua's reference is 112 pages. Just sayin'. (Also, online at http://www.lua.org/manual/5.1/ .)

Re:Graham’s Guide to Learning Scala by seanmcdirmid on Friday November 23, 2012 @01:25PM (#4823141)
All generalizations are false :)

Lua's design philosophy is to keep it simple, which works well for their user base and domain of use (lots of embedding in games as a scripting language). Scala is not meant to be a simple scripting language, its more like a power language. Both are very good languages.

Re:Graham’s Guide to Learning Scala by silentbicycle on Friday November 23, 2012 @02:07PM (#4823264)
Indeed, and Lua gets a lot simpler because it can shrug stuff outside its scope onto C.

(The Definition of Standard ML is also pretty short, though... ;) )

Re:Graham’s Guide to Learning Scala by bad_user on Friday November 23, 2012 @02:28PM (#4823330)
And Scala's is 191 pages, including blanks: http://www.scala-lang.org/docu/files/ScalaReference.pdf
Re:Graham’s Guide to Learning Scala by thebluesky on Friday November 23, 2012 @04:56AM (#4821640)
Scala for the Impatient is definitely the best introduction to Scala (by a wide margin). Re-posting your link: http://blog.typesafe.com/free-pdf-from-typesafe-scala-for-th...
Re:Graham’s Guide to Learning Scala by thebluesky on Friday November 23, 2012 @05:28AM (#4821726)
The preferred way of launching an app in Scala is as follows:

  object HelloWorld extends App {
    println("Hello, world!")
  }
Rather than manually creating a main method, as is done in the OP blog.

It's also possible to simply write:

  println("Hello World")
and that would be the entire app, but the preferred way of doing things is to extend App
Re:Graham’s Guide to Learning Scala by orp on Friday November 23, 2012 @05:31AM (#4821734)
+1 for the 'functional programming in Scala' mention. Really awesome and fun class to take.

Lecture are available here: https://class.coursera.org/progfun-2012-001/class/index

Re:Graham’s Guide to Learning Scala by eeperson on Friday November 23, 2012 @03:25AM (#4821359)
Implicit conversions are not considered experimental in 2.10. Also they are not disabled by default in 2.10. They may disabled in future versions. Scala 2.10 will just give you a warning if you use implicit conversions without explicitly enabling them.

https://docs.google.com/document/d/1nlkvpoIRkx7at1qJEZafJwth...

Re:Graham’s Guide to Learning Scala by bad_user on Friday November 23, 2012 @04:42AM (#4821588)
Sorry, I never got much into Scala 2.10, I'm on 2.9.2 and this impression I got from Odersky's pieces of opinion about it, as from what I remember the initial proposal was for disabling those features, instead of plain warnings, but I guess that changed and it's my fault for not double-checking before giving it as argument (as a disclaimer I'm not an authority on the matter, I'm a rookie too).

I've explained in another comment below what I meant when using the word "experimental". Indeed I don't remember M Odersky ever using this word, but he did use "cutting edge" when giving the rationale for SIP 18.

Re:Graham’s Guide to Learning Scala by grlea on Saturday November 24, 2012 @06:13AM (#4825084)
There are some interesting resources in the above comment. However, by criticising all the introductory material and replacing it with nothing, it misses the point of having a guide to learning Scala. The "plan" it suggests is essentially this:

1. Ignore the freely available, expert-written introductory material on the internet;

2. Don't use tools that will highlight simple mistakes for you quickly;

3. Buy this Scala book and read it;

4. Buy this other (very similar) Scala book and read it;

5. Buy this more advanced Scala book and read it.

Leaves me wondering whether bad_user works for a bookshop.

Re:Graham’s Guide to Learning Scala by RyanZAG on Friday November 23, 2012 @02:26AM (#4821243)
Thank you. That was a lot more helpful than the linked article!
Re:Graham’s Guide to Learning Scala by weego on Friday November 23, 2012 @03:54AM (#4821436)
Apart from it's not all accurate. Implicits have been part of Scala from the start and are used heavily throughout all the core libraries and many large projects so they will not be going anywhere... the changes in 2.10 allow you to use implicit classes on top of the current uses (and using implicit parameters is considered good practice), though they generate a compile time warning if you don't import implicitConversions.
Re:Graham’s Guide to Learning Scala by bad_user on Friday November 23, 2012 @04:08AM (#4821482)
Implicit conversions are used heavily, they aren't going anywhere, but their usage is taking a back seat to other means for achieving the same thing, like context bounds, which is a cheap(er) and safer mechanism for type-classes (jargon doesn't help in learning sadly, type-classes are like open interfaces, such that you can make any existing type implement it - think about adding Ordering to an existing type, like integers and then using it in a sort() that then works on all types with Ordering implemented).

Also implicit classes are only a subset of implicit conversions. Implicit classes are like "extensions methods" from C# (only a little more potent, in the true Scala fashion :)). Their usage is simpler, reasoning about them is simpler, if the implicit class inherits from AnyVal, then performance is better since the compiler will not create wrapper objects, and so on.

It's a subset because implicit conversions allows for viewing any type A as any other type B. This is powerful, but also has gotchas that people fall into ... for one, these conversions are not transitive. So if type A can be viewed as type B and type B can be viewed as type C, that doesn't make type A viewable as type C. To make this work you have to deploy really complicated logic to help the compiler do what you mean and it turns out that in most cases that's not what you really wanted to do anyway. It's also unclear how adding transitivity will interact with other features or what gotchas that may have, while making the compiler slower and more complicated, but put plainly - this is not the kind of feature that does the right thing.

I said "experimental", because the feature itself is a feature where the bounds of what you can and cannot do aren't at all clear and require extensive knowledge of the compiler's decision process, which means it's ripe for replacement as soon as something better comes along, equally powerful, but without the gotchas. This hasn't happened yet, but it probably will, though as a disclaimer I'm also a beginner so I have no way of knowing that.

Either way, I'm happy that Scala is not a frozen language and the team working on it is trying to find ways to safely evolve it. It's pretty bad having to live with broken features for legacy reasons.

I also said "implicit conversions", not implicit parameters. All languages have implicit parameters, even if we are talking about the Singleton pattern / global state or dependency injection.

Scala's mechanism for implicit parameters is better, because it's light, lexically scoped, overridable and compile-type checked, having the side-effect that it scares beginners away since those implicits end up in function definitions ... but I think that's better than carrying around implicits of which you don't know about and anything that helps with referential transparency is Good.

Re:Graham’s Guide to Learning Scala by wiradikusuma on Friday November 23, 2012 @06:10AM (#4821815)
couldnt agree more. skip the article and read this comment instead.

and also, coursera and scala for impatient are definitely must check.