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 Anonymous Coward on Tuesday August 18, 2009 @02:56PM (#29109577)

    "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"

    Have you ever bothered to look what the Twitter site does - there is virtually nothing to it. To argue that any language that is behind it is a testament to that language is ridiculous. The bigger question is how could they get any language to unstable for such a trivial set of functionality?

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

    by glwtta ( 532858 ) on Tuesday August 18, 2009 @03: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 @03: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.

  • by Anonymous Coward on Tuesday August 18, 2009 @03:34PM (#29110125)

    "To this day, many C programmers believe that 'strong typing' just means pounding extra hard on the keyboard." --Peter van der Linden, Expert C Programming.

  • by helixcode123 ( 514493 ) on Tuesday August 18, 2009 @03:35PM (#29110139) Homepage Journal

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

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

    by JAlexoi ( 1085785 ) on Tuesday August 18, 2009 @03: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.

  • by juuri ( 7678 ) on Tuesday August 18, 2009 @03: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 slartibart ( 669913 ) on Tuesday August 18, 2009 @04: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.

  • Sold on Scala (Score:4, Interesting)

    by mcpotato ( 1620433 ) on Tuesday August 18, 2009 @04: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.

  • by Ichoran ( 106539 ) on Tuesday August 18, 2009 @04:34PM (#29111045)

    Those supposedly cute features are there for a reason--they make abnormally clean and maintainable code possible.

    The best Scala code I've seen is clearer (to an outside observer) than the best Java code could possibly be, since the language features allow you to focus more on what is going on rather than necessary theatrics.

    The worst Scala code is, admittedly, worse than the worst Java code could possibly be.

    So, if I had programmers who wrote nice clean code, I'd encourage them to use Scala. If I had programmers who wrote ugly tangled code, I'd force them to use Java.

  • Re:Oooooooohhhh.... (Score:3, Interesting)

    by PylonHead ( 61401 ) on Tuesday August 18, 2009 @05:17PM (#29111561) Homepage Journal

    No question that anyone who wants to make a living programming probably needs to learn a business safe language like the ones you mention.

    Still, some of us really enjoy programming, even when we aren't making a buck off it. Working with a new language can make you think about programming in a new way, and can teach you lessons that you can bring back to your day to day business work.

    Let's not forget how fun masturbation can be!

  • by SL Baur ( 19540 ) <steve@xemacs.org> on Tuesday August 18, 2009 @10:24PM (#29114125) Homepage Journal

    I don't mean to sound pedantic, or borish, but C is actually "yeah baby yeah" typed, to enable pointer arithmetic, stack space exhaustion, buffer overflows, and system level development. It's not incorrect to say that it is weakly typed, per se. It's just awkward having to try to explain the direct parallels between the C type system and a 70s style love-in (where anything goes) -- to your manager.

    I hear where you're coming from, brother /.er.

    I'm rather amazed at what work has been done in the Linux kernel regarding moving the code towards the static typing model with innovations in C and GCC extensions. Much of the Linux kernel *can* be statically type checked.

    I am *so* hoping that Linus writes the Mythical Penguin Month as Fred Brooks did for O/S 360 the 3nd most important O/S, but most important at the time. For all his sometimes abrasive writing style, he has done something I didn't think could not be done. Well more than one something.

  • by Ichoran ( 106539 ) on Wednesday August 19, 2009 @11:56AM (#29119789)

    The JVM scales nicely, but you can load stuff on top of it that makes it not scale nicely.

    That the Scala folks were careful to let the JVM scale nicely is a credit to them.

    (Plus, the scalability also refers to the types of modularity that are available--Scala allows good practice in that area also.)

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

    by TheNarrator ( 200498 ) on Wednesday August 19, 2009 @12:20PM (#29120141)
    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 more advanced features. While working on a toy web app in the excellent Lift web framework, I found that as I applied Scala features my code kept getting smaller and smaller. It was kind of fun to see how small I could get it as I piled on more language features. I actually found myself quite amused at the power of the language.
  • No thank you (Score:2, Interesting)

    by ZmeiGorynych ( 1229722 ) on Wednesday August 19, 2009 @12:24PM (#29120203)
    Erm, I can't think of _any_ situation in applied programming where C++ is a good idea (I design medium to high frequency automated trading algos for a major bank, well run a small team that does that). 90% of the time something like jython or matlab is fast enough and a hell of a lot easier to write and debug, and doesn't give you nearly the amount of options to cut your limbs off by chance - and the 10% of performance bottlenecks can be handled by C/Fortran snippets.

    I am aware that many coders seem to think the very messiness of C++ (several languages crunched into one, but not really in a consistent or compatible manner) is somehow an advantage (trying to call C++ DLLs from other languages, oh my god what a pain, tripled if you want it to work on both windows and Linux), but I'd rather fill my brain with domain-specific knowledge and not with language-specific trivia (eg valarray copy semantics are not compatible with STL, but the code using vector<valarray<> > only actually breaks under gcc and works under VC++; and so on and so forth - why the fuck should I care?).

    I was in the "C++ is great" camp for a couple of years and filled my head with all those stupid quirks (local typedefs in recursive templated classes, oh what fun) , but at one point realized I just couldn't be bothered. Even Java, as crippled as it is language-wise, is IMO preferable to C++, because once it compiles, you can just use the jar, no linker issues, no memory corruption - and if I do need to manage my memory in a bottleneck, a C snippet will do just fine.

    And if I can keep using the JVM but one day switch from Java to a less crippled language, maybe Scala, that's the best of all worlds.

"If I do not want others to quote me, I do not speak." -- Phil Wayne

Working...