Your experience with Scala+Wicket

Alexey picture Alexey · Jan 20, 2010 · Viewed 7.7k times · Source

Could you share your experience of using Scala and Wicket together? Do they fit naturally to each other? Do you get advantage of using Scala (and FP) with Wicket over using Java? Why did (would) you prefer Wicket over Lift?

Answer

Peter Thomas picture Peter Thomas · Jan 21, 2010

For those interested in looking at code, I re-implemented the Seam "Hotel Booking" demo in Scala + Wicket here: Browse | SVN - the Java + Wicket version is here: Browse | SVN

I used the (not yet final) Scala 2.8 and the NetBeans plugin. Was meaning to blog in detail about it (there's even a Groovy + Wicket implementation in place) but a few high-level impressions below; as an example, here's the same UI code in Java | Scala. Observations:

  • certainly a lot less boilerplate and less 'noise'
  • Scala feels like a very good fit for Wicket when it comes to nesting components
  • for e.g. less work / lines of code to define inner classes / constructors, so can do it mostly in-line and keep nesting without much clutter
  • and at the same time override framework methods as one-liners. nice !
  • Scala seemed to work well with Wicket Generics, compiler seemed to be a lot more stricter at times, maybe this is a good thing. NetBeans plugin helps, but still buggy and slow at times.
  • Not a very complex app, so did not get a chance to apply closures and FP much
  • There are some gotchas you need to be aware of like this: Fighting Scala – Scala to Java List Conversion - for the time being I managed using Java collections for domain object properties.

Haven't run a performance test / comparison yet. Stay tuned :) Do let me know if there's anything you want to know when I get around to posting a detailed blog entry on this. Oh and if you get a chance to look through the code and let me know what can be improved, that would be great !

I haven't looked at Lift yet but here's a blog post that may help the OP: Lift from a Wicket Developer's Perspective

Have to say that I would choose Scala over Groovy by a mile if mixing with Wicket. The "organize imports" IDE feature itself settles the question. The new Groovy inner class support has some gotchas that seriously get in the way when using Wicket. Also experienced some problems like groovy.lang.Reference not Serializable etc.