Should I study Scala? [closed]
Asked Answered
B

8

31

I am an experienced C++ programmer with average Python skills. The reasons I studied Python in the first place were:

  • to get a different perspective on programming (static vs dynamic, interpreted vs compiled, etc.)
  • to increase the breadth of projects that I can work on (Python allows me to do web development, develop for Symbian phones or knock up quick system administration scripts)
  • to complement my C++ skills.

I think that Python is great and I believe that I have achieved the above goals. I will continue to use it for small projects, scripts and web development.

I doubt that I can use it for medium to large projects though. While the dynamic typing is convenient, it allows a certain class of bugs that I find disturbing. Unit testing and linting can alleviate this problem, but static typing completely eliminates it.

After looking at some programming languages, I think that Scala looks like a good candidate: I like the type inference and it runs on the JVM so it should be available wherever the JVM is available. I can also learn more about functional programming when using it.

But... I also have some doubts, and this is where I hope that the Stack Overflow community can help:

  • Portability: Linux and Windows at least I hope. What about mobile phones, is it possible to get it to run there?
  • C++ compatibility: can I mix C++ code with Scala? (JNI?)
  • Programming paradigm: I don't feel comfortable with switching to functional programming (FP) at this time. Can I use object oriented and procedural with some FP at first and then change the proportions as I learn?
  • Tool chain maturity: what's your experience with IDEs and debuggers? I'm using Eclipse right now and it seems OK.
  • Learning speed: considering my experience, how fast do you think that I can reach a workable level with Scala?
  • Deployment: how exactly do you deploy a Scala program? Is it a jar, is it an executable?

Finally, what do you think that are some of Scalas disadvantages?

Blindfold answered 10/7, 2009 at 10:34 Comment(3)
Book: Programming in Scala, Martin Odersky et al., Artima, 2007Lorettelorgnette
Thank you all for your answers and recommendations. I have decided to take a closer look at Scala.Blindfold
Best book for me was "Scala for the Impatient" by Cay Horstmann. The first 9 chapters are freely available.Scipio
C
28
  • Portability: Linux and Windows at least I hope. What about mobile phones, did anyone succeed in getting it to run there?

Yes. There is quite some movement about Scala on Android. As for J2ME, I saw something in that respect, but not much. There is some code pertaining to J2ME on the source code repository. I'm not sure how viable it is, but it looks to me that there isn't much demand for that.

I'll also mention that there is/was a pool on Scala-Lang about the desired target platforms, and J2ME was one of them, very low on the totem pole.

  • C++ compatibility: can I mix C++ code with Scala? (JNI?)

As well as you can mix C++ with Java, for whatever that is worth. If you haven't any experience with that, you can just read the Java resources, as anything in them will be applicable with Scala with no changes (aside Scala syntax).

  • Programming paradigm: I don't feel comfortable with switching to FP at this time. Can I use OO and procedural with some FP at first and then change the proportions as I learn?

Definitely, yes. Scala goes out of it's way to make sure you don't need to program in a functional style. This is the main criticism of Scala from functional folks, as a matter of fact: some do not consider a language functional unless it forces the programmer to write in functional style.

Anyway, you can go right on doing things your way. My bet, though, is that you'll pick up functional habits without even realizing they are functional.

Perhaps you can look at the Matrices series in my own blog about writing a Matrix class. Even though it looks like standard OO code, it is, in fact, very functional.

  • Tool chain maturity: what's your experience with IDEs and debuggers? I'm using Eclipse right now and it seems ok.

IDEA (IntelliJ), NetBeans and Eclipse all have good support for Scala. It seems IDEA's is the best, and NetBeans/Eclipse keep frog-jumping each other, though NetBeans has certainly been more stable than Eclipse of late. On the other hand, the support on Eclipse is taking a very promising route that should produce results in the next 6 months or so -- it's just that it's a bumping route. :-)

Some interesting signs of Scala tooling for these enviroments is the fact that the Eclipse plugin in development uses AOP to merge more seamlessly with the whole IDE, that the NetBeans plugin is being completely rewritten in Scala, and that there's a Scala Power Pack on IDEA that supports, among other things, translating Java code into Scala code.

The EMACS folks have extensive tools for Scala as well, and lots of smaller editors have support for it too. I'm very comfortable with jEdit's support for small programs and scripts, for instance.

There is also good Maven support -- in fact, the standard way to install Lift is to install maven, and then build a Lift archetype. That will pull in an appropriate Scala version. There's an scala:cc target that will do triggered recompilation as well.

Speaking of recompilation, neither Maven, and particularly nor Ant do a good job at identifying what needs to be recompiled. From that problem sprung SBT (Simple Build Tool), written in Scala, which solves that problem through the use of Scala compiler plugin. SBT uses the same project layout as Maven, as well as Maven/Ivy repositories, but project configurations are done in Scala code instead of XML -- with support for Maven/Ivy configuration files as well.

  • Learning speed: considering my experience, how fast do you think that I can reach a workable level with Scala?

