Liz Douglass

Posts Tagged ‘XML

Melbourne Scala Users Group

with 3 comments

On Monday night I braved a blustery wet Melbourne night to go to the first Scala Melbourne Users Group meeting at IBS.

The first speaker was Ben Hutchison. Ben presented Combining Object-Oriented and Functional programming, focusing on the features of the language that stand out for him. Ben said that he has really enjoyed what he’s been doing in Scala although he admits it has been a bit of a steep learning curve.
Here’s some things that Ben mentioned that I learnt from the presentation:

  • Functions are first class objects in Scala. From the example Ben showed it appears that you do have to know a little about the syntax in order to understand what the arguments to a method are and what its return type is.
  • You can override methods with fields and all operators are just methods.
  • You can declare a variable as mutable or immutable using the keyword var (mutable) or val (immutable).
  • Ben spent quite a bit of time on traits, which I basically understand from him to be not unlike modules in Ruby. It is possible for a class to inherit multiple traits, and traits can even inherit from other traits (and even classes in unusual circumstances!).The traits concept seems very powerful – for example Ben mentioned one trait called Ordered that when applied to a class effectively gives your class a group of methods like < (less than) and > (greater than) and all you have to do is implement the compare method.
  • Ben talked about mixing OO and functional programming – something that Nick taught me on my last project. In particular Ben spoke about how functions should be side effect free – an idea that Eric Evans talks about in Chapter 10 in Domain Driven Design.

Mark Ryall was the next presenter and he spoke about Scala’s XML support as well as a bit about using Lift on the Google App Engine. From Mark’s presentation I learnt:

  • It is possible to assign some XML to a variable in Scala
  • You can do either DOM or SAX style parsing of XML, and if your not happy with those options there are some pretty cool extraction operators, that look a bit like XPath when they’re used as Mark pointed out.
  • There’s also XML pattern matchers that can match on XML nodes, but will not work on element attributes at the moment at least.
  • You can generate an XML document by calling savefull. It’s also possible to insert Scala code into an XML document and then write that out.
  • Mark has got a Lift application working on the Google App Engine although apparently it was tricky to get going. One of the really impressive things about what he showed was the really concise user authentication that used the Google Accounts.

Jeremy Mawson was the third speaker for the evening and he focused on testing and more specifically on using specs, which I’d not heard of before. In a lot of ways the tests that he showed us looked like RSpec tests but the syntax does not read quite as nicely as RSpec does.

  • Jeremy showed us how you can nest expectations in specs.
  • Apparently there are over 100 matchers already in specs – and if that’s not enough you can write your own
  • spec makes use of implicit function definition to write the tests
  • specs is one of a handful of Scala testing frameworks 
  • You can use JMock and Mockito in Scala

Overall I’d say it was a really successful meeting. I certainly learnt a lot from the three speakers. I would recommend getting along to the next meeting if you’re in Melbourne. Ben did mention that he was thinking of making the next meeting a practical one. Perhaps he can check out Mark’s blog entries about the TW Sydney Wednesday Night Dojo for some ideas.

Written by lizdouglass

May 3, 2009 at 12:17 pm

Posted in Scala

Tagged with , , ,