I've recently become interested in learning Scala, my first thought was a simple compiler, but I don't have very good knowledge of Automata theory.
So my question is: what's a good project or tutorial to learn scala with?
I've recently become interested in learning Scala, my first thought was a simple compiler, but I don't have very good knowledge of Automata theory.
So my question is: what's a good project or tutorial to learn scala with?
I used scala in combination with Processing to make computer games! What better way to learn a language than to use it!
Of course, I also made functional-friendly programs in the beginning. Fractals are an excellent example of this, as are image filters. However, it took a traditionally-imperative problem such as an Asteroids clone to make it really click with me.
EDIT: On a similar note, writing a scheme compiler in scheme really helped me learn the language, but that's not nearly as simple or feasible with a language as complex as Scala. Maybe write a scheme compiler in Scala?
I'm currently using the exercises from here. I'll admit that his approach is not really specific to scala, but it is a really nicely stepped approach to moving from the basic idioms up into the special-purpose libraries of a new Language of the Year..
Update(09.27.2008): Here's a really good primer to the syntax of Scala: link
There is very good a book called "Programming in Scala" that is being written at the moment. You can buy a preprint PDF at Artima.
Of course there is also a lot of free information available on the Scala site. Look at the Scala Reference manuals.
If you have questions you can go to the Scala mailing lists, which are also reference on the Scala site.
Cay Horstaman has his lectures and exercises for a functional programming course with Scala here.
If you come from Java, I think that a good way to star is reading this series of articles from IBM.
Ted Newar give us a nice and funny explanation about Scala, sometimes comparing to Java what makes you lear faster in a consistent way.
Good luck!
For a Java programmer I would recommend Daniel Spiewak's Scala for Java Refugees tutorial series.
As Lars mentions, Cay Horstmann's languages course is a great way to get started. I have been following it regularly, and his slides are filled with hands-on examples to try out. While some may be disappointed that the course specifically hones in on the functional aspects of Scala, it was great for me coming from a Java background to break out of the OO mindset for a bit.
Another way I'm learning Scala is to blog about it, comparing it with Java (pros/cons/when would I want to use each). In general, one good way to learn is to compare it with another language you already know. Implement the same problem in both languages and evaluate the pros/cons of each, so that you can see where you would want to use each one.
The third way is to do problems in Scala. I find I learn best if I have a specific objective in mind. Whether it be to implement an entire application, or just solve little problems here and there. Because I'm doing this in my off time, and don't have a lot of bandwith to solve big problems, I plan on solving problems from Project Euler. That way, I can focus more on learning the language than coming up with problems to solve.
besides the Artima Venner/Spoon / Odersky book, pragmatic is also doing a book which should be in beta PDF soon:
O'Reilly is also writing a book on Scala, about time, I need all of the help I can get....
I’m finding that converting some of my “hobby” open source projects from Java to Scala, along with the excellent Venner/Spoon/Odersky book has been a huge help.
http://davebsoft.com/applications
http://briccetti.blogspot.com/2009/01/dbschools-overlapping-blobs-and-name.html
So far, the Code Commit Blog and Scala By Example proved to be the most invaluable learning resources for me. (Your mileage may vary, depending on your programming records.)
In practice (learning by doing is best!), you should start with transforming one of your former minor Java projects (or a module of them) and you shall see how boilerplate is eliminated and the need for complex frameworks is disappearing quickly!
I'd suggest pipe programming. :-)
Do you use Unix? Have you ever written long sequences of grep, awk, cut, sort, uniq, sed, wc and such commands piped together? If not, sorry, my answer is not for you. If you have, though, you'll find yourself written similar code in Scala.
It's mostly about collections. You think of Sets, and Lists, and Arrays and Sequences... You don't need to worry much about what type of data you have -- you can easily convert from one type to another.
Learn the basics of using those structures. Look up 99 Scala problems (based on 99 Prolog problems) on the Internet, and try these exercises. This will give you the basics of manipulating those types.
Next, start beefing up on map, flatMap, exists, forall and filter. These are the workhorses of collections. It's like grep&sed. Try replicating pipe commands in Scala (scala.io.Source makes it easy to generate lists from file lines).
After that, get the Scala API and pay attention to the methods defined in all collections. Think of creative uses for them.
That's what did it for me in the end.
Some tutorials here: http://reboltutorial.com/blog/category/scala/