Skip to main content
Blog

Exploring Ceylon

By 3 oktober 2013januari 30th, 2017No Comments

Redhat has released Ceylon 1.0 beta! Including a new release of the eclipse IDE plugin which means it’s actually starting to become usable and who knows even practical.

The classes from both languages, java and ceylon, work together like peas in a pod! Don’t believe me? Just follow the instructions on installing Ceylon (which is really easy if you know java), and try the example!

I had already tried some things using Ceylon before, the basic syntax had already been working a long time before. It seemed promising, but not really usable yet.

Now this release is different! It works. I’m especially happy about the integration with java code. Ceylon code can call java code (and the IDE does not mind), and java code can call the Ceylon code just as easy, no configuration needed, no special setup, no interfaces, no nothing, it works.

For example, the java class:

package nl.wijsmullerbros.myfirstceylon;
public class OldStuffStillSurvives {

         public static void main(String[] args) {
                  Interesting theJavaWay = new Interesting();
                  theJavaWay.sayHello();
         }

         public String whatJavaIsAllAbout() {
                  return "nulls, indirection and verbosity";
         }
}

And in the same package, same directory, the Ceylon unit:

void start() {
         value inferencedThing = Interesting();
         // how novel
         inferencedThing.sayHello();
         // but there's more:
         inferencedThing.sayJavaIs();
}

shared class Interesting() {

         shared void sayHello() {   
                print("hello!");
         }

         "So here's where we call java, that old sod"
         shared void sayJavaIs() {
                   String blastFromThePast = OldStuffStillSurvives().whatJavaIsAllAbout();
                  print(blastFromThePast);
         }
}
[box type=”shadow”] Everything you need to know can be easily found on http://ceylon-lang.org, just follow the instructions on installing Ceylon (which is really easy if you know java), and try this example, run the java main class, and the Ceylon top level function “start”.
[/box]

I like it! Maybe (just maybe) I’ll try to get GWT running with Ceylon, who knows.
(which probably could be optimized a lot since Ceylon itself can also be compiled to javascript, but that’s another matter)