Intersting post on Perl 6 type subsets and multiple dispatch

I recently read a blog post by Alex Miller about Clojure multi-methods.

It described and answered a question his friend had asked him, as well as discussing some related problems. I'm going to showcase the different options Perl 6 provides for solving these same problems. Here's the initial question:

Is it possible to write a multimethod that has defmethods which handle ranges of values? For example, say that a person has an age. Can I write a multimethod that accepts a person as a parameter and returns "child" if age < 16, "adult" if 16 <= age < 66 and "senior" if age >= 66?

As in Clojure, the answer is "Sure." In keeping with TIMTOWDI, Perl 6 provides several ways to do this.

This post does a rather good job of covering some of the new features in Perl 6 in a very readable way.

Interesting blog post on the Oracle Google thing by Charles Nutter

As you've probably heard by now, Oracle has decided to file suit against Google, claiming multiple counts of infringement against Java or JVM patents and copyrights they acquired when they assimilated Sun Microsystems this past year. Since I'm unlikely to keep my mouth shut about even trivial matters, something this big obviously requires at least a couple thousand words.

It's long, but he has some interesting thoughts and a decent amount of background that I wasn't necessarily aware of. It's nice that he lists all of the patents, too.

Anyone have recommendations for a good book on HTML/JS/CSS?

I've been deep in the bowels of the backend of web applications for years, but I haven't done anything on the frontend side in years. Since I acquired a webOS based phone, I'm finding that my biggest problem is not having a deep enough understanding of modern web development and how to get the layout I want. I also have ideas that I think might be fun to implement as web applications, but my lack of knowledge about the frontend technology is a problem. Does anyone know of a good book on the topic? Not a nutshell reference, but more in the vein of things like "The C Programming Language" or "Programming Perl".

Tail Call Optimization Decorator in Python

This function decorates a function with tail call optimization. It does this by throwing an exception if it is it's own grandparent, and catching such exceptions to fake the tail call optimization.

Sometimes I wonder why a whole bunch of Scheme loving folks use Python. Then, I see rather clever things like this, and it starts to make more sense. I do wonder how much of a performance penalty something like this incurs, though.

Fun with constants in Java

The following code does not compile:

public class A {
public static void main(String[] args) {
int i = Integer.parseInt(args[0]);
switch (i) {
case X: System.out.println("ONE!"); break;
case Y: System.out.println("TWO!"); break;
default: System.out.println("ZERO!"); break;
}
}
public static final int X = B.getNumber("X");
public static final int Y = B.getNumber("Y");
}

class B {
public static int getNumber(String s) {
if (s.equals("X")) {
return 1;
}
else if (s.equals("Y")) {
return 2;
}
else {
return 0;
}
}
}

The compile error is:

A.java:5: constant expression required
case X: System.out.println("ONE!"); break;
^
A.java:6: constant expression required
case Y: System.out.println("TWO!"); break;
^
2 errors

I think I'll leave explaining why as an exercise for the reader. (Or for a future post. ;-)

Potion Language

Potion is an object- and mixin-oriented (traits) language.

_why's been working on a new top secret project. Wish I had more time to play with all the neat languages out there. This one seems to have a lot of neat ideas.

Interesting talk on Scala


 
A good high level overview of a lot of the neat features and idomatic ways to do things in Scala. It would be nice if he went more indepth on some things, but I found it generally informative, and it's enough information that one could easily look up more detail in the documentation.
 
(Via the Scala blog)

Rawr: JRuby application packaging tool

Rawr, a packaging and deployment tool, is all you'll ever need for your JRuby projects. With Rawr, a simple, pre-generated configuration file turns your code into an executable jar, a .exe for Windows, and a .app for OS X.

It's kinda like Shoes in that it gives you an exe for Windows, an app for OS X, and a jar that you can use everywhere else. Cool stuff.

JRuby lead developer expounds on useful JVM flags

I probably start up a JVM a thousand times a day. Test runs, benchmark runs, bug confirmation, API exploration, or running actual apps. And in many of these runs, I use various JVM switches to tweak performance or investigate runtime metrics. Here's a short list of my favorite JVM switches (note these are Hotspot/OpenJDK/SunJDK switches, and may or may not work on yours. Apple JVM is basically the same, so these work).

If you write any serious Java at all, I highly recommend that you click the link above and read his post. It is full of many amazing gems that I can see being really useful for optimizing and debugging Java applications.

Rhodes framework - Open Source Ruby based Smartphone development

The Rhodes framework is an open source Ruby-based platform for building locally executing, device-optimized mobile applications. It is similar in concept to MVC frameworks such as Rails, Merb and Camping but much lighter weight (and hence executable on a mobile device) than any of these. Along the way of course, we had to implement Ruby for these device operating systems (iPhone, Windows Mobile, RIM and Symbian).

In general, developer productivity is much higher in Rhodes than writing to diverse native device operating systems and APIs since most of your UI customization can be done in HTML templates (ERB files). Rhodes also provides access to native device capabilities such as GPS and PIM data via an extended set of tags (e.g. <geolocation/>).

These applications are also optimized for interacting with hosted enterprise app (SaaS) backends . That is,  it allows mobile applications to work offline with synced local data by embedding a client for RhoSync. The Rhodes source tree contains sample apps for SugarCRM, Siebel Field Service and Ligthouse.

Rhodes is available for iPhone, Windows Mobile, Research in Motion (BlackBerry) and Symbian smartphones. Support for Android devices will be available by end of February 2009.

I just found out about Rhodes, and it looks crazy cool. While I don't currently have a smart enough phone to play with it myself, maybe they'll eventually make it so the thing can target J2ME. (Or, I'll end up getting a smart phone). Regardless, the idea of writing phone applications in Ruby (or another dynamic language) has lots of charm for me, and I've been idly contemplating implementing a interpreter for some small language so that I can do just that on my phone.

In related news, I got to play with my friend's developer G1 this past weekend, and I like. I'm pleasantly surprised at the size and how well it feels. Perhaps I'll get one in a year or so. (And maybe I'll end up with version 2 at that point. ;)