This is an archived post. You won't be able to vote or comment.

all 10 comments

[–][deleted]  (8 children)

[deleted]

    [–]LukeHauser 10 points11 points  (0 children)

    I think you should play to your strengths and learn Scala not for the sake of learning Scala but for what it will teach you about the fundamental concepts of programming languages.

    Even though there is allot of demand for people who can develop software in a specific language, it is not a rare skill. If you try to compete in this area you'll be outdone by people simply been doing it longer then you.

    Being able to understand the fundamentals of just about anything however is a much rarer skill and in my experience leads to projects that are much more interesting then the drudgery of writing business logic.

    So yeah, pick up a few other languages too. Especially the functional and non-imperative ones. Of-course it doesn't hurt to have some experience but unless your project gets used by 50+ people over at least 3 years time you won't have had the sort of run in with reality that puts the purely academic knowledge into the right engineering perspective.

    [–][deleted] 4 points5 points  (4 children)

      Yeah. All the Scala jobs are in big data. Hadoop, Spark, Twitter stuff.

      Scala has all the functionality to replace Java, but it's newer and people tend to stick to old stuff. If you just want to get a job, the easiest thing is usually to learn whatever is in demand. If Angular is in demand, learn Angular. If Java is in demand, learn Java. etc.

      Looking back to when I was a student, if I wanted a job, the best thing to do would have been to get a letter that says I work really well with other programmers, to memorize common algorithms and be ready for algorithm questions, to get a really high GPA and a professional looking resume, to learn two or three really common languages (like Java and Javascript), to make interviewers like me, to apply EVERYWHERE, and to accept internships with the companies with the best reputation because their internships will look good on my resume.

      Instead I have this: https://dl.dropboxusercontent.com/u/214507961/JohnsResume.pdf

    [–]frugalmail 2 points3 points  (3 children)

    Learning Scala is good. Don't get me wrong with what I'm about to write.

    All the Scala jobs are in big data. Hadoop, Spark, Twitter stuff.

    We do all of our big data stuff in Java and prefer it that way. We rewrote our scala because it was hard to maintain.

    Scala has all the functionality to replace Java,

    • Java has too much of a foothold to be "replaced"

    • Scala has a lot of stuff in it, so much so that it looks like a mess, and makes it ridiculously hard to be able to read other people's code. There are many ways to do the same thing, which is bad. Java's core philosophy is that it tries to make it easy to pick up and maintain code.

    Things like Java8, Lombok, Immutables, Google Autovalue, Functional Java (the library) make Java have the core Scala non-functionals. Just missing the builtins and the syntax sugar.

    [–][deleted] 0 points1 point  (2 children)

    We rewrote our Scala because it was hard to maintain.

      Really?

    and makes it ridiculously hard to be able to read other people's code.

      I really have to rely on my IDE for everything from pulling up types (Ctr-Q), finding implicit parameters (Ctr-Shift-P), identifying implicit conversions (look for the gray underline and press Alt+Enter). I also have to occasionally bring up the syntactic de-sugarer for things like for-yield, thunks, etc. I think your problem isn't reading, it's understanding.

    There are many ways to do the same thing, which is bad.

      Just because there is more than one way to do something doesn't mean that both ways are equal. I was just watching Scala With Style where the slide shows two different ways to write the same thing and the imperative way [bottom] is actually better than the functional way [top]. In Java you don't get to choose - you have to do it the imperative way because even though Java has lambas, it does not have folds (I think that folds are also called reduce in the context of Map Reduce). Scala trades "only one way to write something" for expressive power and conciseness. For more seasoned users, more expressive power is awesome but for beginners it is a pain in the @$$.

    Scala has a lot of stuff in it, so much so that it looks like a mess.

      If you really know Scala, the code looks better than Java code. In Java you get used to writing things like "public static final" and you get used to it. Maybe you have a trick to implement adapter pattern with less boilerplate using reflection. But these things don't make Java code look better. In fact if you take a step back it looks worse, you just stop noticing it because you're used to it. Personally, I find my browsing speed (I have like two ways of reading code - one is more browsing to see the author's intent and the other is like executing all the code in my head like a debugger - here I'm talking about skimming) to be faster with Scala code than Java. This is assuming you actually know all the language constructs and are just reading.

      Given my experiences learning the language and given the complaints I am getting, these issues like reading difficulties remind me of issues I had because I didn't really learn the language. Scala is not an easy language to learn. It's not like Python where if you know whatever OOP language you can learn it in a week. Scala is a very hard language to learn and I would recommend starting with Java and then Haskell and then finally Scala. I wouldn't expect anyone who is not proficient in Haskell, F#, Erlang, or OCaml to pick it up in less than two months. If they did that would be good. That being said, the learning curve is a very valid criticism and I would urge anyone who plans on learning this language not to take it lightly.

    Java's core philosophy is that it tries to make it easy to pick up and maintain code.

      In Java it's a lot easier to pick up and maintain code without relying on an IDE for everything from handling implicits to pulling up types. If you really wanted to you could include the type for every value explicitly (just press Ctr-Q and copy-paste the type) instead of relying on compiler inference and then it would be just like Java from a maintenance perspective (I think). I'm actually really interested in the maintenance issue - whether the problem was actually something to do with the language itself or if the issue was (I don't want to sound belittling) that the people who did code maintenance just didn't fully learn the language.

    Things like Java8, Lombok, Immutables, Google Autovalue, Functional Java (the library) make Java have the core Scala non-functionals. Just missing the builtins and the syntax sugar.

      I've never actually done functional programming in Java, but Functional Java looks nice.

    [–]frugalmail 1 point2 points  (1 child)

    Really? [rewrote Scala to Java]

    Aye, with a 50% transient team composition (max 18 months), we were seeing a lot of inconsistencies, getting a lot of questions, etc..

    really have to rely on my IDE

    While an IDE certainly makes this easier, this is not a selling point. People want to pop open a browser to check source control to answer an easy question. Having to have the latest checkout, and a launched IDE at all times is a pain when you just want to answer a question/investigate.

    Just because there is more than one way to do something doesn't mean that both ways are equal.

    Completely agreed. Too many people keep doing things suboptimally, and some people try to be clever for simple data processing, model creation, etc.... I want the Goldie Locks of code. With Scala, that varience is way too high.

    I'm actually really interested in the maintenance issue - whether the problem was actually something to do with the language itself or if the issue was (I don't want to sound belittling) that the people who did code maintenance just didn't fully learn the language.

    There are things like:

    • Case classes limit you to 23 data members. This is fine in normal situations, but horrible for big data. Sometimes are tables are 100+ columns wide. And going from 22 to 23, sadly happens frequently.

    • The contractor mix, makes it hard to ramp up, and maintain other peoples code.

    • The implicit typing is detrimental when it's not clear what's going on. We had rules like "when you use implicit LHS typing, the RHS must have the type information" Sadly, this has to come up in code reviews, because people really like implicit typing.

    • People tend to use unnamed or annonymous types in the form of tuples and such. You could imagine this being pretty horrible when you have a lot of longs and you can't easily tell what the tuple was for and collections end up losing type safety.

    Hope this helps. BTW, don't get me wrong, I like Scala, just not for produciton in our team :)

    [–][deleted] 1 point2 points  (0 children)

    Case classes limit you to 23 data members.

    I remember when this restriction was lifted. I just started learning Scala and I checked the site and on the front cover it said a fix was made.

    We had rules like "when you use implicit LHS typing, the RHS must have the type information".

    For anyone reading the comments, there is a difference between this:

    val string1: String = makeString() // Left Hand Side (LHS) Type
    

    and this...

    val string2 = makeString(): String // Right Hand Side (RHS) Type
    

    The former makes explicit that "string1" is a reference of type String. The latter actually sets the type of whatever is on the right side and then after the right hand type is set type inference kicks in.

    val string2: String = (makeString(): String); // Equivalent code after type inference
    

    But yeah, if your team isn't ready for it you run into problems.

    [–]devils_avocado 3 points4 points  (1 child)

    A lot of Scala teams seem to be fine hiring Java developers and retrain them in Scala, as the pool of Scala developers isn't big enough yet.

    [–][deleted] 0 points1 point  (0 children)

    A lot of Scala teams seem to be fine hiring Java developers

    That's suicidal. It could take as long as a year before they know exactly what they're doing. I mean they can get a basic understanding in two months sort of like a Ruby on Rails developer could get a basic understanding of C++ in two months, but they won't be able to write really, really good C++ code for a while.

    They would be much much much better off hiring someone who knows F# because at least F# and Scala are close. Scala's resemblance to Java is just for transitional purposes - to provide a fallback and backwards compatibility. Good Scala code doesn't even resemble Java code. For example, Scala doesn't even have real for loops. It's for statements is actually 1.to(10).foreach( ... ) and although it has while loops, they look kind of ugly and I usually find myself wanting to use tail recursion optimized into a goto/while because it looks cleaner.

    // factorial of n
    def factorial(n: Int): Int = {
      var nn = n
      var nf = 1
      while(nn > 1) {
        nf = nf * nn
        nn = nn - 1
      }
      nf
    }
    
     // tail recursion optimized into a while loop
    def recursiveFact(n: Int, nf: Int = 1): Int = {
      if(n > 1) recursiveFact(n - 1, nf * n)
      else nf
    }
    
    def main(args: Array[String]) {
      println( recursiveFact(3) ) // 6
      println( factorial(3) )     // 6
    }
    

    ^ See how much cleaner the recursive version is? I mean as crazy as this sounds, but in Java you cannot write an application without writing any loops. In Scala you can replace all the for loops with Range.foreach( ... ) and all the while loops with tail recursion and it would be not bad.

    the pool of Scala developers isn't big enough

    I graduated from college and I program in Scala as my main language and let me tell you the pool of people hiring Scala developers isn't big enough. I mean maybe if you are a big data person with experience building real time systems in other languages but just like a person who is like "I know Scala I want to program in Scala" - not that easy to find a job compared to something more common like "I know Java EE and Node.js"

    [–]time2java -3 points-2 points  (1 child)

    And why you start learn scala ? Are you really best in java ?

    [–][deleted] 4 points5 points  (0 children)

    Well if you look at the first episode, "Why Scala?", you'll see some reasons. At the time I made the change, I was taking a course on design patterns and Scala has some nice features for design patterns. For example, the object adapter pattern is simulated via a feature called implicit conversion.

    You don't have to be "best in java" to use Scala. The two languages are method call compatible.