views:

709

answers:

5

I had limited success myself. I was able to hype a few persons about Scala. But in fact none of them made a meaningful effort to try to switch (usually from Java).

I would like to read both success and failure stories here. Both long tries and short ones.

My goal is to find ways of presenting Scala to another person, friend, co-worker (not an audience) that will make them want to use this great language.

+3  A: 

I recommend posting pictures of the Programming Scala book on the wall and constantly suggesting that "Scala can do that" whenever a programming question comes up. It convinced me to look into Scala, but I can't say that I've "switched".

scompt.com
After the first few times, just start saying "SCDT".
Randall Schulz
+4  A: 

I can tell you how I found Scala, which may help.

Two guys at my work had mentioned it once or twice, and maybe I'd seen a few of those "Is Scala the next Java?" posts on blogs, but neither of these had convinced me to look into it. Then I noticed that my local Java User Group was having a talk about Scala, and I thought, "That's what I need: someone to explain it to me in less than two hours using PowerPoint, while I drink free beer." Ironically, not wanting to be totally bamboozled by the talk, I spent a couple of hours before the talk reading about Scala and looking at a few simple examples.

After seeing someone get excited about little snippets of Scala code who I didn't know, but who was clearly a pragmatic, non-academic programmer, and who was obviously trusted enough by other people to give a talk, I decided I needed to write a few little programs to check it out myself and haven't looked back. Now I run a multi-million dollar company where I write a whole Scala application from scratch each day and sell each one for US$70,000. (Okay, the last bit isn't true - yet.)

To summarise, the following helped get me across the line, and may help get your friends and workmates across the line:

  • free beer
  • a short talk...
  • ... by a stranger who seemed to be respected (and was also "new to Scala")
  • small code examples, in large print, on a large screen
  • examples of everyday efficiencies (e.g. the map() function) rather than academic possibilities (e.g. monads)

Two resources I found very useful in learning a little about Scala as a complete newbie and which you could easily pass on to your targets:

I've also written a blog entry about "Why your company should let you use Scala at work" which is targeted at people like those you are trying to reach (and their managers - and my managers!).

Graham Lea
If you want a failure story, I've been mentioning the benefits of Scala to my Manager (who is also a programmer) at least once a week for the last six months and I don't think he's read a thing about it yet.
Graham Lea
Thanks for the links - I'm hyped up, but haven't yet made it to any of the (infrequent) intro talks happening locally. Will have a read...
Alison
@Graham - I think your scala `balanceFor` nastiness (i.e. using `Option.get`) can be simplified using either for-comprehensions or explicitly using `flatMap`. Arguably if the thing you are looking for may not exist, the whole should return an `Option` in any case
oxbow_lakes
Thanks for the ideas, Chris. Without a doubt, there's probably a hundred ways to do the same thing, like most things in Scala.Looking at it now, if I wrote it for myself I'd do as you suggest and return Option by using a combination of filter(), map() and firstOption() calls.The point of the example, though, was not to show the most efficient solution but more to show how approaching the problem in pretty much exactly the same way as the Java (find the customer with this name, then the account with that name) yielded more succinct code while increasing comprehensibility.
Graham Lea
Out of interest, what do you think a for-comprehension solution would look like? I don't have much experience with these.
Graham Lea
@Graham: http://paste.pocoo.org/show/204066/
missingfaktor
@Graham - I was persuaded by some Danes at scaladays that for-comprehensions could be much more readable when compared with map/flatMap. I think Rahul's example is an excellent example of this. In general you should look at `Option.get` as a code smell!
oxbow_lakes
@Graham: If you don't `get` why `Option.get` is bad, see this thread: http://stackoverflow.com/questions/2079170/why-optiont ;-)
missingfaktor
Hi Rahul,Thanks heaps for the for-comprehension example. I have avoided "for" in Scala because it feels a bit imperative, but I understand that comprehensions are compiled to flatMap() calls under the hood, so I may try to keep that in mind and experiment with them a little more.
Graham Lea
Hi again Rahul. For what it's worth, I consider I have a fairly good understanding of Option, but I don't agree with you that `Option.get` is "bad". While I mostly use `match`, `map` and `getOrElse`, if the behaviour I want is "either get a value or throw an Exception", then calling `get` does exactly what I want.
Graham Lea
@Graham: Although `for` comprehensions have a somewhat imperative feel and can always be replaced with operations like `map`, `flatMap` and `filter`, they are still useful in situations where you are composing lots of monadic operations (where the method syntax won't be quite as readable). See this thread: http://stackoverflow.com/questions/1052476/can-someone-explain-scalas-yield
missingfaktor
+10  A: 

I've been sold after hearing an excellent Scala presentation by Mr. Odersky himself, at Jazoon'2008 in Zurich. The main selling points were:

  • In Scala, you can do everything you can do in Java
  • Even use Java libraries and your existing code, almost effortlesly
  • But Scala has much better syntax (I passionately hate boilerplate code, especially getters and setters, and Java arguably has more boilerplate stuff than COBOL).
  • You can write code snippets much more concisely comparing to Java.
  • Closures!

You see — I wasn't a functional programming aficionado; only after one year I became interested in FP.

Alexander Temerev
I think Alexander makes a good point. The Functional-ness of Scala is often put forward as a Good Thing, and hence a reason for switching from Java. Realistically, though, you can use Scala to go on writing the same imperative code you have always written in Java, just much more efficiently (i.e. almost eliminate boilerplate). I think this is much more appealing to extant imperative programmers than the proposal of shifting to a new paradigm.
Graham Lea
You can program Scala like it's Java with a funny syntax. You can program Scala like it's Ruby. You can also program Scala like it's O'Caml. These are all different degrees of integrating functional programming concepts into your programs.
Ken Bloom
But to get rid of boilerplate you are most often using higher order functions. You are using FP at that point.
Synesso
+2  A: 

I would liken leaving Java behind to giving up heroin. It can be explained the various merits of alternatives, such as beer or chocolate and also the various drawbacks of continued use: like destitution, prostitution or death.

But generally, giving up heroin is something that people usually do when they are good and ready

oxbow_lakes
@oxbow_lakes: Isn't switching from Java to Scala more like switching from codeine to heroin?
Randall Schulz
A: 

I think it will be hard to make the case, at least to me, until a better IDE is built. I would agree that scala is much much better than java as a pure language. But in terms of overall developer productivity, I would wait until we see a better tool, The guys building the eclipse plugin have done an admirable job but the task at hand is very large. While, for example, I dont think we need all the refactorings that eclipse provides, we need at least some of them. There are some other issues as well. We have +1M LOC and the eclipse projects are quite big. The scala plugin really slows down the dev env because of the weaving the scala plugin needs. It may be the case that some project can work around this stuff but I dont think we can. Sadly, by the time the dev envs are really ready, java may have closed the gap enough to make it tolerable.

Alan
Use Jetbrain IDEA IDE
Łukasz Lew

related questions