# Learning Scala

Some questions for people who are learning / have learned Scala: What languages did you know beforehand, and how easy did you find learning Scala in comparison to these? Are there any languages which you found knowing particularly helpful when picking up Scala?

An explanation follows:

Scala seems to be a relatively hard language to learn for some people, not so much for others. Part of this is its complexity – it really does have a lot of little features – but I’m wondering if more of it might be its approach. It’s a language with two major inspirations – object orientation (in the peculiar flavour of it Java practices) and statically typed functional programming, and I’m not sure how easy it is to understand the language unless you understand where it’s coming from in this regard.

In particular one thing we’ve observed in #scala from people learning the language is that if you know both Java and Haskell (I presume an ML would work as well?), learning Scala becomes significantly easier. I had almost no trouble picking it up, but I know both. Ricky Clarkson seems to be in a similar boat in terms of Haskell + Java having helped. I presume others are too. On the other hand, people with Java background but not much FP seem to have more trouble and people coming from a predominantly ruby or python background have a harder time yet. (I don’t know what happens to people coming from a Haskell with no Java background. I’d expect a similar degree of confusion to the Java with no Haskell background).

Some of this is probably in terms of material – a lot of Scala tutorials, etc. out there seem to assume you already know Java. This is probably largely accurate but seems like a mistake in the long-term to me. On the other hand, I’d be really uncomfortable teaching Scala as a first language, so what languages *should* they be learning to prepare the way? Anyone tried learning it on the basis of, say, Ruby + OCaml?

So, what do we want people’s path into Scala to be? Should we suggest they learn Java first if they don’t want a bit of a rough start, or is there a better way?

This entry was posted in programming and tagged , , , on by .

# Minor irritations

I just noticed the following issue in Java. It’s never bothered me before, so it’s clearly not that big a deal, but I find it vaguely annoying.

The following code is not legal:

final Foo foo;
try{
foo = stuff();
} catch (Exception e){
foo = otherStuff();
}


The compiler thinks that foo might already have been assigned in the catch block, even though it clearly can’t have been.

The reason is presumably that it doesn’t distinguish it from the following code:

final Foo foo;
try{
foo = stuff();
bar();
} catch (Exception e){  // Might have been thrown from bar.
foo = otherStuff();
}


Which is reasonable. I’m not sure if I’d really want this edge case to be handled specially.

As Ricky Clarkson pointed out in ##java, what would really be much nicer is:

final Foo foo = try { stuff(); } catch(Exception e) { otherStuff(); }


i.e. Compound expressions ala Scala (or GCC extensions, or any number of other languages). It would avoid a lot of annoying edge cases with assigning to final variables.

This isn’t really a “Please add this to Java 7” request. I don’t care enough and the list of desired features is getting annoying. It’s just a minor irritation with the language.

This entry was posted in programming and tagged , , on by .