Monday, December 3, 2007

A year with Scala and lift

I was a bit more than a year ago that I stumbled across Scala.

I had been doing Ruby and Rails for 18 months and Java for 10 years before I found Scala.

I was looking for a language that had the strengths of both Java and Ruby and I found them in Scala. I have been happy with the language and the community ever since.

Scala's goodness comes in many forms. Some practical (XML as part of the language syntax, runs on the JVM and has 100% compatibility with Java libraries), some geeky (Scala's type system is powerful and learning to program with primarily immutable data types is an excellent thought-challenge), and esoteric (Scala has an implementation of Erlang's Actors that's pretty spectacular.)

After coding in Scala for year, I find it very difficult to code in Ruby and almost impossible to code in Java. Scala has spoiled me on a bunch of different vectors.

Scala has a command-line interpreter. I can type lines of Scala, have them run... just like IRB in Ruby. That makes exploring a new API much, much easier. For example, I was writing some Crypto stuff the other day (in Java). I was able to check out the Java crypto stuff, run simple examples, etc. from the Scala command line. Once I was satisfied with the code, I ported it to Java and ran it. It's a lot easier than a "make changes to code, run the new program, see what it did" cycle with Java.

Scala's got XML right in the language. I was doing some SOAP coding recently. I captured the wire-level of some existing SOAP calls, copied the XML into my Scala code, and I had a running SOAP client in about 30 minutes. Some of the folks who were doing the same coding task in Java didn't even have all the import statements defined in by the time I had my code running.

Scala allows passing of functions and storing functions in Hashes, etc. It's like having amazingly light weight anonymous inner classes all over your code. In reality, the Scala compiler is creating a bunch of anonymous inner classes, but your code isn't cluttered with all the class definition stuff... your code is a simple statement that looks and feels like it's part of the current method. From a "picking your code up standpoint" it's much easier to understand what you did if your eye sees the substance rather than the cruft that is anonymous class definition.

You can code Scala just like you code Java. All the Java constructs are there (except the c-style for loop, but you'll never miss it.) You can connect to your Java classes and Java libraries from Scala. You can subclass Java classes, implement Java methods and your Scala code looks just like Java code to the other libraries. It's very simple to stick your toe in the Scala water and see if you like the temperature. Also, Scala code runs as fast as Java code so you're not sacrificing performance for language value.

Scala's traits and type system allow for type-safe, compiler checked meta-style programming. No, it's not changing the behavior of classes at runtime, but it is the ability to add complex functionality to classes simply by mixing new methods in. It's far more powerful than Ruby's mixin mechanism and the compiler takes care of making sure things don't get broken. An example of this is adding "user" functionality to an OR mapped class (first name, last name, email, password, etc.) In Ruby, this would be done with acts_as_xxx, in Scala this is done with class Foo extends Mapper with ProtoUser. And, yes, you can, at compile time, add methods to existing classes, even String.

So... what about lift?

One of the things that drove me to search for a new language after doing Ruby was the multi-fold needs for performance, type safety, and integration with Java libraries including Lucene.

I found Scala, but there were no web frameworks for Scala. Sure, I could have coded in Wicket and Hibernate using Scala, but then I would have lost a bunch of the Scala benefits. So, I sat down to write my own web framework. I started with a list of requirements and started coding.

I initially built lift "for me." Later, I started building lift for a multi-person team that I was part of.

Finally, the lift community developed a life of its own and people started using lift for real projects. There are currently 300+ people in the lift community, 5 active committers, and a bunch of active projects being built on lift (including Much4).

There are some amazing people in the lift community... people who know so much more than I do about so many different things. There's great give and take on the lift mailing list.

Most importantly, we're moving lift towards being a 1.0 product... a product that you can build a commercial application on top of. This means being developer friendly, having good documentation, having a decent tool chain.

So... what's so cool about lift?

It's got the code efficiency of Rails -- a few lines gets you a lot of stuff.

It's got the designer friendliness of Wicket.

It's got the statefulness of Wicket and Seaside.

Plus, lift is the best way to write AJAX and Comet applications. With a dozen lines, you can put a dynamically updating clock in your application. You can add chat with 50 lines. All this is possible because of Scala's Actors and the way lift abstracts away the HTTP request/response cycle.

Anyway... stay tuned to the Scala Blogs to see exciting developments in Scala and lift brought to you by some of the coolest people in the Scala and lift communities.


Benji said...

cool! I came from Java/Wicket. Now learning Scala and was reading on integration with Wicket/Hibernate, I think Lift may be better! I heard Wicket is rewriting with Scala from scratch? not sure if it's true.... Lift sounds good!

Tugiran Wibowo said...

Excellent blog you have here but I was curious abou t if you knew of any communi ty forums tha t cover the same topics talked about in this article? I’d really like to be a part of online community where I can get advice from other experienced individuaIs that share the same interest. If you have any suggestions, please let me know. Appreciate it!

Greenwood Jonny said...

obat herbal mengatasi kencing nanah
obat herbal kencing nanah di apotik
obat herbal kencing nanah pada pria
obat herbal kencing nanah
obat tradisional kencing nanah
obat alami kencing nanah
obat alami kencing nanah pada pria
obat herbal untuk kencing nanah
obat herbal buat kencing nanah
apa obat herbal kencing nanah
obat herbal mengatasi kencing nanah
obat herbal kencing nanah di apotik

Dedi Abdullah said...

jual obat untuk kutil kelamin di kota semarang
jual obat kutil penis daerah sorong
jual obat kutil kelamin di solo
gatal berlebihan dimuara Vagina
jual obat penghilang kondiloma
antibiotik kutil kaki
apa nama obat antibiotik untuk kutil kemaluan wanita
jenis obat antibiotik yang dikonsumsi penderita kutil kelamin
mendeteksi kutil kelamin
kapsul kutil kelamin ibu hamil denature
tanya dokter apakah kutil kelamin menular lewat celana dalem
Tumbu dibagian kelamin
herpes genitalis pada wanita