Very fast. As a purely OO language, Scala already introduces some nice features, comparable to some stuff that's present in C++ but not Java, though they work in different fashion. In that respect, once you realize what such features are for and relate them to C++ stuff, you'll be much ahead of Java programmers, as you'll already know what to do with them.

  • Deployment: how exactly do you deploy a Scala program? Is it a jar, is it an executable?

The same thing as Java. You can deploy JARs, WARs, or any other of Java targets, because the scala compiler generate class files. In fact, you use Java's jar to generate a Scala's JAR file from the class files, and the Maven targets for Lift support building WAR files.

There is an alternative for script files, though. You can call "scala" to run Scala source code directly, similar to a Perl of Shell script. It can also be done on Windows. However, even with the use of a compilation daemon to speed up execution, start up times are slow enough that effective use of Scala in a heavy scripting environment needs something like Nailgun.

As for Scala's disadvantages, take a look at my answer (and other's) in this Stack Overflow question.

Cicily answered 10/7, 2009 at 14:49 Comment(0)
P
16

Scala is an evolving language well worth to invest in, especially if you are coming from Java world. Scala is widely covered at Artima. See this article from Bill Venners and also read about Twitter and Scala.

Regarding your questions:

  • Java can run wherever there is a JVM. No luck with the mobile phones however. You need a full JRE, not the subset that is available there.
  • This is possible with JNI. If something is possible with Java, then it is possible with Scala. Scala can call Java classes.
  • Functional programming is a strong point of Scala - you do need to learn it. However you could also start using it without taking full advantage of it and work your way with it.
  • There is a plug-in of Eclipse. It is not best, but it will do the job. More details here.
  • If you are experienced, I would say really fast. I recommend that you find a book to start with.
  • See this faq entry for deployment.
Petulant answered 10/7, 2009 at 10:43 Comment(1)
One addition: it seems to be possible to run Scala on Android: scala-lang.org/node/160Depredate
A
6

Programming paradigm: I don't feel comfortable with switching to FP at this time. Can I use OO and procedural with some FP at first and then change the proportions as I learn?

Scala has full support for imperative programming, writing programs with no FP elements in it is a breeze (however, FP is useful and worth learning anyway).

Learning speed: considering my experience, how fast do you think that I can reach a workable level with Scala?

Quickly. There is a number of interesting features in Scala that may be not familiar to people coming from a C++, Java environment, like for example some of the features of the typing system. Some argue that the fact that there is a lot to learn in Scala before you know all of it is a problem with the language; I disagree. The presence of those feature is an advantage of the language. The more features the merrier. After all, you don't have to use them all at once, just like you don't have to buy everything that is being sold in the store.

Anett answered 10/7, 2009 at 13:43 Comment(0)
T
5

Learning speed: considering my experience, how fast do you think that I can reach a workable level with Scala?

I also come from a C++ background, one thing I noticed is that since you will write a lot less code as compared to C++ for a comparable task, your learning will be expedited as you will get more done in the same time period. This was the same phenomenon that I experienced with Ruby.

Trudeau answered 10/7, 2009 at 20:19 Comment(0)
R
3

Actually - if I were you - I'd study programming paradigms instead of languages. Of course you have to study an example language to study the paradigm. Knowing the drawbacks & benefits of different paradigms enables you to view your problems from a different side and makes you a better programmer (even in the languages you already know).

Picking up a language of a paradigm already known is a relativly easy task if needed. Since Scala is FP (at least you mentioned it) and C++/Python is OOP, it's a good language for you, I'd say.

Richards answered 10/7, 2009 at 10:46 Comment(0)
A
3

You should register for this course by the Creator of Scala himself.

https://www.coursera.org/course/progfun

Alo answered 10/9, 2012 at 16:6 Comment(0)
W
2

James Strachan (productive Java open source developer, for those not in the loop) has an interesting discussion of Scala here, and why he feels it's a progression from Java (the langauge, not the platform).

Scala looks like it's gaining a lot of traction. I don't think it's a flash in the pan, and is currently on my list of languages to learn (partly for the functional aspect)

Wagstaff answered 10/7, 2009 at 20:21 Comment(0)
S
0

Here's an anecdotal evidence regarding learnability of Scala.

In our company, we got several interns from U.Waterloo. They were told to write in Scala; never saw it before.

They picked up Scala and Lift remarkably fast; now they are producing Scala code; it may be not perfect, but nobody's perfect.

So, the fact that a manager does not know Scala may be not the best argument when you decide on adoption.

Sc answered 6/11, 2011 at 22:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.