Catch up on stories from the past week (and beyond) at the Slashdot story archive


Forgot your password?
Java Programming

Ask Slashdot: Should I Move From Java To Scala? 245

"Scala is one of the JVM languages that manages to maintain a hip and professional vibe at the same time," writes long-time Slashdot reader Qbertino -- building up to a big question: One reason for this probably being that Scala was built by people who knew what they were doing. It has been around for a few years now in a mature form and I got curious about it a few years back. My question to the Slashdot community: Is getting into Scala worthwhile from a practical/industry standpoint or is it better to just stick with Java? Have you done larger, continuous multi-year, multi-man and mission-critical applications in Scala and what are your experiences?
The original submission asks two related questions. First, "Do you have to be a CS/math genius to make sense of Scala and use it correctly?" But more importantly, "Is Scala there to stay wherever it is deployed and used in real-world scenarios, or are there pitfalls and cracks showing up that would deter you from using Scala once again?" So share your experiences and answers in the comments. Would you recommend moving from Java to Scala?
This discussion has been archived. No new comments can be posted.

Ask Slashdot: Should I Move From Java To Scala?

Comments Filter:
  • Twitter and Scala (Score:5, Informative)

    by ebrandsberg ( 75344 ) on Saturday April 08, 2017 @05:03PM (#54199357)

    Quote "I can't answer that, but I did attend lately a session by Raffi Krikorian, who was VP Platform Engineering at Twitter and one of the people responsible for introducing scala at Twitter.

    He was asked about scala, and said that if he would have to choose again today, he's not sure he would go with scala.

    The argument was that scala introduces a big learning curve for new developers. Because of its complicated language features it can become hard to read. So at Twitter they are trying to not overuse the complexities of the language, so the main benefit they get from it are lambdas. Which is now basically available with Java 8. So the overhead of developer training might not be worth the benefit."

    • by 1 a bee ( 817783 ) on Saturday April 08, 2017 @06:04PM (#54199553)
      Agree. Coded in Scala. A large language -- makes C++ look tame, by comparison. Which in turn makes many 3rd party libs harder to read. Java 8 (look at Streams) offers many similar features in a smaller language that's easier to communicate. Learn Scala? Of course. But don't dive into its depths. We must all budget our time.
    • This isn't necessarily an argument against Scala, using it well will have it's challenges, but this is true for most languages. Linkedin went through the same.
      Some of the tradeoff's Twitter has had to make have changed. They moved away from Ruby, and for Ruby developers, Scala might actually have been easier to pickup than someone who has been doing Java since 1.4. You have to unlearn more OO practices to use Scala well, but you can write very rubyish or pythonic code in Scala. If I look at a project like f

    • Re:Twitter and Scala (Score:5, Informative)

      by atrizzah ( 532135 ) on Saturday April 08, 2017 @07:48PM (#54199923)

      And yet, read the other answer [] on that same Quora page.

      I would also add that the opinion of an Engineering VP at Twitter might take into account a whole bunch of things that aren't applicable to the dev who is trying to decide whether learning a language is worthwhile to them. Those are two very different points of view, with very different considerations. I love working in Scala, but if I were building a team of probably over 100 engineers, I might think twice.

      Also keep in mind that Twitter was one of the very early adopters of Scala. They lived through growing pains in the ecosystem that newcomers to the language will never have to encounter.

      Scala has a learning curve, no doubt about it. Its design tends to emphasize features that are very general. You put in some extra effort upfront, but you get more mileage in the long run. Scala also has a very rich ecosystem of libraries that may approach the same problems with different philosophies. Some find the amount of choice paralyzing. It's a bit reminiscent of the React ecosystem. But I think I speak for many Scala fans when I say that it feels very rewarding and empowering as a programmer to work with.

      Intellectual benefits aside, I've also found it to be a language for getting things done. My small team launched a mission-critical distributed system in 6 months [], with me as the only veteran Scala programmer. I give a lot of credit to the extremely robust ecosystem of libraries around Scala -- especially Lightbend's Akka and Slick. A lot of ready-made tech mapped very nicely to our problem domain, and we were off to the races. The documentation is great and there's lots of support available.

      My advice for the OP: take the Coursera course and/or give the Red Book [] a spin. You'll likely be challenged but also you may find it to be very intellectually stimulating.

    • by HiThere ( 15173 )

      FWIW, it's my understanding that Scala strongly emphasizes immutable data, so unless that's suitable to your use case it may be a poor choice. And if it *is* suitable, then you should give Erlang a look.

      OTOH, it you want to interface with a lot of Java code, it may be a reasonable option.

    • The argument was that scala introduces a big learning curve for new developers

      If that is the problem, use PHP instead. Or BASIC.

  • by cheesybagel ( 670288 ) on Saturday April 08, 2017 @05:04PM (#54199361)

    Then figure out for yourself if you like it or not. If you're going at this from a PHB perspective just stick with Java.

  • Rust (Score:4, Insightful)

    by 110010001000 ( 697113 ) on Saturday April 08, 2017 @05:10PM (#54199387) Homepage Journal
    You should switch to Rust. No wait, Swift, er no, Ruby, er no. Don't worry about the flavor of the year language.
    • by Pulzar ( 81031 )

      You should switch to Rust. No wait, Swift, er no, Ruby, er no. Don't worry about the flavor of the year language.

      I hear you about Rust, maybe... but Scala, Ruby, and Swift aren't pretty far from "flavour of the year" languages.

      • by asylumx ( 881307 )

        I hear you about Rust, maybe... but Scala, Ruby, and Swift aren't pretty far from "flavour of the year" languages.

        If you did mean this as written, then I just don't get your point.

        If you meant are pretty far I disagree with you. 'Flavor of the year' is a figure of speech meaning they are a fad, and indication is that GP is very correct about a lot of these. Ruby is already yesterday's news, with the MEAN stack and even newer ideas taking its place. Swyft is very new and replaces Objective-C with a C#/

        • instead to learn what skills make a great developer. It's not what language they know, because that can be learned quickly.

          I agree to an extent, though the stumbling block is the equivalent of vocabulary - knowing all the standard libs and what they do.

          However HR do not. If they want you to have 23 years experience with it then "I know something similar, I'm sure I could pick it up" just won't fly. Bastards.

        • by Pulzar ( 81031 )

          If you meant are pretty far I disagree with you. 'Flavor of the year' is a figure of speech meaning they are a fad, and indication is that GP is very correct about a lot of these. Ruby is already yesterday's news, with the MEAN stack and even newer ideas taking its place. Swyft is very new and replaces Objective-C with a C#/Java-like language, which begs the question why don't we just use those?

          Yeah, that was a typo, I meant "are pretty far".

          I don't know how Ruby can be included in the list of "fad" langua

    • All languages that don't run on a JVM (well, Swift does, there is a cross compiler).
      You know that, so why post such bullocks?

      Quite often it makes sense to learn the flavour of the year language. E.g. Swift. Just to broaden/extent your horizon.

    • Or worry about every language - to the point of setting up whatever dev environment and doing a few simple things like hello world, fizzbuzz, create deck of cards, shuffle, and deal a few cards, etc. Just enough to learn how to use the tool chain, basic syntax, user interaction, etc.

  • Yes. (Score:3, Informative)

    by Just Some Guy ( 3352 ) <> on Saturday April 08, 2017 @05:14PM (#54199405) Homepage Journal
    I don't have a strong opinion about Scala, but the answer to questions in the form of "should I Move from Java to _____?" is almost always "yes" (for values of _____ not including PHP, VB*, or other asininities).
    • ... the answer to questions in the form of "should I Move from Java to _____?" is almost always "yes"

      The reason being? As others will have pointed out, Java is used in incredibly many places - Android apps, Java application servers even in Oracle databases. IBM mainframes even have dedicated Java CPUs as an option. In short, there are loads of career opportunities that expect you to code Java.

      And the language as such is easy to learn - if you have learned C, you are almost there. The downside of Java is that it has been taken over by standards for absolutely everything computers do; but the upside is that

  • by NEDHead ( 1651195 ) on Saturday April 08, 2017 @05:32PM (#54199453)

    I don't know where Scala is, but Java sounds like a nice place to live.

  • For a specific project - look at the ecosystem of libraries and tools, and what you want to accomplish. One project might be easier in java, another in scala.

    For a career - look at jobs in your area. Are more people hiring for java or scala? You can learn both of course. Rust is also worth looking into.

    But scala is just a language. You don't need to be "math genius" to use one language over another.
  • by Anonymous Coward on Saturday April 08, 2017 @05:49PM (#54199511)

    I have a PhD in CS and have coded in many many languages.

    Difficult: Yes, I find that is the most difficult language I've ever coded in, but I really enjoy it. The difficulty mainly has to do with the type system, the compiler, and what I call Shiny thing syndrome (STS). When first learning I found occasional surprised in assignments because I had the same types on the left and right hand side, but did not. When examining the types, one would observe a page describing it. This can cause frustration for the novice. The compiler messages and the documentation have both improved immensely in recent years, so this is not as bad a problem as it once was, but still, the documentation is not a gentle guide for the initiate to understand the language. Finally, STS. There are some aspects of the language that seemed to have been simply shoe-horned in, often syntactically. That is, there are many multiple ways to do the exact same thing and all where shoved in because they exist that way and were a shiny thing in some other language. This hurts the language in my opinion.

    Enjoyment. I find that when I am coding in Java or other languages I miss features of scala. I have grown to prefer scala over java, which I didn't initially think that I would. I find that I can write a lot of code for 30 minutes in Java or I can sit on my hands looking at the screen for 25 minutes and write for 5 minutes a beautiful piece of code that does the same thing with Scala. The code has an elegance and beauty to it. Actually I don't think I stair at the screen all that long anymore but switching to functional was initially quite the paradigm shift for this old fart.

    Consequences ( Scala is not without its issues):
    1) The difficulty of the language makes it very difficult to be productive with novice coders on your team. Don't do it.
    2) Some aspects of the language: e.g. Macros, implicit parameters, implicit types, can make for elegant code, but can also make your code look like magic that will baffle your (less than stellar) team member. Use with caution.
    3) You will think different after mastering it, that is a good thing. Nothing special about scala, you should learn new languages frequently for this reason.Scala will help you.
    4) Don't do it because it is a hot new language, don't do it because you think it will solve a problem better than another or you'll make more money, do it because you love to code and you want to explore using a new tool set. Do it for the fun. I enjoy coding in Scala much more than java, and the akka actor framework is great. But you will find many analogues to the actor framework (example go routines, rust channels etc)*, but it all addresses the difficulties of multi-threading, which are somewhat cumbersome and error prone in Java.

    *Yes I know they are different, before you pretentiously lecture me on the difference, please realize that I am comparing not contrasting here. They all have the same goal to approach simplifying life in the multi-threaded environment.

    Anyhow, my advise is pursue learning scala with vigor and wild abandon. I'd also recommend go-lang and rust, they are cool also. After you learn them then decide on the tools that you want to work professionally in. You will not be harmed by the effort.

    • I have a PhD in CS and have coded in many many languages.

      In other words, "I have worked a lot in fake environments in many languages".

      You got a PhD in part because of a language that is controversial, and you consider that a win? The value of a CS PhD just dropped a few points.

      I too have coded in many different languages. Tcl/Tk was painful, but doable. Javascript was painful and not doable. Sed, awk, bash,various assembler, C,, C++, Java, Perl, Python is a subset of languages I've coded in.

      Never used Scalia, probably never will. I'm old, odds are

      • You got a PhD in part because of a language that is controversial, and you consider that a win?

        I'm sorry, in what part of his post did he say that?

        • by dbIII ( 701233 )
          S'not actually in the post but he nose.

          It's projection. He feels he needs to exert dominance and show that he is better than people with doctorates which is kind of entirely pointless due to different people working on different things.
          • He gave you some sense as to why he's experienced in this area. You can choose to believe it or not; you can listen to his opinion or not. Responding snottily, to things he didn't say, seems like a less than optimal choice. Put another way, I got a lot more interesting info from his post than from your retort.
            • by dbIII ( 701233 )
              First - there was an extremely obvious attempt at a joke (which you appear to have taken seriously and appear to require it to contain information) hence the "Responding snottily".
              Second - how can you get any more snotty than putting down all doctorates as working in fake environments? I really do not see how that does anything other than reflect on the person who is trying to devalue the work of a vast number of others while blowing their own trumpet.
      • In other words, "I have worked a lot in fake environments in many languages".

        Or, to rephrase what you said "I have my head permanently lodged up my arse".

        You're welcome.

  • by iceco2 ( 703132 ) <> on Saturday April 08, 2017 @05:53PM (#54199525)

    Scala has achieved critical mass, it has shown steady growth over the years and will likely continue. It is entirely possible it will never become as big as Java but that should not be the requirement, it is plenty big enough you can count on it.
    I have been developing large scale projects in Scala for the last 6 years and I can't imagine going back to Java now. Scala makes it easy and fun to write good correct code.
    Scala is boilerplate free, it feels a bit like your favorite scripting languages yet with compile safety a powerful type system and lot's of help from IDE.
    Obviously Scala supports Functional Programming which is essential as everything becomes multi threaded and/or distributed. Scala makes it easy to write functional code and is immutable by default, yet it isn't opinionated and you can use other paradigms when they make things easier/faster.
    It's fun to write, you don't have to be a genius to use it, though with weak members on your team you will want a strict style guide. I found using Scala is a selling point when recruiting top talent, even those who never used it. Those who have used it, especially coming from a Java background are instantly hooked.
    This was verified again in recent Stack Overflow developer surveys where Scala came out to be a very loved language, nearly everyone who tries it falls in love.
    I highly recommend

    • If you want to do functional programming there's always JavaScript. [ducks]
    • > Scala has achieved critical mass
      No it hasn't. Unless we're talking about in your delusional mind.

      > It is entirely possible it will never become as big as Java
      No it isn't. Unless we're talking about in your delusional mind.

      > Scala is...
      Mostly garbage. Java has everything Scala has and isn't designed by retarded monkeys.

  • by wonkey_monkey ( 2592601 ) on Saturday April 08, 2017 @05:57PM (#54199535) Homepage

    If you want to schlep all the way from Indonesia to Italy, sure, why not.

  • Scaling Scala []

    I don't have a particular opinion, other than the common concerns about its performance and resource utilization. But I tend to code at the traces anyway.

  • Probably yes (Score:5, Informative)

    by hibiki_r ( 649814 ) on Saturday April 08, 2017 @06:05PM (#54199557)

    First, background: I have been using Java at work, at least part time, since 2005. I started getting paid to write scala since 2012. I've definitely ran large, critical applications in Scala: I am running some right now.

    Scala is a far more featureful, complicated language than Java is. A lot of what it gives you is really very high quality syntactic sugar (case classes, lambdas, pattern matching), but the one thing that sets it apart is its type system.

    The trick is that nothing forces you to use Scala as if you were using Haskell instead: You can use it as a more sugary Java, using the extra type system fun sparingly. Restraint is the name of the game here, and also the reason some people have Scala horror stories: A company decides that Scala sounds great, and then hire some hotshot scalaz committer to teach everyone else how it's done. Then your codebase is full of operators that look like line noise, every class extends a base that comes straight from category theory, and half the developers say 'screw this, let's rewrite it all in Go!'

    There is value in the category theory, and using arcane libraries like cats or shapeless, but 99% of the time, you don't need to: Just like back in the 90s you had to stop people from overusing OO design patterns, or their code will end up looking like Spring, Scala shops have to remind people to do the same when it comes to higher kinded types, hlists and concepts out of category theory. You really don't need any of that to use Scala successfully. Just ending up in a world where you typically don't need either a mocking library or any dependency injection nonsense is more than enough to switch. (Curse you Rod Johnson!)

    The one thing where I would make people spend some time studying is in basics of functional programming, the very first of which is to learn to remove side effects from code, and clearly separate code that changes state from computation. Chances are you were doing some of that already in Java if you were hoping for a good unit test suite, but it's more important in Scala

    Career wise, the more is a no brainer IMO: If you write Java, you are one in a very large pool of completely generic candidates that can use Spring and Hibernate to do something super boring. In Sala, you enter a smaller pool that most of the most average Java developers will never try to enter, so, on average, the job will be more interesting, and the pay will be higher.

  • by PPH ( 736903 ) on Saturday April 08, 2017 @06:22PM (#54199601)

    Choose one.

  • by Moochman ( 54872 ) on Saturday April 08, 2017 @06:55PM (#54199711)
    Having used plenty of Java in big-ish teams over the years - and mind you, having never used any other JVM languages beyond simple tutorials or scripts - I can imagine that Scala's learning curve might present a problem. Kotlin, on the other hand (as far as I can tell from my admittedly limited experience) adopts many of the best syntax features of alternatives like Scala and Groovy while keeping things simple enough for pretty much any existing Java developer to use right away. On top of that it does not introduce any new APIs or concepts like actors to get a grip on - as such cross-compatibility with existing Java code is 100% out of the box (this was of course a big factor for the JetBrains folks who are using it to develop the future of their IDE platform). And even though Java 8 is a huge advance in terms of functional programming support, it feels like a more natural fit in Kotlin. Essentially I think Kotlin is something like "Java 2.0", or what Java could be if they were willing to throw backwards compatibility out the window. :) At the same time it's dead simple to learn in its entirety in a short period of time, as opposed to Scala's huge feature set and learning curve. Scala may be the "better" language overall, but Kotlin seems like the more practical choice, especially for teams that have no Scala experience as of yet.
    • Kotlin is an important language and deserves consideration. As the parent stated, it is very much like what Java 2.0 should be.
    • Well to correct your Groovy statement... all Java code can convert to Groovy with 100% compatibility; change any Java class extension from '.java' to '.groovy' and it compiles 100% of the time. That because Groovy is just a layer of convenience code on top of Java. Scala attempts to REWRITE Java and thus causes an incompatibility with Java and Java libraries.
  • The bitter lesson I've learned over the years is that the larger the team, the simpler the tool set and the less clever the implementation must be.

    And it makes sense. You pretty much have to target the 10th percentile programmer in your organization or your going to have your systems ruined over time.

    In a small organization, you can probably hire selectively enough that your 10th percentile programmer can handle Scala. In a large organization (like Twitter is now), not so much.

  • by Foofoobar ( 318279 ) on Saturday April 08, 2017 @08:05PM (#54199989)
    With all the Scala hype, people neglect to point out that Scala is NOT compatible with Java; alot of libraries and tools have to be rewritten to work with Scala. This is why LinkedIn dumped Scala, Spring dumped its Scala adaptation and more and more companies are dumping Scala. And for all its hype on 'functional programming', you can do the EXACT same thing in Java and Groovy with 100% compatibility. In fact, every Java class converts 100% to Groovy; take any Java class and change the '.java' extension to '.groovy' and it will compile without issue. The same CANNOT BE SAID OF SCALA! This is because it is not compatible with Java and requires Java rewrites in order to be compatible.
    • In fact, every Java class converts 100% to Groovy; take any Java class and change the '.java' extension to '.groovy' and it will compile without issue.
      That is not necessarily true.
      E.g. if you have attributes with "default" access and a getter or setter it will not compile.

      Regarding this: people neglect to point out that Scala is NOT compatible with Java; what do you mean with that? Java code calls Scala code and vice versa without problems, but I don't use Scala intensively enough.

      This is because it is not

  • maintain a hip and professional vibe

    Since *when* has being "hip" been an attribute, much less a desirable one, of a competent language? The only friggin' professionals who speak in those terms are marketers.

  • There are a zillion fad languages out there. Each (presumably) excels at something, but most languages that are not in widespread general use will usually suck at anything outside the core competency of that language. Second-tier languages also have smaller communities developing tools and components, making them less desirable. Finally, if you ever need to hire programmers, you seriously limit your pool of available candidates if you lock yourself into a language that is not in widespread use.

    My advice:

  • by corporate zombie ( 218482 ) on Sunday April 09, 2017 @12:33AM (#54200765)

    1) Do you need a degree or to dive into the math to make effective use of the language? No. Like any programming language you can just learn the patterns and apply them. That said, like any programming language, if you learn the math behind why it works you can make more effective use of the language. (You are probably using monoids, functors, monads, and maybe applicative functors in any large program. Not knowing what those are doesn't mean you aren't using them.)

    2) Would I recommend switching?

    I having been programming professionally for 31 years. I have been programming Scala since 2010. I have taught about a dozen people the language. Much like, "Should I quite my day job to put all my time into my startup?", the answer is probably, "not right now". If you can get the same or better pay, under the same or better conditions, then obviously yes, make the switch. Otherwise if the language interests you (same answer for the startup) then work on it in your spare time with your day job giving you the security you need to expand your horizons. As a programmer learning new languages will make you a better programmer. Learning languages like Scala or Haskell which lean so heavily into functional programming and their higher-kinded type systems will definitely expand your knowledge. Additionally you'll then be able to decide if a switch is worth it FOR YOU rather than relying on getting a useful answer from a infinite number of monkeys banging on an infinite number of keyboards.

    All that said no company would pay the price I would demand to code in Java again.

  • I got stuck maintaining a bunch of Scala code at one point, and I'd say "no thanks." Why?

    The code wasn't any more error-free than any other code, but it was an order of magnitude more difficult to maintain. It also didn't seem to speed up the development process any; the devs were just as late as they were without Scala.

    Scala developers are also expensive and hard to find, two things that make finding a "Scala maintainer" a difficult task.

    Unless you're willing to invest in supporting it, I'd say no. If you

    • by cowdung ( 702933 )

      You bring up a good point.

      At the end of the day maintainability is very important in a software system. For many systems I'd say its more important than initial productivity.

      Many features in the language is not as important. In fact, I'm a big fan of one of the most feature free languages ever: Smalltalk.

      So Java has the advantage of being more predictable and more maintainable.
      My big gripe is some of the crazy frameworks you have to deal with.

  • No question there's a learning curve, but you don't have to be a genius to learn Scala and use it effectively. Is Scala there to stay? Yes. I've used it successfully at TraceLink, Inc and CiBO Technologies, Inc and am a big fan. Scala is richer and more expressive than Java and eliminates annoyances like checked exceptions. The key is the principal of minimum power (use the smallest hammer that gets the job done) and some consistency in style across the team. If people go meta-nuts with advanced language fe

  • by allo ( 1728082 )


  • Should i dress white or black today? Should i wear a fancy shirt or a hoodie when going to work?

    So no, unless you have a really compelling reason (like: the project i am currently doing sucks in java and would be very nice in scala), stay with what you know.

Civilization, as we know it, will end sometime this evening. See SYSNOTE tomorrow for more information.