Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Scala, a Statically Typed, Functional, O-O Language 299

inkslinger77 notes a Computerworld interview with Martin Odersky on the Scala language, which is getting a lot of attention from its use on high-profile sites such as Twitter and LinkedIn. The strongly typed language is intended to be a usable melding of functional and object-oriented programming techniques. "My co-workers and I spend a lot of time writing code so we wanted to have something that was a joy to program in. That was a very definite goal. We wanted to remove as many of the incantations of traditional high-protocol languages as possible and give Scala great expressiveness so that developers can model things in the ways they want to. ... You can express Scala programs in several ways. You can make them look very much like Java programs which is nice for programmers who start out coming from Java. ... But you can also express Scala programs in a purely functional way and those programs can end up looking quite different from typical Java programs. Often they are much more concise. ... Twitter has been able to sustain phenomenal growth, and it seems with more stability than what they had before the switch, so I think that's a good testament to Scala. ... [W]e are looking at new ways to program multicore processors and other parallel systems. We already have a head start here because Scala has a popular actor system which gives you a high-level way to express concurrency. ... The interesting thing is that actors in Scala are not a language feature, they have been done purely as a Scala library. So they are a good witness to Scala's flexibility..."
This discussion has been archived. No new comments can be posted.

Scala, a Statically Typed, Functional, O-O Language

