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.
"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.
Like mod_perl ?
What does that even mean?
Shameless plug alert: Game server control panel
You mean like Mason? Possibly you're looking for something more like Catalyst?
These things have been available for Perl for a long time.
But if all you're doing is reinventing Perl with C-like syntax, it's not really a step forward.
Perl already has C-like syntax. It doesn't, however, have static type checking, let alone robust static type checking (with nice features like variance annotation etc.); nor does it have particularly robust functional programming support -- you can certainly do functional programming in Perl, but it isn't as clean and syntactically sugared as it could be; nor does perl have particularly clean OO if we're being honest -- yes it works and can be made to work quite well, but elegant isn't a word that comes to mind when I think Perl and OO; nor does Perl have function pattern matching and algebraic data types; nor does Perl have a nice concurrent programming interface based on the Actor model. None of this is really to say that Perl is bad -- it is very good for a great many things, and the features I've mentioned needn't hold it back. My point is that Scala is most certainly not re-inventing Perl. In fact Scala doesn't even have a particularly C-like syntax: it's less C-like than Perl really.
Craft Beer Programming T-shirts
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
My point is that Scala is most certainly not re-inventing Perl.
True, it also doesn't appear to be a reimplementation of anything. It's somewhat related to Java (Scala programs execute with the JVM).
The code snippets on the website http://www.scala-lang.org/ are intriguing. It's certainly a terse language. That's both good and bad.
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).
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."
already has C-like syntax
Why not use the C instead then, or even better C++. After all many top websites run C++ (Google,eBay,Yahoo) as it is the fastest, well memory utilizing, best threading performance and green/CPU saving solution. With the native processor exceptions used properly it is also the most robust solution.
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.
Sounds like someone is bitter about not having much choice in their life. You probably don't have any hobbies, either, since your employer wouldn't approve. Have fun tilling the land for your lord. The rest of us will be making real money for ourselves, out-competing your boss because of productivity gains from using decent tools, as opposed to whatever tools your boss thinks are the cheapest to teach monkeys to use.
Enjoy your job. Maybe if you're a good, your employer will give you a 1% raise next year? As long as it doesn't cut into executive bonuses, that is.
Next biggest thing for the "guys with a job" crowd.
Learn some other language that isn't C#, Java, C++, VB.NET, or in fact particularly related.
Specifically, learn something with functional programming, or a different sort of object orientation (Common Lisp comes to mind, or Smalltalk or Objective-C), or declarative programming (like Prolog)...anything that's considerably different from any of the standard compiled OO languages.
Learn and improve, or don't learn and become unable to earn a living in the field.
"When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
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.
Ummm. No.
Been both self-employed and employed by others in life. Plenty of choices. Most are lousy economic dead-ends (Gee! I think I'll learn Modula-2!). Recognizing this is highly adaptive. Ignoring it, highly maladaptive.
Note: If the best engineering always won, would we all be using (ugh) Windows?
I repeat, Software is about money or masturbation. Learn the difference.
Please do not read this sig. Thank you.
I agree. Why learn the languages that 60% of all new code is written in when you can learn the latest niche language that barely accounts for .3% of all new code written and will probably be forgotten when Twitter rewrites itself in the newest and greatest flavor of the month in a couple of years. Clearly the GP is the stupid one in this.
Source: http://www.tiobe.com/content/paperinfo/tpci/index.html
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
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!
# (/.);;
- : float -> float -> float =
Yes, but understand that, when you're learning that language, you're doing it to expand your mind and development toolkit, *not* to add said language to the list you put on your resume, as the very fact it's niche means no one will care.
And by "development toolkit", I mean things like design patterns and approaches to software construction. Take Haskell, for example. Compared to a typical imperative language, it requires a *very* different mindset when constructing applications. But the lessons you learn (higher-order functional programming, function composition as a form of abstraction, etc) are powerful tools which can be utilized in other languages, and learning them will force you to re-think how you build software, which is a very good thing.
Touche'
Not bad if it's understood that it's the commonly practiced entertainment/educational activity noted earlier (Not that there's anything wrong with that!).
Please do not read this sig. Thank you.
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.
You assume that the only reason to learn something is to make money with it. Which is a rather depressing worldview, really.
"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.
IIRC it was originally intended to be able to use the JVM or Microsoft's CLR; they just finished the JVM version first and that's what's being promoted.
Terseness is largely irrelevant. The right question is not "does this language let me express something in the minimal number of keypresses", but rather "does this language force me to repeat myself endlessly".
Scala has good support for abstracting code; Java, for example, does not. That means that code written in Scala could well be more maintainable (changes need to be made in fewer places), and it also means it's likely to be better quality (people are less likely to copy and paste if it's just as easy to do it properly).
I ran into this just today. I had a bunch of copy-and-pasted code that I was trying to refactor into a sane design, and Java thwarted me at every step. I could see why the original coder had given up! Eventually I had to resort to a hack using reflection, which of course lost me all the benefits of static typing. Thanks, Java. But at least the core algorithm is now stored in exactly one place, instead of there being ten copies of it scattered across as many files.
>> , 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.
There, fixed that for you.
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".
As a programmer with 25 years of experience, I could hardly disagree more. When developing any large project, static typing is hugely beneficial. It lets you catch far, far more errors at compile time. In a dynamic language, those would all be runtime errors that could easily slip through your testing and make it out to a customer. It makes automated refactoring possible. (Ever try doing a major restructuring of a 500k line code base written in a dynamic language? Good luck!) It enables all sorts of static analyses that let you be a more productive programmer. Try using a really good Java IDE like Intellij IDEA, then try the best Python or Ruby editor available, and you'll feel like you've gone back to the stone age. No "Find Usages"? No autocompletion? No "Go to Definition"? You simply can't do these things in a dynamic language, because the editor has no idea what the type of any variable is.
This isn't meant to criticize dynamic languages. They definitely have their place. But 90% of the symbols in most programs should be statically typed. I don't see why more languages don't simply offer both options. In those that do (e.g. Groovy), type declarations are simply optional. If you declare a type, it gets checked at compile time. If you don't, that symbol becomes dynamically typed. It works very well.
"I'm too busy to research this and form an educated opinion, but I do have time to tell everyone my uninformed opinion."
Maybe you should check out RubyMine from ..., oh no, the same Intellij people
Sounds like you have accumulated a bit of baggage in those 25 years.
As to Perl's object model, I couldn't agree more. However, from CPAN you can get Moose and MooseX which really clean things up a lot and hide the nasty bits. For instance, with MooseX::Declare, the following is now valid Perl:
use MooseX::Declare;
class Car {
has make => (isa => "Str", is => rw"); # setting a member... they are in a hash type of thing
#some simple methods
method set_make (Str $make) {
$self->{"make"} = $make;
}
method return_make {
return $self->{"make"};
}
I just learned about the MooseX stuff yesterday, so of course my example isn't anything super, but as you can see, it's pretty god damned simple comapred to the alternative.
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.
LISP, Perl and OCaml are far more useful than C++, Java and C#
Let's see:
I'm not sure what point you're trying to make, but it doesn't seem to have anything to do with either strong typing or static typing.
The academic idiots,
That's as opposed to the non-academic idiots, who apparently don't even know what "strong typing" means.
Try the more advanced languages. Once you have strong typing you can have variables that are of types like:
function of a string, int and a char to a string and then when you apply a char to it the system knows you now have a function of type string and int to string.
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.
yes, the similarity is immediately obvious
--BF code for hello world removed because i was unable to get it past the junk filter. (http://www.roesler-ac.de/wolfram/hello.htm)
# Hello world in perl
print "Hello World!\n";
Reminds me of the adage:
Terseness is largely irrelevant. The right question is not "does this language let me express something in the minimal number of keypresses", but rather "does this language force me to repeat myself endlessly".
I did not mean "terseness" to be a pejorative. Length of code can sometimes and sometimes not be of assistance to the poor bastards maintaining it after the original developer has gone.
It's my fate in my career that I have been primarily maintaining other people's code and personally, I have an easier time reading small snippets of code in small functions than the multi-K lines of deeply nested if-else/etc. that certain coders prefer.
That was actually a dig on the four-letter P-word which can be compressed into incomprehensibilty.
The stuff I saw on the Scala website looked quite nice and terseness and reducing repetition appears to be one of their stated goals. I applaud them for that. Any time you have enforced repetition, maintenance costs go up regardless of how strict or sane the development environment is.
I need to rewrite a bunch of super-crap CGI code from scratch and I was planning on looking at something Scheme-ish to see if that would work (the core code I would like reuse is all in Emacs Lisp). I do plan on looking deeper into Scala before I propose anything because the Java tie-in might be easier for me to handle politically.
...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.
Not much for professionalism, are you? I can say with about 99% certainty that the fact that you know Haskell will have absolutely no effect on your career. The fact that you learned it will have a large effect on how well you can turn problems into programs.
The only stable asset you have is you. If you don't improve yourself, you'll get left behind, and in ten years you'll be working on legacy C# systems and not getting paid as much as the people working on the interesting stuff in whatever language is new and hot next decade.
I've watched small computer development be dominated by BASIC, Pascal, C, C++, Java, and C# (with a lot of Visual Basic thrown in). I have absolutely no reason to suspect it all stops here. Learn or die.
"When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
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.
It is pretty hard to see how Perl relates to Scala.
Scala has static types for a start.
Scala does not just enable functional programming and OO, it assumes you want to use those, and burdens the language with tools to push you in those directions.
Perl hardly pushes you anywhere.
For example Scala has ways two different keywords to create identifiers, one that allows rebinding, and a standard, *functional* one, which does not.
C++ is only the backend language for at least two of the sites you mentioned. Yahoo runs mainly on PHP hence Rasmus working there and Google, though I can't speak to what extent they use it felt it was in their best interest to bring on the creator of python.
Does this sig remind you of Agatha Christie?
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.
But if all you're doing is reinventing Perl with C-like syntax, it's not really a step forward.
Any change to Perl's syntax is a step forward.
(No idea what this has to do with Scala, though.)
The code snippets on the website http://www.scala-lang.org/ are intriguing. It's certainly a terse language. That's both good and bad.
Terse is mostly good, as long as it doesn't come at the cost of readability (see Perl for an example of that). Scala, while being about as terse as Ruby, doesn't seem to be quite as readable, unfortunately. But maybe the code snippets I've looked at aren't the best examples.
If C++ was well suited to web application development, it would be a very common choice for websites. Instead, Google, Ebay, and Yahoo need the performance it offers for their high volume websites. Most smaller volume websites and many of the competing high volume websites are willing to skip the performance of C++ for the faster development time and easier maintenance from using other languages.
For server side applications, the ability to move applications from Windows to Linux to BSD is nice. Scala gives you that while C++ requires a recompile for each platform with a mess of #ifdef and Make options.
Scala has tuples, traits (similar to Ruby mixins, and a very nice solution to Java's lack of multiple inheritance and C++'s multiple inheritance headaches), cases classes that are far more powerful than the C++ switch or other similar C++ constructs (or at least, all of the ones I've encountered), functional language constructs (which in many cases use compile-time tail call optimization to keep run time performance acceptable), and the ability to easily import and use existing Java APIs and libraries and run on existing Java servlet containers. Check out the Scala web development platform lift ( http://liftweb.net/ ) - the example website has a staggering number of features for such a tiny codebase.
Hey, I'd love to program for fun. But I have to put food on the table. The honeymoon I had with Java is long over, but since I'm making twice as much as I did as a C developer, I'm going to stay with it.
If I could find a company local that would pay me as much, or nearly as much, to work on Scala or Haskell, I would jump ship in a hurry. Until then, I'm not going anywhere.
Ruby can be made a lot more terse than Scala can but at that point it's quite difficult to read. I've tried to match the terseness of a number of very compact Ruby programs in Scala and I'm lucky to get within 50%.
At the same level of terseness (maximum Scala terseness, comfortable Ruby terseness), Ruby is easier to read unless you're much more familiar with Scala than Ruby. (Stuff like _._2 < _ in Scala takes a while to figure out, and even when you've got it it takes a bit of thinking.)
At a comfortable level in both languages, I find Scala easier to read but less terse--the key being mostly Scala's descriptive inline operators.
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.
Thanks! I'd mod you informative if I could.
At a comfortable level in both languages, I find Scala easier to read but less terse--the key being mostly Scala's descriptive inline operators.
That's probably the correct level of abstraction to think about it. Repeated sequences of anything are going to be mind numbing. Shorter sequences are going to be easier to grasp at first sight. But only on average and the 4-letter P-word has certainly proved that very short code isn't necessarily readable or maintainable.
My Perl colleagues are swooning at Moose. It certainly seems like something to take note of, if you're into that sort of thing (Perl, that is).
xkcd is not in the sudoers file. This incident will be reported.
Funny thing.. Java, or actually the JVM, with hotspot, is faster than c in many instances. And, you know Scala runs on the JVM.. So uh, ok great.
I know.
http://www.kichwa.com/quik_ref/spec_variables.html
http://www.perl.com/doc/manual/html/pod/perlop.html
I see, Scala is not ScalaScript
I've read that, aside from startup times, the JVM is extremely fast these days. But I thought most well-written Java (and by extension, Scala) applications are still 2-10 times slower than equivalent C.