微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Coteline 基于 JVM 的编程语言

程序名称:Coteline

授权协议: 未知

操作系统: 跨平台

开发语言: Java

Coteline 介绍

Coteline一个全新的基于 JVM 的编程语言。Coteline
Ceylon 的超集,并保持对 Ceylon 的向后兼容。

Ceylon 改进的地方包括

  • “public as a service”, because shared is not a good keyword.

  • implements, because it is fancier than satisfies and it closes the gap for existing J2EE 1.3 developers.

  • Call an object a singleton.

  • Use const in lieu of value.

  • Write def as a Hipster-compliant variant of function.

  • Ink Unit instead of void in your fine-crafted Coteline deFinitions.

  • contract and trait carry more meaning than interface (and who cares about the actual formal semantics of these?).

  • We think pray is a better replacement for assert, because this is what you actually do when you write assertions.

  • dynamic blocks are better named as unsafe blocks, because they escape the wonderland of static type checks.

  • Parametric types with in / out for contravariance and covariance are hard to manipulate. This is also way too reminiscent of the C# world. Coteline provides salvation with covar and contravar.

  • Last but not least, you can also write foreach loops 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();
    }
}

Coteline 官网

http://typeunsafe.github.io/coteline/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