Category Archives: Scala
Posts on or related to Scala development
3 commands, 2 dependencies, 1 minute.. blast off with Scala development using the mvn archetype
I go to a fair few (probably too many), tech conference and meetups. A passing observation, is that if code samples are shown a proportion of the audience will try to run them while following along. Initially, this seems counter intuitive (to try and both listen and absorbing information while also trying to perform actions as a background task), though my own experience is that this works suprisingly well for practical activities, (maybe the multi-sensory exposure helps learning and retention ?).
Continue reading
Scala + JDK 6 annotations = Simple REST service in ~ 50 LOC
This is a post I’d been meaning to submit for some time and is the chaser sibling to the SOAP fuelled scrub up, showing how to create a very simple service in the Restful style using only Java 6 and the Scala language (note I personally use Scala v2.9). Continue reading
Partial updates in an immutable World
This post was prompted by a conversation with a good friend, who is an experienced Java developer taking their first, tentative, steps towards becoming a Scala programmer. Basically, the conversation went as follows:
“…Immutability seems good and like a goal I should aim for. How can I get this in my domain objects without having to provide a multiplicity of constructors to do partial updates ? Is it really that big a deal ? I’ve rarely had to worry about this stuff in Java at all !”
Both fair question, which I’ll try to address in the remainder of this post. Continue reading
A crash course in Scala types
After many years of Java development, discovering Scala’s type system and related features was something of a departure for me. Suffice to say GADT wasn’t my first four letter utterance when learning about pattern matching on types, let alone what, when and how to use variance annotations and generalized type constraints. To kick things off, here’s a ‘small but powerful‘ few lines of buzzword bingo on the type system:
…Scala is a statically, strongly, typed language, with implicit type inference and support for structural and existential types. It also features parameterized types, abstract and phantom types and is capable of implicitly converting between datatypes. These core capabilities are utilized by context and view bounds and complimented by generalized type constraints, to provide powerful compile time contracts. Furthermore, Scala supports declaration site type annotations to facilitate invariant, covariant and contravariant type variance…
In a word, Ouch !
In the remainder of this post, I’ll try to demystify these concepts and sew the seeds of intrigue for further investigation.
Continue reading
Pattern Matching in Scala distilled
Using functions to convey intent
Something I had been meaning to post for a while, was a simple snippet showing the use functions as values and/or variables in Scala and how expressive this is at conveying intent within the code. Continue reading
Power with control… control structures and abstractions in Scala
Scala + JDK6 annotations = Simple Web Service < 20 LOC
Notes from… Scaling webapps with Akka [live blog]
Akka is a Scala based framework for creating robust and scalable distributed applications, and (along with the Lift web framework), has been one of the poster boys for the Scala dev community. Given the [relative] naivety of Scala programming language I was intrigued to see what was actually possible with these frameworks from the trenches. Tonight’s presentations from Maciej Matyjas (@matyjas) at skillsmatter offered to show exactly these possibilities using both Lift and Akka to build a scalable webapp with remote actors, and also using sbt as the build tool (sbt purporting to be the Scala good cop equivalent of Maven).