Ted Neward on why Java developers need Scala. Scala Syntax Primer. Scala runs on the JVM and can directly call and be called from Java, but source compatibility was not a goal. Scala has a lot of capabilities not in Java, and to help those new features work more nicely, there are a number of differences between Java and Scala syntax that can make reading Scala code a bit of a challenge for Java programmers when first encountering Scala. This primer attempts to explain those differences. It is aimed at Java programmers, so some details about syntax which are the same as Java are omitted. This primer is not intended to be a complete tutorial on Scala, rather it is more of a syntax reference.
For a much better introduction to the language, you should buy the book Programming in Scala by Martin Odersky, Lex Spoon and Bill Venners. Most of these syntax differences can be explained by two of Scala's major goals: Minimize verbosity. . (0/:list)(_+_) Scala is an integrated object/functional language. Contents Basics Keywords Symbols and Literals Expressions Arrays Types. Scala as the long term replacement for java/javac? Don't get me wrong - I've written tons of Java over the last decade or so & think its been a great evolutionary step from C++ and Smalltalk (lots of other languages have helped too like JavaScript, Ruby, Groovy, Python etc). However I've long wanted a long term replacement to javac.
I even created a language to scratch this itch. Java is a surprisingly complex language (the spec is 600 pages and does anyone really grok generics in Java?) , with its autoboxing (and lovely NPE's hiding in there), primitive types, icky arrays which are not collections & general lack of polymorphism across strings/text/buffers/collections/arrays along with extremely verbose syntax for working with any kind of data structure & bean properties and still no closures (even in JDK7) which leads to tons of icky try/catch/finally crapola unless you use frameworks with new custom APIs & yet more complexity.
So whats gonna be the long term replacement for javac? So why Scala? E.g. in Java List<String><String> in Scala. Scala By Example. Scala. Code Commit: Roundup: Scala for Java Refugees. 13 Feb 2008 To be honest, I’m somewhat kicking myself for writing this post. As I’ve said many times: roundup posts are for people who are too lazy to write real content. I can’t tell you how many blogs I’ve come across which have a roundup-to-post ratio of easily 3:1. You know it’s a bad sign when sites start having roundups of their roundups… Meta-roundups aside, I decided (after much deliberation) that a single post linking to all six parts of the series would be useful to one or two people.
So if you like to save things with del.icio.us or even plain-old-bookmarks (POBMs for short), this is the one! And if no one finds it useful, eh, I suppose Google probably likes it. Of course it’s always possible that you subscribe to my way of looking at things. Part 1: main(String[]) Introductory article giving motivation for learning Scala and some first steps to “get your feet wet” in the language. Part 2: Basic OOP Looking at Scala’s syntax in a little more detail. Part 3: Methods and Statics.