Coteline基于 JVM 的编程语言
Coteline 是一个全新的基于 JVM 的编程语言。Coteline 是 Ceylon 的超集,并保持对 Ceylon 的向后兼容。
比 Ceylon 改进的地方包括:
- " - publicas a service", because- sharedis not a good keyword.
- implements, because it is fancier than- satisfiesand it closes the gap for existing J2EE 1.3 developers.
- Call an - objecta- singleton.
- Use - constin lieu of- value.
- Write - defas a Hipster-compliant variant of- function.
- Ink - Unitinstead of- voidin your fine-crafted Coteline definitions.
- contractand- traitcarry more meaning than- interface(and who cares about the actual formal semantics of these?).
- We think - prayis a better replacement for- assert, because this is what you actually do when you write assertions.
- dynamicblocks are better named as- unsafeblocks, because they escape the wonderland of static type checks.
- Parametric types with - in / outfor contravariance and covariance are hard to manipulate. This is also way too reminiscent of the C# world. Coteline provides salvation with- covarand- contravar.
- Last but not least, you can also write - foreachloops in Coteline.
示例代码:
"The classic Hello World program"
public Unit hello(String name = "World") {
    const str = "Hello, `` name ``!";
    def work() => print(str);
    work();
    pray(1 == 1);
    plop.plop();
    foreach (i in {1, 2, 3}) {
        print(i);
    }
}
singleton plop {
    public Unit plop() {
        print("Oh Plop!");
    }
}
"Run the module `better.ceylon.is.coteline`."
public Unit run(){
    if (nonempty args=process.arguments) {
        foreach (arg in args) {
            hello(arg);
        }
    }
    else {
        hello();
    }
}