The Whiley language takes an unusual approaching to static typing called flow typing. This helps to give Whiley the look-and-feel of a dynamically typed language. The key idea behind flow typing is to allow variables to have different types at different points in a program. For example, consider the following code written in a . . . → Read More: Formalising Flow Typing with Union, Intersection and Negation Types

Groovy 2.0 has just been released, and it contains something rather interesting … optional flow typing! For those who don’t know much about the language, Groovy is a JVM-based dynamically typed language which is similar to Java, but more compact. And, being dynamically typed means that there’s no need for any cumbersome type declarations.

The Whiley language splits into a fully functional “core” and an imperative “outer layer”. References and objects do not exist within the functional core. However, they can exist within the imperative outer layer and are necessary for supporting state and other side-effecting computation. Here’s a simple example:

A friend of mine was talking about how variable scoping for try-catch blocks in Java really frustrated him sometimes. Specifically, the problem was related to variables declared inside try blocks not being visible in their catch handlers. The example would go something like this:

Whiley uses flow typing to give it the look-and-feel of a dynamically typed language (see this page for more on flow typing). In short, flow typing means that variables can have different types at different program points. For example: