Project Ceylon

Gavin King (the inventor of Hibernate) fired out a new language project called Ceylon (I suppose referring to the Tea versus the Java Café). I love new languages. I know a bit of them, and I work with Java form 1995, so I will do a deep review of this news…

From The Register we read about Ceylon:

In his China presentation, King says that the Java SE SDK was designed in haste, that it was never “properly modernized”, and that it “still has an experimental, work-in-progress feel about it”.

We also read to the King pdf, to look at this early preview of the Ceylon language.

Java Story in a snap

I have used Java from 1995 (yes, I was on university when Java popped out, do you remember HotJava browser and Sun Studio?…). Java 1.0 was a very verbose language, but featured garbage collection, bytecode and synchronized threads. It rocks a lot compared to C++. Java was easy to use, error was easy to spot. When the Enterprise Specification was mature, Java was able to scale in a developer-sense: a lot of different people can add stuff to a core project with a good isolation, generating good software.

Java spot a very verbose syntax (quite suicide) on EJB 1.0; because of the lack of reflections and introspecion, every EJB’d have three classes, to be able to proper generate stub and skeleton for the trasportation protocol.
EJB 3.0 spot a very different approach, using annotation (a great C# idea, by the way).
So most of the Java defects have been “corrected”.

The only thing has been done bad is the type erasure: to retain backward compatibility, the Java template system type-template destroys information at runtime. This in my own humble opinion is a very bad thing, because you cannot check type any more at runtime.

Java evolved a lot with JDK1.5 and also JDK 1.7 has some new feature to watch for

Ceylon

So let’s read Gavin words:

Another priority of the Ceylon project is to create a Java-based language that defines user interfaces and structured data using a typesafe, hierarchical syntax. “Java is joined at the hip with XML, and this hurts almost every Java developer almost every day,” reads King’s China presentation (39-page PDF/471 KB). “There is simply no good way to define a user interface in Java, and that is a language problem.”

The concept of a user interface is obscure. What does it mean? In Java you can define interfaces in Corba, WebService and so on, so Java is not so bad at this. Java is able to mix multiple interfaces, and with inner classes has a clojure support, even if it is a bit too verbose. CGLib enable you to build dinamically proxy, in a very strong a flexible way (even too flexible, if you consider Spring avoided to use it too much and roll back to lighter interface-based proxy!).

At the moment, the project amounts to little more than a specification. A compiler has not been released. But when the language arrives, it will run in the Java Virtual Machine. According to King’s presentation, it will include static typing, automatic memory management and safe referencing, first-class and high-order functions, declarative syntax for defining user interfaces and structured data, and built-in modularity

Reading the pdf, the language seems a mix of Python and Javascript. As a nice plus, Ceylon avoid “static” concept and you could define functions outside classes (like python) to define “static-like” functions.

From python it takes optional parameters too, and the lack of a “new” keyword. The functional ideas seems taken from javascript and Erlang.

There is a bit of C# too, because

If a value of type T can be null, it must be declared as type Optional<T>, which may be abbreviated to T?.

lead to something like this:

1

2

3

voidhello(){

<strong>String?name=process.args.first;</strong>

}

From the King’s pdf:

There is no constructor syntax. Instead, the class itself declares parameters, and the body of the class may contain initialization logic

Conclusion

Ceylon is still a bit “vapor”, because no code is under our eyes, and there are solo “bits” of examples. It has similarities with Javascript and Scala.JavaScript is already included and integrated in Jdk 1.6 (yes, it is its default scripting language), so Ceylon must provide a stronger alternative to JavaScript to be somewhat attractive.