Mar. 16th, 2009

jducoeur: (Default)
As previously mentioned, I'm starting to play seriously with Scala, the cool new language for the JVM. It's being a lot of fun -- I think it has supplanted Ruby as my favorite programming language to date. It looks as sprawling and messy as Perl, but its complexity is built on top of a more careful language-design basis than most. In particular, one of the neat things about it is that most of the language can be built on top of lower-level constructs.

Here's an example, that struck me last week as especially cool. As with most modern functional languages, pattern-matching is quite important, so you get constructions like this:
def receiveMessage(x:MyMessageType) = x match {
case PING: { print "Got a Ping"; reply Pong; }
case PONG: print "Got Ponged";
}
So far, so ordinary -- on the surface, this looks like a conventional switch statement. But that stuff after "match", in the curly braces? That's actually a first-class type unto itself, called PartialFunction. Given a PartialFunction, you can check what types of things it matches, feed things into it and get return values, constrain its types, and so on. So it's easy to build powerful new operations using the same pattern-match facility.

Almost everything in the language is built this way. The scala-debate mailing list is currently embroiled in an argument about whether to allow "1-legged if" (that is, if without else), with the Java programmers arguing "yes" and the Haskell folks saying "no". And along the way, it's been pointed out that it's only three lines of code to add a "when" expression that has the semantics of 1-legged "if", so who cares? (And three more to add "unless". And only a few more to simply redefine "if" in terms of lower-level operators anyway.)

Which is all very cool, but does drive home the slightly scary part of using it for CommYou: the language is still a wee bit squishy. It's a very serious language, being used for serious apps, but they're still refining some of the details. It's not raw and experimental any more, but it's only about 90% mature at this point. That's not going to stop me from using it, but it does remind me that I'm going to need to be prepared for bits of rewriting down the road. (Fortunately, *most* of the arguments have to do with very high-power stuff to do with types, which matters a lot at the library level but is unlikely to affect my ordinary app code much.)

It's fun, though: I'm now on all the major Scala mailing lists, which are still dominated by the people actually writing the language and environment. I haven't been involved at this level of a fundamental-technology project since the early days of VRML. (And I think this group has more clue than we did in that project, and will come to better results...)
jducoeur: (Default)
As previously mentioned, I'm starting to play seriously with Scala, the cool new language for the JVM. It's being a lot of fun -- I think it has supplanted Ruby as my favorite programming language to date. It looks as sprawling and messy as Perl, but its complexity is built on top of a more careful language-design basis than most. In particular, one of the neat things about it is that most of the language can be built on top of lower-level constructs.

Here's an example, that struck me last week as especially cool. As with most modern functional languages, pattern-matching is quite important, so you get constructions like this:
def receiveMessage(x:MyMessageType) = x match {
case PING: { print "Got a Ping"; reply Pong; }
case PONG: print "Got Ponged";
}
So far, so ordinary -- on the surface, this looks like a conventional switch statement. But that stuff after "match", in the curly braces? That's actually a first-class type unto itself, called PartialFunction. Given a PartialFunction, you can check what types of things it matches, feed things into it and get return values, constrain its types, and so on. So it's easy to build powerful new operations using the same pattern-match facility.

Almost everything in the language is built this way. The scala-debate mailing list is currently embroiled in an argument about whether to allow "1-legged if" (that is, if without else), with the Java programmers arguing "yes" and the Haskell folks saying "no". And along the way, it's been pointed out that it's only three lines of code to add a "when" expression that has the semantics of 1-legged "if", so who cares? (And three more to add "unless". And only a few more to simply redefine "if" in terms of lower-level operators anyway.)

Which is all very cool, but does drive home the slightly scary part of using it for CommYou: the language is still a wee bit squishy. It's a very serious language, being used for serious apps, but they're still refining some of the details. It's not raw and experimental any more, but it's only about 90% mature at this point. That's not going to stop me from using it, but it does remind me that I'm going to need to be prepared for bits of rewriting down the road. (Fortunately, *most* of the arguments have to do with very high-power stuff to do with types, which matters a lot at the library level but is unlikely to affect my ordinary app code much.)

It's fun, though: I'm now on all the major Scala mailing lists, which are still dominated by the people actually writing the language and environment. I haven't been involved at this level of a fundamental-technology project since the early days of VRML. (And I think this group has more clue than we did in that project, and will come to better results...)
jducoeur: (Default)
Thanks to Between the Lines for the pointer to this lovely little video about economics. Okay, it's probably not really from Sesame Street, and it's not in any way accurate.1 But regardless of correctness, it is rather viscerally satisfying...


1 I find most of the "Madoff is Evil Incarnate" hype to miss the point: the scary thing is that I suspect he simply fell into an easy trap of his own making, and that most people, after the first few steps, would have made just the same decisions he did. The thing about pyramid schemes is that they are easy to start, and *very* hard to stop. You get deeper and deeper so fast that all you can do is keep feeding the monster until it eats you. Indeed, it wouldn't surprise me if it started the same way as the Satyam mess: cooking the books just a little to smooth out a glitch, and then covering over each successive layer until all you have left is the fraud...
jducoeur: (Default)
Thanks to Between the Lines for the pointer to this lovely little video about economics. Okay, it's probably not really from Sesame Street, and it's not in any way accurate.1 But regardless of correctness, it is rather viscerally satisfying...


1 I find most of the "Madoff is Evil Incarnate" hype to miss the point: the scary thing is that I suspect he simply fell into an easy trap of his own making, and that most people, after the first few steps, would have made just the same decisions he did. The thing about pyramid schemes is that they are easy to start, and *very* hard to stop. You get deeper and deeper so fast that all you can do is keep feeding the monster until it eats you. Indeed, it wouldn't surprise me if it started the same way as the Satyam mess: cooking the books just a little to smooth out a glitch, and then covering over each successive layer until all you have left is the fraud...
jducoeur: (Default)
For those in the live-combat LARP side of the world, you might be interested in the Ars Technica review of the new Nerf N-Force sword. Summary: unlike their first foray into this space, it sounds like an adequate boffer for the masses...
jducoeur: (Default)
For those in the live-combat LARP side of the world, you might be interested in the Ars Technica review of the new Nerf N-Force sword. Summary: unlike their first foray into this space, it sounds like an adequate boffer for the masses...

Profile

jducoeur: (Default)
jducoeur

June 2025

S M T W T F S
12 34567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags