archives

Sun's new JavaFX Script language

Sun recently announced JavaFX Script, a new Java-based scripting language designed for use with Sun's nascent rich interactive application development platform, JavaFX. JavaFX Script is statically typed, but it seems heavily influenced by dynamic languages like Python and JavaScript.

JavaFX Script provides an unusual declarative syntax intended to facilitate rapid interface development and it has some interesting features like support for first-class functions and Pythonic list comprehensions. The language also has some really unusual array manipulation operators that are somewhat thought provoking.

Here are a few samples to consider:

var titleTracks =
  select indexof track + 1 from album in albums,
    track in album.tracks where track == album.title;

select n*n from n in [1..100];

function factors(n) {
  return select i from i in [1..n/2] where n % i == 0;
}

x = [1,2,3];
insert 10 as first into x; // yields [10,1,2,3]
insert 6 after x[. == 2]; // yields [10,1,2,6,3]

You can also find some good examples of the declarative interface design syntax in Sun's JavaFX Script tutorial for Swing developers.

-- Ryan Paul

Pickler Combinators

Pickler Combinators, Andrew Kennedy 2004.

The tedium of writing pickling and unpickling functions by hand is relieved using a combinator library similar in spirit to the well-known parser combinators. Picklers for primitive types are combined to support tupling, alternation, recursion, and structure sharing. Code is presented in Haskell; an alternative implementation in ML is discussed.

This is a very pretty functional pearl, which is both useful and illustrates some nice semantic principles.