Help

Great, I'm finally able to write, compile, and run Ceylon code that uses Java libraries from within Ceylon IDE:

import java.lang { System { sysprops=properties } }
import java.util { Date }

void greet() {
    value date = Date();
    print("Hello, " sysprops.getProperty("user.name", "world") 
          ", the date is " date.day "/" date.month "/" 1900+date.year ".");
}

This doesn't look like much, perhaps, but it's demonstrating some important features of the interoperability:

  1. the ability to map a Java static declaration to a toplevel declaration in Ceylon,
  2. the ability to resolve an invocation to the correct overloaded version,
  3. the equivalence between Java primitive types and java.lang.String and Ceylon types in ceylon.language, and
  4. the automatic mapping of JavaBeans properties to Ceylon attributes.

Here's a second working example:

import java.lang { System { sysprops=properties } }
import java.io { File }

void listHomeDir() {
    for (file in File(sysprops.getProperty("user.home")).listFiles()) {
        print(file.canonicalPath);
    }
}

Java interop has been a somewhat tricky problem for us because Ceylon's type system is somewhat different to Java's, and because the design of Ceylon's language module isn't really based on the Java SDK. When running on the Java VM, the language module does make use of the Java SDK as part of its internal implementation. But when running on a JavaScript VM, it can't, of course. So we have to limit our dependence upon JVM-specific stuff.

We've still got a few things to finish off here. For example, our treatment of arrays and Java Iterables is not completely finished, and some IDE features still aren't working quite right, but I think most of the hard work is already done, ready for release as part of Ceylon M2.

Good work guys!

10 comments:
 
27. Feb 2012, 00:09 CET | Link

Well done! Do you plan realizing Java interop and Union/Intersection Type compatibility?

Like: import java.util { Date } DateCeylonClass = Date(); And how about Nullsafety? Are all used Java classes implizit Nothing Union Types or do you assure that references of Java variables can not be null?

Best regards, Frank

ReplyQuote
 
27. Feb 2012, 00:11 CET | Link
My comment broke because of the Ceylon example. ;-)
Correct version:

Well done!
Do you plan realizing Java interop and Union/Intersection Type compatibility?

Like:
import java.util { Date }
Date|CeylonClass = Date();

And how about Nullsafety? Are all used Java classes implizit |Nothing Union Types or do you assure that references of Java variables can not be null?

Best regards,
Frank


Click HELP for text formatting instructions. Then edit this text and check the preview.
 
27. Feb 2012, 18:38 CET | Link
Like:
import java.util { Date } 

Date|CeylonClass obj = Date();

That should work just fine. :-)

And how about Nullsafety? Are all used Java classes implizit |Nothing Union Types or do you assure that references of Java variables can not be null?

Our approach is to let the programmer decide. You can write:

Date date = methodThatYouKnowNeverReturnsNull();

And, if you're wrong, and it actually does return null, you'll get an NPE at this line.

Or you can write:

Date? date = methodThatYouThinkSometimesReturnsNull();

Unfortunately, Java's typesystem doesn't capture information about which methods can return null, so this is the best we can do. But I think it's a very reasonable approach in light of that. I would not want to go and make you have to write if (exists) every time you call a Java method. Nor am I going to go and try and compiler a catalog of all methods in all Java libraries that can't return null. That to me just sounds nuts and extremely error-prone.

 
29. Feb 2012, 15:55 CET | Link

I think that java needs a CLS common lenaguage specification that the microsoft plaftform do for interoperability between languages.

All the people is making a new language but the other languages maybe can not interop with others because Java doesn't have a CLS.

 
29. Feb 2012, 23:14 CET | Link
I think that java needs a CLS common lenaguage specification that the microsoft plaftform do for interoperability between languages.

Well, it sort-of does in the sense that this is defined by the bytecodes and class file format. But yeah, I agree that the level of abstraction is a not quite right, and that interop is a bit limited to the language subsets which map directly to Java.

I agree that it would be wonderful if the JCP could take on the role of trying to improve interop between JVM languages. That seems to be something where the JCP could really show its value.

 
16. May 2014, 11:27 CET | Link

One story that makes its way through the set in a couple of different ways involves Master Kensei as he finds out that his older brother is in Japan looking for him. Sogetsu has a long time grudge against his brother for things from http://www.hawkinsfalconry.co.uk/read.aspx their past that deals with just differences in their personalities. Though Sogetsu is here to fight him, Kensei's daughter is also here and looking for him. She's intent on bringing him back chanel replica to China where he's the master of a school of a hundred thousand students, something he turned over to his wife before leaving. Renka has replica chanel little time for Kenichi during this but as the episodes go on and she gets more involved, she starts to see more in Kenichi because replica handbags of how he's involved with everyone at Ryozanpake and that there simply must be something more to him. This leads to some competition between her and Miu that's comical, especially when Miu treats her like a kitty and skritches her chin.

17. May 2014, 08:10 CET | Link
If someone likes to lie, then he will not be trusted again by many people. Therefore, you should look for ways to eliminate this habit. <a href="http://www.healthybodyinc.com/garcinia-cambogia-extreme-with-75-hca-180-count/">check here for GC online</a>
 
29. May 2014, 22:19 CET | Link
I do believe that will coffee requires a CLS popular dialect specs the Microsof company podium perform pertaining to interoperability between languages.[url=https://www.passbeemedia.com/buy-ibeacon/]Quality iBeacons Online[/url] <a href="https://www.passbeemedia.com/buy-ibeacon/">Quality iBeacons Online</a>
 
01. Jun 2014, 08:57 CET | Link

Ceylon is really a good programming language. One problem is that a few features are machine dependent

 
10. Jun 2014, 11:28 CET | Link
jack

This life of being a self-employed artist/writer is not an easy one but I don’t believe that I chose it;homes for sale palm beach county I believe it was chosen for me – it was pre-determined

Post Comment