A few years ago I took a functional programming course at university; I immediately liked the idea. Since then I became an eager proponent of functional programming. I am now even more convinced that functional programming will continue to increase its reach into mainstream development. Advancements in C# (LINQ) and the bigger spotlight that F# enjoys is proof that Microsoft is also waking up and smelling the curry.
It's been a six months out of the Microsoft camp for me. A few weeks ago I started sniffing around in the wild for a Java VM offering that'll do for a functional thinker like myself. The language Scala was reverently promoted (albeit from a distance) by some of my esteemed colleagues, and I just had to take a closer look. What I found was a pleasant surprise: a first class language that is a viable alternative to Java. Scala is a fully featured object oriented language for the JVM that has been folded nicely with a very usable functional notation.
Allow me to shamelessly punt the language by listing some key language ideas here (mostly to whet your appetite):
- Interoperability. Scala programs work with Java packages. There is no new standard object library to learn. Scala creates normal JARs, and you can import any old Java JAR and use it without modification.
- Implicit typing. When the compiler can derive types (which is often enough), there is no need for you to state the obvious.
- Better class design. In Scala you can declare a "Trait". This is a language construct that allows you to add implemented methods to an interface. Very reminiscent of multiple inheritance.
- Local functions. Declare a function anywhere - even within the method of a class.
- Functions are values. Pass a function around as a value and you end up with a very neat solution to event handlers. And that is just the start of the functional magic.
- Operator overloading. Operators form an important part of the functional paradigm and Scala has a neat solution. Essentially any method that takes one argument is an operator; and yes, you can use operator symbols (such as +,-,++ and many more) as method names.
- Matching. The idea of functional expression matching is nicely extended to regular expressions and compiled XSLT expression, Ready for use where you need it.
- Domain specific language development. Put together a parser and interpreter for your own DSL using a powerful grammar framework.
- Concurrent programming. Use a message oriented programming paradigm built into the language structure to write complex concurrent programs.
You must agree, for any language this is an impressive shopping list. Surely, many more goodies wait to be uncovered.
On a cautionary note, keep in mind I am just beginning to use the language (at home), some of the claims remain to be verified by yours truly. On the other hand, the Scala project seems very active, and the language is gaining ground.
If you feel the urge to learn something different, Scala might be just the thing for you!
Ek sien die manne van Object Mentor punt ook Scala - http://blog.objectmentor.com/articles/2009/09/21/programming-scala-is-now-available
ReplyDeleteEn ja, jy bloggitie-blog-blog-blog dam nie heeltemal vir jouself nie :P