The point is missed

Museum of public mistakes and unfinished projects

Drying up widget creation

with 6 comments

I continue to be amazed how Scala lets me keep my code DRY (if I care to do it the tools are there, I just need to look for them). One of the reasons that Scala allows this more than Java is that Scala supports functional programming. One thing that makes Scala interesting is that Scala blends Functional Programming and Object Oriented programming. This is often overwhelming but it really keeps the tools you need close at hand.

To start with I had to be torn kicking and screaming from my beloved object orientation. I was told I suffer from the Stockholm syndrome which was quite a hilarious way to put it. Especially since I live in Stockholm and was immediately comforted by the same person with the words “I suffer from it too, I still love C++”. So I thought maybe leaving my comfort zone is not so bad?

Yesterday it payed off and I experienced a kind of flow that was new to me in Scala. I thought I’d share that experience here step by step. Don’t expect to be blown away by my Scala-skills, If you want to be impressed in that way there are other blogs :) What follows is a real world example of  things coming together into a moment of productiveness. I guess another real world example of applying Scala to a problem could not harm? Read the rest of this entry »

Advertisements

Written by johlrogge

January 14, 2009 at 1:12 am

Posted in learning, scala, Uncategorized

Tagged with ,

Making SWT shine with Scala

with 34 comments

At Agile 2008 I was calmly coding together with Daniel Brolund in the open space area. We were interrupted by a guy that asked us if we did any coding in Ruby and if we did he will hold a lightning-talk about a framework he had put together to create SWT-gui:s using JRuby. Interestingly enough I had thought about how GUI-coding could probably be improved in a language such as Ruby so I reluctantly stopped what I was doing and watched the lightning talk. This was the first time I ever saw Glimmer and it totally blew me away!

Read the rest of this entry »

Written by johlrogge

January 6, 2009 at 8:48 pm

Posted in Ruby, scala, SWT

Tagged with ,

Scala Nugget – Pattern matching and Lists

with 7 comments

I was whining recently about how my scala-code is java in poor disguise. I started reading the scala by example pdf that also comes with the scala installation. I just read some interesting things about lists and pattern-matching that gave me an idea how to “scalafy” the following scjava-code:

Read the rest of this entry »

Written by johlrogge

October 6, 2008 at 10:27 pm

Posted in scala

Tagged with , , , , ,

Phasing over from java to scala, retrospect

with 10 comments

I have written quite a few posts, 4 to be exact, about my experiences with phasing over from java to scala in my pet-project. I thought it is about time to take a look in the rear-view mirror now when some time has passed and I am more comfortable with Scala.

Read the rest of this entry »

Written by johlrogge

October 1, 2008 at 10:32 pm

Posted in scala

Tagged with , , ,

Phasing over from java to scala pt. 4 – Writing specs with specs

with 7 comments

In the last part I figured out how to make Buildr run specs that are also runnable from Eclipse via JUnit. I started writing my first spec and we are now in the position to make it fail. What we are trying to acomplish is to make directories behave as nodes in a graph, at the moment, only the files show up as nodes.

The spec I wrote currently looks like this:

class PublishSiteGraphSpecTest extends JUnit4(PublishSiteGraphSpec)
object PublishSiteGraphSpec extends Specification {
  "directories are nodes" in {
  }
}

Let us fill in the details about what we actually mean when we say that directories should be nodes:

Read the rest of this entry »

Written by johlrogge

September 14, 2008 at 10:05 pm

Posted in Uncategorized

Tagged with , , ,

Buildr – Keeping up with the latest and greatest

with one comment

In a previous post I ran into some problems with Buildr’s support for Specs in combination with JUnit. I googled a bit and came up with nothing so I did what all newbies do. Ask the pros on the mailinglist :) (I stayed away from “plz help” and “could you plz send me a patch”). I was (of course) suggested to try the latest from head and I felt an unpleasant resistance towards downloading archives, figuring out how to point gems to the latest version etc. All of those things are probably simple but I just want to develop some Scala code and did not look forward to it.

Well, boy was I worrying in vain!

Read the rest of this entry »

Written by johlrogge

September 13, 2008 at 1:49 pm

Posted in Uncategorized

Tagged with , , ,

Scala Nugget – implicits to make java blend into Scala

with 2 comments

Most of my posts related to Scala so far have been quite long and unpolished I have intentionally kept them that way since I wanted to give a feel for what i is really like to make the shift, including the dead ends.

During the work of converting Java to Scala I have stumbled over some things that I found to be extra cool, nuggets. I’ll try to post them here from time to time.

The first nugget is about implicits. Implicits are so cool that I think I will shoot myself in the foot with them many times so let’s start now. One piece of java-code that I converted looked for module descriptions on the class-path. The code looked something like this:

Read the rest of this entry »

Written by johlrogge

September 11, 2008 at 9:06 pm

Posted in java, scala

Tagged with , ,