Comments Filter:
  • by neonprimetime ( 528653 ) on Tuesday August 18, 2009 @01:04PM (#29108765)
    ... skah-lah not scale-la
  • by sycodon ( 149926 ) on Tuesday August 18, 2009 @01:07PM (#29108825)

    Scala Programmers: $35K - $45K

    Our company is looking for motivated individuals with 5 + years in depth experience with Scala.
    Must be familiar with all aspects of O-O Languages.

    We are an equal opportunity employer.

  • "Twitter has been able to sustain phenomenal growth"

    This is my friend FailWhale. You are making FailWhale sad. You wouldn't like FailWhale when he is sad...
    • Re:Eh sonny? (Score:5, Insightful)

      by iluvcapra ( 782887 ) on Tuesday August 18, 2009 @01:25PM (#29109101)
      To be fair, FailWhale has not been seen by me of late, and the Twitter devs attribute their salvation to Scala. However, there are some pretty good arguments that the Twitter developers Mother of All Fail was initially trying to write their own hand-rolled message queue [unlimitednovelty.com] instead of simply using one off-the-shelf.
      • by juuri ( 7678 ) on Tuesday August 18, 2009 @02:56PM (#29110475) Homepage

        Recently I decided to move from contracting to full time work as the job market is balls here in the Bay currently for Contracts. Twitter was one of the companies which I applied and I had the pleasure of having a "phone screen" with them for a senior unix position. Here's what this screen was, a basic unix question, that any lunix user could get. A more intermediate type question that could trick some people. And finally their *BIG SCREEN* a tricky question that was based on esoteric knowledge that had absolutely nothing to do with one's ability to perform the job.

        The person calling me was just reading these off a list, she didn't know why they were picked and was only able to write down the answers. Here's the hilarious part, I informed her that the question was silly and there's no reason anyone should really care about this sort of information except in extreme situations. That this was the question that lead me to believe they had a culture of primadonnas. She diligently wrote all this down, in case they still wanted to talk to me.

        But here's the REAL kicker, their stupid asinine esoteric question? Was wrong. They had the phrasing wrong... what they were asking and looking for in an answer were not the same things. Being a pedantic asshole, in my followup to tell them what I thought of their process I pointed this out. Never heard anything back ;) Wonder if they have fixed their question yet?

        • by MyLongNickName ( 822545 ) on Tuesday August 18, 2009 @03:03PM (#29110557) Journal

          Wow! You sure showed them!

        • Maybe they didn't care about Unix experience, and were primarily testing your personal skills and your ability to hold a pleasant conversation with a non-technical person over the phone.

          Always keep an eye out for the psych test [memory-alpha.org].

          • Re: (Score:3, Insightful)

            by juuri ( 7678 )

            I was completely pleasant with the woman, we joked about the questions in fact. The simple fact was they had a stupid call screen process straight out the egotistical dot.com days, which showed much about the types of "engineers" they like to bring in.

            Thanks for assuming that I was an ass thought. :)

            • Thanks for assuming that I was an ass thought. :)

              You said yourself that you were a ... let me scroll it up here... a "pedantic asshole" who told the interviewer, quite presumptuously, that a question was "silly." Furthermore, completely on the basis of the phrasing of one question, you had concluded that the entire company had a "prima donna" culture.

          • by MaggieL ( 10193 )

            But what if the interviewer was a Zaldan?

        • Re: (Score:3, Insightful)

          they must have some of the old Amazon.com folks there. Amazon was like that. Same type of questions, same type of mistakes in what and how they asked the question except they did it in person. I had the same reaction as you did, told them they were wrong in the specification which led to their answer being an incorrect solution. They got pissed and ended the interview. I caught an early flight back :) Plus people were on call 24x7 and worked hellacious hours for low pay and lots of worthless stock options.
        • by mwvdlee ( 775178 )

          She diligently wrote all this down, in case they still wanted to talk to me.

          Point of case; they never DID want to talk to you again, did they?
          Why employ somebody that considers difficult questions "esoteric knowledge that had absolutely nothing to do with one's ability to perform the job".
          Perhaps that little bit of information is exactly the kind of thing you need to know if you're working on Twitter's systems.
          Or more simply put; "There are no stupid questions, only stupid people".

        • Re: (Score:3, Funny)

          by BitHive ( 578094 )

          Sounds to me like their bozofilter worked perfectly.

  • Type erasure (Score:5, Informative)

    by shutdown -p now ( 807394 ) on Tuesday August 18, 2009 @01:17PM (#29108971) Journal

    Scala is great, but one really annoying thing about it is that it inherits type erasure [safalra.com] implementation of generics from Java. This means that you cannot overload methods on argument with the same generic class with different type parameters, cannot implement the same generic interface with different type parameters on the same class, cannot check whether a class implements a particular generic interface for a given type parameter, etc. They did fix some issues [lamp.epfl.ch] - for example, you can instantiate arrays - but it's still far from perfect.

    I understand the need to match Java's broken model for the sake of interoperability, but surely a better way can be devised for pure Scala code? It's pretty much the only area where Scala noticeably lags behind advanced .NET-hosted languages (such as Nemerle or F#).

    • How do you propose they support this given that Java generics aren't reified? Arrays are, which is why that works.
      • One way to reify type parameters is to make them runtime arguments. For example, let's say we want to reify java.lang.Comparable<T> such that I can write:

        class Foo implements Comparable<Bar>, Comparable<Baz> {
        public int compareTo(Bar bar) { ... }
        public int compareTo(Baz baz) { ... }
        }

        Since interface is actually just one, on JVM level we're stuck with a single compareTo(Object); furthermore, there's no way to do instanceof checking.

        For instanceof, we can just do the same th

        • by pjt33 ( 739471 )

          Ah, my comment just down the page didn't take into account that you want to use the full Java standard libraries. However, it still seems to me that you're projecting deficiences of the Java language onto the Java VM to some extent. You write:

          Since interface is actually just one, on JVM level we're stuck with a single compareTo(Object)

          It's more complicated than that. If Foo implements Comparable then Foo.class will contain methods

          public int compareTo(Bar bar) {...}
          public int compareTo(Object obj) {return compareTo((Bar)bar);}

          The latter is a Miranda method or synthetic method generated by the comp

    • Re:Type erasure (Score:4, Informative)

      by pjt33 ( 739471 ) on Tuesday August 18, 2009 @03:35PM (#29111059)

      The third of your listed limitations is semi-bogus: you can't check generic type information with instanceof, but java.lang.Class.getGenericInterfaces gives you the information you need if you're prepared to write a method to process it.

      I can't help feeling that the first two can be worked around too if you're prepared to be more creative with your Miranda methods than javac.

      • The limitations are all bogus; the point is that it should be Scala compiler that's doing all the jumping through hoops, and without telling me, too. I should just be able to write code in a straightforward way, same as I can on .NET (where it's the VM itself that's doing all the dirty work).

  • ...had Martin Odersky in for an interview a while back [se-radio.net].

    It's good stuff; se-radio isn't afraid to get down in the weeds with the interviewee.

  • Scala is a joy... (Score:5, Informative)

    by sitarlo ( 792966 ) on Tuesday August 18, 2009 @01:52PM (#29109529)
    Probably the most robust JVM compatible language to date. Even the creater of Groovy digs Scala: http://macstrac.blogspot.com/2009/04/scala-as-long-term-replacement-for.html [blogspot.com]
  • Doomed (Score:5, Funny)

    by decipher_saint ( 72686 ) * on Tuesday August 18, 2009 @01:58PM (#29109603)

    Martin Odersky is beardless, Scala is doomed.

  • Scala on Scales?
  • Not sold on Scala (Score:4, Interesting)

    by glwtta ( 532858 ) on Tuesday August 18, 2009 @02:02PM (#29109657) Homepage
    Am I the only one not terribly enamored with Scala? It's a massive language (have you seen the book?), but a lot of the syntax is somewhat redundant and doesn't seem to add that much. The type system is downright byzantine, and the Java interface is, let's say, somewhat inelegant. And the whole object-functional thing seems like a paradigm in search of an audience (maybe I'm just not getting it).

    And you get to pay for all this with a huge performance hit.

    I guess their "more is more" approach is mostly making Clojure look more attractive.
    • Re:Not sold on Scala (Score:4, Interesting)

      by shutdown -p now ( 807394 ) on Tuesday August 18, 2009 @02:34PM (#29110113) Journal

      Am I the only one not terribly enamored with Scala? It's a massive language (have you seen the book?), but a lot of the syntax is somewhat redundant and doesn't seem to add that much. The type system is downright byzantine, and the Java interface is, let's say, somewhat inelegant.

      I've read the book. Yes, it's fairly complicated, but then all languages tend to become that as they move from academia or design-by-committee stage into real world - witness Java. In terms of power, however, it's one of the most advanced languages today which can be used in production... and yet it's statically typed, which is a plus in my book.

      And the whole object-functional thing seems like a paradigm in search of an audience (maybe I'm just not getting it).

      You probably aren't. It's been a big thing in .NET land ever since C# 3.0 appeared, and grows even bigger now with F#. It's a pragmatic approach - it gives you both OO and FP tools, and lets you mix and match freely to get the optimal balance for the task at hand.

      And you get to pay for all this with a huge performance hit.

      I guess their "more is more" approach is mostly making Clojure look more attractive.

      Funny how you speak about performance hit, and then immediately mention Clojure...

      Anyway, where did you see the "huge" perf hit there? Examples? It's still JVM bytecode, remember, and it's statically typed, so in the end it's mostly normal Java method invocations all around. It has to fall back on reflection for some things that JVM simply doesn't support otherwise, but those are corner cases, not normal operation.

    • Re:Not sold on Scala (Score:4, Interesting)

      by JAlexoi ( 1085785 ) on Tuesday August 18, 2009 @02:41PM (#29110235) Homepage

      whole object-functional thing seems like a paradigm in search of an audience

      Ah, young grasshopper. You are not aware of the mixed paradigm programming languages then. See OCaml, that is object/function oriented lang.

      And you get to pay for all this with a huge performance hit.

      That is definitely an overstatement. The performance hit is not huge, it's not even big.

      Now, if you want a language with truely different syntax, try erlang.

    • Sold on Scala (Score:4, Interesting)

      by mcpotato ( 1620433 ) on Tuesday August 18, 2009 @03:32PM (#29111027)

      I have not only seen the book but also read it (assuming you mean Programming in Scala [artima.com]). It is very well written and gets you started with Scala easily.

      I do not agree that the syntax is redundant. To the contrary: an important part of the language design is that Scala enables the programmer to extend the language using libraries. A good example is the way collections and iteration work in Scala vs. the way the foreach loop has been added in Java 5.

      Whether static type systems help or hinder depends on whether you work with or agaist it, and on the kind of programs you write. The Scala type system is rather advanced (in the sense of complete) such that it allows you to express more in the type system than other languages do.

      For Java style programming Scala is just much simpler and shorter to write. When you have written some code in both you can appreciate the way Scala works.

      There has already been a comment on multi-paradigm programming [slashdot.org], I do not have to extend that.

    • Re: (Score:3, Interesting)

      by TheNarrator ( 200498 )
      I just finished reading Programming In Scala. Yes, it's a big language. There is a lot going on for sure. Extractors, Case Classes, Pattern Matching, Implicit Functions, just to name a few. Reading about scala can be a bit overwhelming. I had to really get my hands dirty with a small project before I really was able to understand and appreciate all the features and how they work together. The fun thing about Scala though is that one can start out programming in a Java style and slowly incorporate its
  • Comment removed based on user account deletion
  • by jma05 ( 897351 ) on Tuesday August 18, 2009 @02:22PM (#29109929)

    I could use an alternative programming language for the JVM that is more expressive than Java. Both Scala and Groovy integrate well with Java at the language level, albeit with different type systems. While I do use Groovy from time to time, what kept me from Scala was that it is not well supported by IDEs (Eclipse/Netbeans - I hear things are somewhat better with IntelliJ). The problem is the nature of Java libraries. They tend to be deeply nested and often expressed in lower level abstractions and are difficult to use without strong IDE support. I don't need an IDE for Python (flat module systems, high level libraries), but certainly do for Java. With solid IDE support however, I am nearly as productive in Eclipse + Java as with dynamic languages, even for medium apps. Scala and Groovy come with their own standard libraries and I don't need IDE support as long as I stay within them. But sooner or later, I will need to step into plain Java land and I no longer feel productive. I would rather use straight Java for them.

    The development experience is language + tools, not just the language. While Scala can piggy back on JVM and undercut the rest of the process that languages need to go through to mature and be accepted, Scala plugin (or someone else) has to provide a JDT equivalent first to have popular appeal.

    I just wish there was a well supported superset of Java with productivity considerations that maintains 1:1 byte-code compatibility on compilation. Java purists can keep their language clean. But the rest of us can be happy too. Scala has that potential.... almost. So far, Groovy has been filling that role for me. Groovy will never have the kind of edit-time IDE intelligence simply due to it's dynamic nature. But for now, it stands ahead (after all, it has been around longer).

    • I like Groovy, it's java-like and scratches some of my biggest itches about java.

      However I like Clojure better. It's hard for me to resist the power of a lisp, with a full macro system, *and* full java interop. To me it's the only JVM language that stands out, Scala and Groovy are nice, but I don't see why they are any better or different than JRuby or Jython.

      • Groovy is different because it's easy for Java programmers to learn. In fact, most Java devs can understand Groovy code with little or no explanation. That's certainly not the case for JRuby or Jython.

        In any event, I agree Clojure is pretty sweet. However, being a Lisp, it's future is questionable. A lot of devs won't be willing to deal with the brain melting process necessary to grock it.
        • by slartibart ( 669913 ) on Tuesday August 18, 2009 @03:11PM (#29110651)

          Groovy is different because it's easy for Java programmers to learn. In fact, most Java devs can understand Groovy code with little or no explanation. That's certainly not the case for JRuby or Jython. In any event, I agree Clojure is pretty sweet. However, being a Lisp, it's future is questionable. A lot of devs won't be willing to deal with the brain melting process necessary to grock it.

          Yeah I agree with you there. I do use groovy as my "java and then some" language. It looks an awful lot like ruby to me, but yes it's more java-like.

          Its unfortunate about lisp(s) and their popularily, because honestly I don't see what's so difficult about them. Macros are hard, but lisps don't force you to use them. Other languages don't even give you an option, you can't. Paren matching is done by any modern editor. Prefix notation is a bit unintuitive I guess, but that slowed me down for maybe a couple of weeks, about the same as new syntax for almost any language. I am starting to think that "a lot of devs" just don't want to understand it. Or maybe a lot of devs just don't get programming in general, they just learn their one language, and can maybe pick up a few similar ones.

      • by Ichoran ( 106539 )

        Scala is better and different from Groovy and JRuby and Jython in that it is statically typed (but does a fantastic job at hiding all the type nonsense as long as you are doing something sensible). Those of us who make type errors as one of their most common errors really benefit from this. It is also better and different in that it is quite a lot faster than the interpreted languages. (It is worse and different in that a few fancy tricks are impossible, such as method-missing stuff, or generic operation

      • by jma05 ( 897351 )

        I should have mentioned that I did try Clojure. While it is certainly the epitome of dynamic typing and syntactic flexibility for the JVM, I rejected it for the same reasons (no code completion and other validations). Most of the software I choose to write in Java is so because of the specific libraries. Most of code ends up manipulating these libraries, not as my custom logic. If I had a lot of custom logic, I could see value in Clojure (or in Scala as I mentioned in my previous post) where I could use it

    • by Ichoran ( 106539 )

      I've found NetBeans + Java + Scala to not detract at all from NetBeans + Java. So to me, it's a win to add Scala to the mix. It would also be a win to add Groovy or Clojure or Jython or whatever; I just find adding Scala to be the biggest win because the interoperability with Java is easiest (at least in the Java->Scala direction) and because performance is by far the best.

  • Umm... I think we were doing this a long time ago in Lisp with CLOS (and flavors).

  • a language that can be used in many different ways will result in code that will be a JOY to maintain and debug.

  • by speedtux ( 1307149 ) on Tuesday August 18, 2009 @07:07PM (#29113191)

    According to common usage, Python and Scheme are both "strongly typed" as well, since they guarantee that all type errors in programs are detected. This is in contrast to "weakly typed" languages like Perl or K&R C, in which many type errors are silently ignored. That is, all four combinations of strong/weak and static/dynamic typing are possible.

    Some people are using the term "strong typing" as a synonym for "static typing"; I wouldn't really care, except that there is no good other term to describe what "strong typing" means.

    From a practical point of view, it seems pretty clear that "strong typing" (in the first sense) is important, but I have seen little evidence that static typing is all that useful in a general purpose programming language.

    • Re: (Score:3, Insightful)

      ... but I have seen little evidence that static typing is all that useful in a general purpose programming language.

      That is a matter of the way how the mind of a particular developer works.
      I have troubel with dynamic typing, and I hate it to get me my errors shown by runtime when a compiler could have detected that error. Some people don't have this trouble, so they don't need static type checking. Other people develop even the simples script in a test driven development approach and don't need static type

"Why should we subsidize intellectual curiosity?" -Ronald Reagan

Working...