Tuesday, April 15, 2008

Scala + Annotations

So, in my private effort to create a Scala Web framework that doesn't look like Rails... I started taking a closer look at Scala-Java interaction. Specifically I wanted to know if I can use JPA for persistence in Scala. I figure hibernate and/or JPA should be more familiar to users and I wouldn't have to write anything to wire it together. Anyway, I was impressed when I found that this is all that's required to map a Scala class with JPA:


@Entity
class MyScalaClass {

@Id
@Column{ val name="O_ID" }
var id: Long = -1
var name: String = _
}


Anyway, I hope to have more extensive Scala coverage along with any slick ways of handling things I can think of. One thing I really love about Scala is that it decided to "make the compiler your batman" again (Anyone who knows that reference [hint: C++ developers should] wins a prize). Since Scala is type safe AND infers a type, I can not only implicitly do things, I can make some good compile-time guarantees. Hopefully this combined with Java-bytecode interoperability will make for a great platform with which to build a (non-railsy) Web-Stack.

0 comments: