archives

The Mezzo programming language

I saw a link to the Mezzo programming language on Hacker News, and I came here to see what had already been discussed. To my surprise there seems to be hardly a mention about it. So I figured I'd post and perhaps stir up a discussion.

According to the Mezzo website the language has been formalized in Coq and is:

... a programming language in the ML tradition, which places strong emphasis on the control of aliasing and access to mutable memory. A balance between simplicity and expressiveness is achieved by marrying a static discipline of permissions and a dynamic mechanism of adoption and abandon.

The TechEmpower Web Framework Benchmarks

I'd like to draw attention to the TechEmpower Web Framework Benchmarks, which compare solutions to simple web programming tasks in different programming languages and frameworks. For now, the formal comparison is entirely about performance, in particular throughput and latency. I believe the long-term plan is to expand to include measures of code complexity, memory usage, and other good stuff.

Eric Easley and I contributed a solution in Ur/Web, a statically typed, purely functional DSL. It's managing to compete pretty well, despite a configuration error that should be fixed for the next round. You, too, can contribute to future rounds! I think it would be great to see languages further outside the mainstream represented!

On the functional programming front, there are already solutions in Erlang, Haskell, and Racket, as well as more "mainstreamed" hybrid languages like Clojure and Scala. Other popular scrappy newcomers include D, Dart, and Go. I think Ur/Web is the most avant-garde language currently represented, and I challenge LtUers to one-up us on that front!

Value-level programming

I was very inspired by the post Scrap your type classes by Gabriel Gonzalez, where he proposes to pass around explicit dictionaries instead of defining instances of type classes. That leads to a distinct style of programming that we may call "value-level programming", where you avoid using any kind of type-directed dispatch and instead pass values around.

To show some examples of that style, I wrote a couple blog posts translating generic algorithms from the C++ STL into Java. Where the C++ version uses implicit concepts like "forward iterator" that the types must satisfy, I pass around explicit objects describing these concepts, while keeping the type parameters completely generic. That way you can e.g. use built-in Integers as iterators. The only features used are Java interfaces and basic generics (no type bounds, etc.)

In the first post, I do a line by-line translation of the STL algorithm std::partition into Java, in a way that works on both Java's built-in arrays and arbitrary user-defined containers. In the second post, I explore a technique to simulate template specialization from C++, like using a more efficient version of an algorithm when a forward iterator is actually a random access iterator, and demonstrate it with a translation of std::advance.

A nice programming language feature to support that style could be something like Agda's instance arguments, to avoid passing around explicit dictionaries all the time. Another related idea can be found in Oleg Kiselyov's delimcc library, where "throwing" and "catching" a specific exception uses a specific value as a point of communication, instead of using the exception's type. It's interesting to translate programming idioms from "type-level" to "value-level" in this way, because it often makes things simpler and more first-class.

What do you think?