DEV Community

Discussion on: What makes you want to stick with a programming language?

polentino911 profile image
Diego Casella • Edited on

Reasons why I moved, a now am happily sticking, to Scala:

  • easy to understand for people with knowledge of Java/C++ like me;
  • compiles down to java bytecode, aka it runs on any machine with a JVM;
    • which means you can freely mix any Java/Scala library, and it just works (in my company for example, we're using Spring + other java libs);

  • lean syntax for variables/methods declaration, even leaner with respect to generics cough C++ and Java cough (0);

  • but still, it's statically typed: it's just that Scala's type inference is so good that you can omit most of the type declarations (still, for a public facing API you'd better explicitly define the types!). And I really wonder why people would throw away such beautiful mechanism to check if "can this variable be passed to that method?" at compile time, instead of having unexpected errors at runtime;

  • you can choose whether to program in functional style, or good'n old object oriented way, or mix the two as you wish (0);

  • REPL to the rescue if you have to implement/check something quick (0);

  • again, functional programming style! The moment you get the hang of it, you'll realize how immutable data plus data manipulation function definition will make your code much more robust than hiding complex state behind an object;

  • no more NPEs: stop returning nulls and use Option instead. If you're dealing with Java libraries that do return null, wrap the result into an Option (0);

  • powerful, compact and typed pattern matching that would otherwise translate in many nested levels of Java if(){} statements

  • case classes to model data in a one liner, instead of POJOs that spans tens of lines

  • traits and mixins

(0) yes, yes, Java 8/9 did catch up a bit, even though it's doesn't feel as intuitive and simple as Scala. And keep in mind, most of those features were already available since day zero Scala (2004).

17cupsofcoffee profile image
Joe Clay Author

I definitely want to check out Scala (and Kotlin, for that matter) at some point! I write Java all day at work, and while I quite like the JVM as a platform the actual language itself just feels really... heavy, for lack of a better word. Not my least favourite, by any means, but if there's languages that would give me the same upsides but feel less clunky I'm all for it :)

polentino911 profile image
Diego Casella

Yes, I think it's worth it :)
And quite honestly, after reading so many positive articles about Kotlin, if I were to decide between Scala and Kotlin today, I'd give a go to the latter.
Have fun() !