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

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

As the name suggests, pattern matching enables the checking of a sequence of tokens for the presence of the same pattern. Beyond the Scala language, pattern matching is a commonly employed programming technique in a number of (predominantly functional), programming languages including Haskell, Erlang, ML, Clojure and Prolog. In this post I’ll cover the different flavours of pattern matching in Scala, as well as providing reference to typesafe null and extractor patterns to cover the idiomatic usage of pattern matching in Scala.

Power with control… control structures and abstractions in Scala

So ramping up with the Scala 101 series, I thought now is an appropriate juncture to introduce control structures in Scala. To a certain extent, working with the Scala language presents a vista wherein the developer is afforded much greater freedom than in many other environments, but therein lies a great many choices and a sense of responsibility. As such, I’ve consciously tried to restrict this post to covering some of the main flavours and options for control-flow and ¬†iteration within Scala, how they differ and provide examples of usage. Continue reading

Scala… As good as it gets…

As good as it gets was a film starring Jack Nicholson, in which he played a misathropic writer who also happened to suffer from OCD. What bearing has this got with Scala ? Well non-directly, or even indirectly TBH, though I’d say that if Scala were best represented by any psychological disorder, it would most likely be some flavour of bipolar disorder. Scala really does seem to be a modern programming Marmite, where developers either love it or hate it. With no real middle ground being forged between the two. I personally find this quite ironic given the ‘maleability’ of Scala as a programming tool. Continue reading