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!

15 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

 
23. Aug 2014, 14:57 CET | Link
Zcxvcv

We definitely realize that people like desktop apps. Gavin's criticism wasn't intended to mean don't do this but to mean looks good, but make it typesafe!. the venus factor weight loss

 
01. Sep 2014, 22:03 CET | Link
jack

I have been interested in this topic for quite some time.dental seo services I have been researching it for a couple of hours and found your post to be very interesting.Thanks for sharing!!!

16. Sep 2014, 09:01 CET | Link
michael kors outlet online sale,michael kors,kors outlet,michael kors outlet,michael kors handbags,michael kors outlet online,michael kors handbags clearance,michael kors purses,michaelkors.com,michael kors bags,michael kors shoes,michaelkors,cheap michael kors

, oakley vault,oakley sunglasses,oakleys,oakley sunglasses cheap,oakley.com,sunglasses outlet,cheap oakley,cheap oakley sunglasses,oakley outlet,cheap sunglasses,oakley prescription glasses,fake oakleys,oakley sunglasses outlet,oakley glasses,oakley store,fake oakley,oakley sale,cheap oakleys,discount oakley sunglasses, tory burch outlet,tory burch,tory burch handbags,tory burch shoes,tory burch sale,toryburch,tory burch sandals,toryburch.com,tory burch flip flops, ray ban sunglasses outlet,ray ban,ray ban sunglasses,rayban,ray bans,ray ban outlet,ray-ban,raybans,ray ban wayfarer,ray-ban sunglasses,raybans.com,rayban sunglasses,cheap ray ban, oakley sunglasses,oakley vault,oakleys,oakley sunglasses cheap,oakley.com,sunglasses outlet,cheap oakley,cheap oakley sunglasses,oakley outlet,cheap sunglasses,oakley prescription glasses,fake oakleys,oakley sunglasses outlet,oakley glasses,oakley store,fake oakley,oakley sale,cheap oakleys,discount oakley sunglasses, burberry outlet online,burberry,burberry outlet,burberry handbags,burberry factory outlet,burberry sale, polo ralph lauren outlet online,ralph lauren,polo ralph,polo ralph lauren,ralph lauren outlet,polo shirts,ralph lauren outlet online,polo ralph lauren outlet,ralphlauren.com,polo outlet,ralph lauren polo, gucci outlet,gucci handbags,gucci belts,gucci shoes,gucci,gucci belt,gucci sunglasses,gucci bags,cheap gucci, polo ralph lauren outlet,ralph lauren,polo ralph,polo ralph lauren,ralph lauren outlet,polo shirts,ralph lauren outlet online,polo ralph lauren outlet online,ralphlauren.com,polo outlet,ralph lauren polo, michael kors outlet,michael kors,kors outlet,michael kors handbags,michael kors outlet online,michael kors outlet online sale,michael kors handbags clearance,michael kors purses,michaelkors.com,michael kors bags,michael kors shoes,michaelkors,cheap michael kors, toms shoes,toms outlet,toms shoes outlet,toms.com,tom shoes, cheap oakley sunglasses,oakley sunglasses,oakley vault,oakleys,oakley sunglasses cheap,oakley.com,sunglasses outlet,cheap oakley,oakley outlet,cheap sunglasses,oakley prescription glasses,fake oakleys,oakley sunglasses outlet,oakley glasses,oakley store,fake oakley,oakley sale,cheap oakleys,discount oakley sunglasses, louboutin,christian louboutin,red bottom shoes,louboutin shoes,red bottoms,louboutin outlet,christian louboutin shoes,christian louboutin outlet,red bottom shoes for women,louboutins, michael kors outlet online,michael kors,kors outlet,michael kors outlet,michael kors handbags,michael kors outlet online sale,michael kors handbags clearance,michael kors purses,michaelkors.com,michael kors bags,michael kors shoes,michaelkors,cheap michael kors, michael kors outlet,michael kors outlet online,michael kors,kors outlet,michael kors handbags,michael kors outlet online sale,michael kors handbags clearance,michael kors purses,michaelkors.com,michael kors bags,michael kors shoes,michaelkors,cheap michael kors, ray ban sunglasses,ray ban,rayban,ray bans,ray ban outlet,ray-ban,raybans,ray ban wayfarer,ray-ban sunglasses,raybans.com,ray ban sunglasses outlet,rayban sunglasses,cheap ray ban, louboutin outlet,louboutin,christian louboutin,red bottom shoes,louboutin shoes,red bottoms,christian louboutin shoes,christian louboutin outlet,red bottom shoes for women,louboutins, michael kors handbags clearance,michael kors handbags,michael kors bags,michael kors purses

 
21. Sep 2014, 18:54 CET | Link

What to Look for in a Steam Mop : A reputable brand, Weight, Handle design and length, Mop head, Indicator Lights, Covers, On and off switch, Warm-up time, Attachment. Source olive oil for hair cara memakai jilbab steam mop reviews

 
23. Sep 2014, 06:27 CET | Link
jassica

A marathon game where the global star Flo Hyman is overshadowed by the 16-year-old Cuban volleyball prodigy Mireya Luis Hernandez (who stands 1,76m tall, but with a jump of 3,39 meters over the net), a key-player during the match. Days ago, the U.S. had defeated Cuba 3-1 (16-14, 16-14, 11-15, 16-14) in the first round. handball

Post Comment