Scala, a Statically Typed, Functional, O-O Language
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..."
More like FUN-ctional!
... skah-lah not scale-la
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.
When Fascism comes to America, it will call itself Anti-Fascism, and tell you to give up your guns.
If you can create a better wheel, sometimes it makes sense to reinvent the wheel.
But if all you're doing is reinventing Perl with C-like syntax, it's not really a step forward.
A Perl Server Pages technology that was scalable and didn't require the interpreter to load on every access would make Scala obsolete in a New York minute.
"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...
Scala is so kawaii! ^_^
Scala is great, but one really annoying thing about it is that it inherits type erasure 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 - 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#).
... 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...Hmmmm, maybe I should switch my company's programming language to Scalia. After all, it cause market share to increase, computer systems to become more stable, and maybe it will make my hair grow back. I'm in!
Different tools for different jobs.
That being said, does anyone know of a good comparison of languages broken down by what they're best at doing? How does one decide what the best language for what they want to do is? My google-fu is weak today. I found this: popular programming languages; but the analysis seems lacking.
What does that even mean?
Shameless plug alert: Game server control panel
Back at university I somehow dodged functional programming. I knew functional programming was and is an important concept, but besides an excursion to Prolog and some SQL I never went outside imperative and/or object-oriented programming. I never wanted to learn Lisp or Scheme, Haskell seemed to much for mathematicians back then. Scala intrigued me enough to give functional programming a try again. It's object-oriented, has generics, is strongly typed, but has a powerful inference systems, so declaring things is not too tedious. Java classes and packages can be used within. It has not only builtins for concurrency but also for parallelism. However, it was the functional programming paradigm opened my eyes, what I was missing yet.
...had Martin Odersky in for an interview a while back.
It's good stuff; se-radio isn't afraid to get down in the weeds with the interviewee.
The Army reading list
FTA: actors in Scala are not a language feature, they have been done purely as a Scala library
So:
1. There will be no useful compiler warnings/errors for the feature, since compilers implement only the core languuage.
2. Even if the library code will be 100% bug free, you'll still have to drag a debugger though it when debugging a hard bug in nearby code.
3. The library's API will never acheive the self-consistency of the core language because of too many cooks spoiling the broth.
4. The library will be massively overfeatured, but still not do what you actually want.
5. The library will change more frequently than core langage, meaning nothing will compile in the real world without hacks.
6. The library designer will hypnotise the core language designer and impose his own stupid ideas on the core language.
7. (6.) will lead to the entropy death of the language; people will simply stop paying attention to new versions.
Seriously, we should be figuring out a minimal subset of concurrancy features that really *can* go into a core language, with compiler support, debugger support, good consistency (like the while loop which does the same thing in all languages) etc.
Then libraries can implement endless semantic sugar/bullet-point fluff on top of the core features, since that's what libraries are good at.
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
"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?
Martin Odersky is beardless, Scala is doomed.
crazy dynamite monkey
Scala on Scales?
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.
sic transit gloria mundi
Comment removed based on user account deletion
If you think Scala is good, then check out the Fan programming language!
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).
Another next biggest thing for the "guys in Mom's basement" crowd.
Learn C#, Java, C++ or VB.Net. Get a job.
Learn {obscure fad language of the month created by college students who don't have to make money}, stay unemployed.
It's either about money or masturbation guys. Learn the difference.
Please do not read this sig. Thank you.
I have no idea how hard is should be, but remember, each time Scoble farts, twitter has to handle 93,000 messages.
Nerd rage is the funniest rage.
Given the number of reported "fail whale" incidents (if I'm naming them correctly), apparently it's really, REALLY hard to do. Or at least for the people who did it...
Bit I'm not a Twitter-er. I have an account and I occasionally read news blurbs on it, but I have yet to post anything on it.
"This post contains words, known to the State of California to cause thought. Wash brain thoroughly after reading."
Umm... I think we were doing this a long time ago in Lisp with CLOS (and flavors).
In a band? Use WheresTheGig for free.
It seems sort of pointless to have another language that runs on top of the Java JVM. You still have all the Java baggage, plus a new language with its own baggage.
Scala is heavy on "cute" features. Wow, you can define your own infix operators! Mixins! Traits! Lots of overriding and overloading! Heavy "extensibility". You can beat the language into letting you write parser rules in Scala.
The trouble with overdoing language extensibility is that someone else may have to fix the "extended" code.
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?
--- I do not moderate.
a language that can be used in many different ways will result in code that will be a JOY to maintain and debug.
Privacy is terrorism.
Even if it was a brain fart it's quite funny. Thanks for making me laugh.
I have not only seen the book but also read it (assuming you mean Programming in Scala). 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, I do not have to extend that.
Too loud and screechy. and silly costumes
The academic idiots, who rarely write big programs have been proselytizing strongly typed languages for 37 years, since Martin Richards devised BCPL so he did not have to teach fortran at MIT.
Put simply, the problem is in the semantics, not syntax/slips, and LISP, Perl and OCaml are far more useful than C++, Java and C#. If you need raw speed use C+Assembler, else use something you feel comfortable to write and debug quickly. Strong typing helps _only_ weak programmers, the rest of us either (a) remember the types of our variables or (b) expect "1" + "2" -> 3, not "12".
We have enough languages, but _not_ enough competent developers, and we will not find them in India or SE Asia.
It depends on which language you use. A lot of people blame Twitters early problems on Rails, which has notorious scaling issues.
//Angry Ruby fanboy comments start below
ad logicam Claiming a proposition is false because it was presented as the conclusion of a fallacious argument.
"I hate computer languages because they force me to learn a bunch of shit that are completely irrelevant to what I want to use them for. When I design an application, I just want to build it. I don't want to have to use a complex language to describe my intentions to a compiler. Here is what I want to do: I want to look into my bag of components, pick out the ones that I need and snap them together, and that's it! That's all I want to do." Quoted from Why I Hate All Programming Languages.
Functional languages are worse because they are painfully counterintuitive. I don't want to write a function if all I want to do is link a sensor directly to an effector. Drawing a line from A to B is an order of magnitude simpler. Which is the way it should be.
>> , the rest of us either (a) remember the types of our variables
1) Strong typing helps compilers and processors, not programmers. A weak programmer wouldn't understand the value of a strongly typed language.
2) Any developer who says he 'remembers the types of our variables' is either lying, or inexperienced. You may remember it today, a week from today, or perhaps even a month. You will not in a year. Nobody who looks at your code will 'instantly know' unless you name your variables 'thisIsAnUnsignedInt32', which, would be pretty silly.
3) SE Asia and India produce many fine programmers (FYI, I'm a caucasian american, so no favoritism.). because of the lower prices of programmers from India and SE Asia you're statistically likely to see _more_ of them, hence more bad programmers.
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.
The only people who blamed it on ruby/rails where twitter people. Now, ruby does have scaling problems. But twitter's problems were on the backend, where there is no rails. The problem is/was their message queue was poorly designed.
...it sounds like an absolute mess for anybody but the guy who wrote the code.
All you need to code Twitter is any language that can wrap SQL....
Add tweet: INSERT TABLE x (x) VALUES (@x, @userId)
Retrieve tweets: SELECT * FROM x WHERE UserId = @userId
I do respect some aspects of Scala, but using Twitter as a mark of success is worse than Hello World.
Brilliant! ;-)
The summary reminded me of this:
http://www.willamette.edu/~fruehr/haskell/evolution.html
But I can't say that I'm not Haskell "biased". After all I tasted "her". And this resembles the experience best:
http://www.xent.com/pipermail/fork/Week-of-Mon-20070219/044101.html
Any sufficiently advanced intelligence is indistinguishable from stupidity.
SatanicPuppy wrote...
:-)
> Perl is weakly typed on a lot of things,
> but it's static for data structures and subroutines.
> So you can have a hash of hashes, or an array of arrays,
> but you can't get arrays in your hashes or vice versa.
Bad puppy
I would like to mod that post '-1 good intentions w/ignorance'.
Thank you, bsDaemon.
It is worth looking at the code in bsDaemon's link.
For all the jokes about perl code being read-only,
this is really pretty clear:
--- begin excerpt ---
Answer: How do I make a hash of arrays?
contributed by chromatic
my %dramatis_personae = (
humans => [ 'hamnet', 'shakespeare', 'robyn', ],
faeries => [ 'oberon', 'titania', 'puck', ],
other => [ 'morpheus, lord of dreams' ],
);
Access it like this:
foreach my $group (keys %dramatis_personae) {
print "The members of $group are\n";
foreach (@{$dramatis_personae{$group}}) {
print "\t$_\n";
}
}
--- end excerpt ---
(I'm guessing 'Hamnet' is a typo).
Anyway...
There are other ways to do this in perl, but the *intention*
should be pretty clear.
Just for fun, does anybody here have a corresponding Scala example?
Scala team loves to bring up high-traffic sites (Twitter, LinkedIn) as examples of how scalable Scala the language is.
In reality, what scales on those deployments so nicely is the Java VM which is Scala's runtime. Nothing to do with the language per se. Choice of programming language may have an effect on programmer productivity but in this case nothing to do with runtime scalability.
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.
I see, Scala is not ScalaScript