If you like programming languages here's an interesting interview and discussion on language design and evolution featuring Erik Meijer, Gilad Bracha and Mads Torgersen. I came across the video while googling for Mads Torgersen and his paper "The Expression Problem Revisited." Gilad Bracha I recognized from the Java world and his thoughts on dependency injection with respect to his Newspeak language when I proclaimed that dependency injection is broken. Not sure who Erik Meijer, but he looks really familiar. Basically three really smart guys shooting the shit on languages.
One thing that stuck with me was language purity. Erik mentioned that he really likes languages that are base on one fundamental concept, idea, notion. A language where everything is a function (Haskell). A language were everything is virtual (Newspeak). A language where everything is a message send (Self).
Java is far from pure and singular. Most things are objects, but a few aren't. You can do reflection, but not really. Etc. It then hit me why I've never really liked Java: Java doesn't have a raison d'être. Some people bash Java for its verbosity, or because it lack this feature or that feature, but those things don't really bother me as much as Java's conceptual elegance--lack thereof. It is, by designed, a mix bag, meant for the hoi polloi. And It's quite successful at what it does. Don't get me wrong, I'm not a language zealot. Java is great, with its VM, the available IDEs, the libraries, etc. But it'll always be a Porsche, not a Ferrari (Porsche has always been designed with driveability in mind--the every man's sport car).
So I started thinking about Scala versus Newspeak/Smalltalk. I think part of the reason Scala has been successful is it adopts a less than pure approach--a pragmatic approach. Here's a trivial example (like all trivial examples it could just prove a trivial point). Joey Gibson writes that Scala gets operator overloading right because 2 + 3 * 5 = 17 in Scala but 2 + 3 * 5 = 25 in Smalltalk (and likewise Newspeak). But it's not that Scala gets it right, it's that Scala has chosen a pragmatic approach to operator precedence. If Scala was pure then 2 + 3 * 5 would equal 25, because + and * are just ordinary methods on objects; it'd be like saying method foo has higher precedence than method bar. Smalltalk treats + and * equally because there's nothing special about them and the expression precedence is well-defined at a higher level: unary messages, then binary messages, then keywords.
Pragmatism "wins" in the "real" world. That's why I don't expect Newspeak to gain wide adoption. Worse is better?
The problem with 2 + 3 * 5 = 25 is that it breaks the "principle of least astonishment". Like "The Spanish Inquisition", nobody expects that + and * have the same priority. In Haskell, + and * are function calls, but * still have higher precedence. This is not about purity, but usability of the language.
Posted by: Ricardo Lima | June 23, 2009 at 02:01 PM
@Ricardo - Speaking of least astonishment: http://dcsobral.blogspot.com/2009/06/parser-surprise.html
@Tinou - I share your sentiment. I like Scala's power, but really love Newspeak's purity and elegance. However, I think there's no "right" and "wrong" in this debate because Newspeak and Scala have different targets, and slightly different design philosophies. Gilad Bracha mentioned operator precedence implementation being considered as part of a "skin" (http://gbracha.blogspot.com/2008/09/skinning-newspeak.html) so I don't think it's lack of pragmatism that led to Newspeak design, but rather the observation that convenience opens a slippery slope to confusion, like the link above illustrates. Now, many people may prefer convenience over clarity, so it may be a pragmatic choice if a language aims to quickly become widely popular. But as I already noted, Scala and Newspeak, both being great languages, aren't perusing exactly the same goals.
Yardena.
Posted by: Yardena | June 24, 2009 at 03:03 AM
I disagree. Operators originate in maths, and there operator precedence is a fundermental concept. So the "pure" solution would mean 2 + 3 * 5 = 17.
Purity does not mean applying the same rule everywhere. From a maths perspective, it would be impure to treat operators differently than their defined mathematical meaning.
Posted by: vyadh | June 24, 2009 at 05:13 AM
Please consider that your example really means 2.+(3.*(5)) in Scala since 2, 3 and 5 are not simple data types - Int is a class! This means you are calling a method named "+" or "*" as these are no keywords in Scala. Everything else is just syntactic sugar.
Andreas
Posted by: Andreas | June 24, 2009 at 08:35 AM
In Haskell, which you list on the pure side, the result is 17. Scala's approach to operator precedence is similar (if not based on) Haskell's. So as you say, this is a trivial example. Scala's raison d'être is the bridging of the object and functional worlds on a robust platform, which it does very well.
Posted by: Stephen | July 14, 2009 at 09:50 AM