Yeti – probably the most agile of the statically typed languages on the JVM

Posted on February 24, 2011

6


2 years ago I wanted to learn a new functional language on the the JVM. While I liked the simplicity of Clojure I chose Scala because of its static typechecking. I enjoyed working with scala but was on the latent search for something less baroque but with a good typesystem and typeinference.

And than about a year ago I found by chance a link to yeti: http://linux.ee/~mzz/yeti/intro.html Which was for me exactly the right mixture:

Yeti

  • is a very simple yet powerful functional language
  • is staticly typed with full typeinference and with as little type-typing you can get – if you want so none like in a dynamic languge
  • runs on the JVM and integrates with java

Yeti is simple yet powerful

In Yeti you have to know basicly 4 things:

  • functions: because all code is in functions and invokes functions (there are no classes or objects)
  • values: 3 base types (number, string, unit ) and the composed types (list, array, hash, structure) and their literals ie [“one”,”two”,three”] for a string list
  • how to assign the values to mutable and immutable variables
  • the if-expression and the case expression

If you want to learn the whole language then read the intro http://linux.ee/~mzz/yeti/intro.html Thats one document in a tutorial style which takes you about 2 hours to read and than you know 98 % of the language.

Yeti is also quite pragmatic it is not haskell strict immutable and you can typecast values work with objects etc.

Still yeti is powerful. Like in any functional language you can code in a very elegant concise way things which take much more LOC in a OO language.

Again please take a look at the tutorial I leave here the prove for later posts.

Yeti has a simple but powerful type-system with full typeinference

Any typesystem is a compromise: Either it is powerful and complicated and therefore can check a lot of different code or it is more simple and forbidds certain code which is otherwise perfectly legal. It is ongoing scientific process to find here a good balance.

However for many and for a long time now the ML typesystem und its typeinference alogartihmus is seen as a sweetspot in this compromise.

Yeti implements excatly this sweetspot-typesystem (with a few additions). To my knowledge no other VM-language does this.

The typesystem supports polymorphism (similar to Java Generics), mutable values and arrays with full type-inference.

As long as you don’t use legacy Java code you do not have to write any type in yeti – everything is inferred (you can if you want specify types on function etc for debugging – but you don’t have to).

In yeti you also do not define types. There are no classes, interfaces, traits etc. Yeti is purely structural typed. Every type is composed of the above mentioned basic types. The compiler inferece from your useage of values what you want and checks wheter you provide the right thing.

If your functions needs a structure with a field “swim” holding a function than the compiler checks wheter your code provides a structure with the field “swim” holding a function but it does not demand that you declare and instantiate a class “Duck” “Boat” or what soever etc.

So yeti is very very close to the “agile” dynamic languages, because it behaves like them in many respects (no typeannotations no typedelcarations no type instantiation) but it still checks the types, which saves a lot of test-code maintance and reading.

To my knowledge no other JVM language combines agility with static typechecking as close as Yeti.

What is not so good with yeti?

In my opinion the two main disadvantes are:

Yeti does not integrate as nicely with Java as Scala. But Java integration works both ways and with little problems. You just have to do a bit more work with types

Yeti does not have a big community. I thinkt thats its main problem

Where to continue?

Downlaod yeti http://mth.github.com/yeti/ read the tutorial http://linux.ee/~mzz/yeti/intro.html and have fun with the repl.

Advertisement
Posted in: Uncategorized, Yeti