Skip to main content

Posts

Showing posts with the label scala

Targeting Android with Scala 2.8 Trunk builds

The definitive reference for using Scala on android seems to be here: http://www.scala-lang.org/node/160 Unfortunately, all the references on using scala with android are based around Scala 2.7 and refer to a custom build android-library.jar, with a couple of cryptic references suggesting that this custom build isn't needed for later versions of android (I'm using 2.1 / API v7) So... What are the steps needed to use Scala 2.8 in an android project? Preferably using eclipse and the Android tools that Google supplies for that IDE.

Android without Java

After doing the whole "enterprise" programming for a while, I'm seriously disillusioned by the language itself and always feel quite hampered if I have to go back to it. The project size of your average Android app isn't too intimidating and the libraries are actually quite nice regarding their coding style, but if I could avoid Java, I'd certainly do. So that's the question: Can I avoid it? While there are lots of JVM language that would be an option on desktops and servers, the Dalvik VM and the devices themselves pose some limits. This seems to be a bit better in 2.2 with the JIT, but limiting myself to the cutting edge would be a rather harsh decision. The only alternative I know that's used somewhat seems to be Scala. Is there some possibility I'm missing? Clojure seems to run in exactly the problems I've illustrated above with Dalvik, but as the AppInventor is built on Kawa there might be hope for a Lisp on the mobile platform? What o

Instantiate a type based on json and metadata using lift-json

I would like to deserialise Scala case classes that have been serialised using lift-json. The problem I am having is, I don't know how to invoke the generic method extractOpt[A] method below: someString:String = {...} JsonParser.parse(someString).extractOpt[A] The type of [A] is going to depend on metadata, for example the class name of [A] but for the life of me I can't work out how to make the call using reflection. In c# I would just be able to set the generic type for a call on extractOpt[A] using reflection. I fear my problems are something to do with Java type erasure. I am going to have a lot of case classes so I really want to avoid having to create some kind of hand crafted map from {metadata} -> classOf[]. I have full control over what the metadata associated with someString is. If it helps understand why I have this issue, I am implementing event sourcing, and all my [A] types are going to be persisted events. Any ideas what I can do?