Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I study Scala? [closed]

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?

like image 480
rpg Avatar asked Jul 10 '09 10:07

rpg


People also ask

Is it worth learning Scala in 2022?

Scala is worth learning in 2022. The demand for Scala developers is high, and the pay is good. LinkedIn currently lists over 24,000 Scala jobs. According to ZipRecruiter, the average Scala developer salary in the United States is $139,292 a year.

Is it worth learning Scala in 2021?

Those who approach Scala as an option for Data Science in 2021 should definitely at the very least be pretty good at writing Python… Of course, this is just my subjective view, but Python is even more likely to get you a job, will have better documentation, and is easier to learn.

How many days it will take to learn Scala?

How long it takes to learn Scala depends on whether you already know Java. If you know Java, it will take you about one month to get the hang of Scala. If you are not familiar with Java, it will take you about two to three months to learn it. Scala has a steep learning curve, according to some software engineers.

Is Scala popularity declining?

Scala's popularity, on the other hand, is starting to decline, driven by long compile times, non-essential complexity in the language, binary and source compatibility problems, the looming threat of obsolesce that is Dotty, brain drain to the Rust and Haskell communities, and fractures in the Scala community that are ...


2 Answers

  • 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.

like image 77
Daniel C. Sobral Avatar answered Oct 01 '22 10:10

Daniel C. Sobral


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.
like image 20
kgiannakakis Avatar answered Oct 01 '22 11:10

kgiannakakis