# 锡兰（编程语言）

**锡兰**（Ceylon）是一门静态类型编程语言，面向Java和[JavaScript](https://www.edgepedia.org/zh/javascript)虚拟机，由加文·金（Gavin King）及其在红帽（Red Hat）的团队创建，后转由Eclipse基金会开发。它可编译为Java字节码或JavaScript，具有完全具体化的类型系统，支持联合类型与交集类型，并将模块作为语言级构造。2017年发布1.3.3版后开发工作归档，GitHub仓库于2023年设为只读。<sup>[1](https://in.relation.to/2011/04/27/introduction-to-ceylon-part-1/)</sup><sup> • </sup><sup>[2](https://www.theregister.com/2013/11/13/red_hat_ships_ceylon_1_0_0/)</sup><sup> • </sup><sup>[3](https://ceylon-lang.dev/)</sup>

| 关键事实 | 详情 |
|---|---|
| 创建者 | 加文·金在红帽的团队；项目于2011年4月27日公布<sup>[1](https://in.relation.to/2011/04/27/introduction-to-ceylon-part-1/)</sup> |
| 首个版本 | 1.0.0，2013年11月13日，在比利时安特卫普的Devoxx大会上公布<sup>[2](https://www.theregister.com/2013/11/13/red_hat_ships_ceylon_1_0_0/)</sup> |
| 目标平台 | Java虚拟机与JavaScript虚拟机，包括Node.js；编译器输出Java字节码或JavaScript<sup>[4](https://site.ceylon-lang.dev/blog/)</sup> |
| 类型系统 | 完全具体化的泛型类型参数、联合类型与交集类型、流敏感类型、类型安全的空值处理<sup>[5](https://www.saylong.org/documentation/current/spec/html_single/index.html)</sup><sup> • </sup><sup>[6](https://site.ceylon-lang.dev/documentation/1.2/introduction/)</sup> |
| 模块化 | 语言级包与模块；带OSGi和Maven元数据的`.car`模块归档；Ceylon Herd社区仓库<sup>[7](https://site.ceylon-lang.dev/documentation/1.2/tour/modules/)</sup> |
| 最终版本 | 1.3.3，2017年8月21日（21 MB发行包）<sup>[3](https://ceylon-lang.dev/)</sup> |
| 状态 | 2017年转入Eclipse基金会；项目已归档；GitHub仓库于2023年4月13日设为只读<sup>[4](https://site.ceylon-lang.dev/blog/)</sup><sup> • </sup><sup>[8](https://github.com/eclipse-archived/ceylon/issues/7454)</sup> |

## 起源与设计目标

Hibernate的创建者加文·金于2011年4月以红帽项目的形式推出锡兰。其公开动机是：Java的语言与类库设计于十五年前以上，已不再是应对一系列企业计算问题的最佳基础。设计目标包括：对Java和C#开发者易于学习；消除Java的部分冗长之处，同时保持可读性；改进类型安全性；为层级化信息（如用户界面定义）提供声明式语法；以不可变对象和高阶函数支持更函数式的风格；以及提供内建的模块化支持。<sup>[1](https://in.relation.to/2011/04/27/introduction-to-ceylon-part-1/)</sup>

早期媒体报道将锡兰称为“Java杀手”，但金否认曾有意取代Java。即便最早的构建版本生成的代码也运行在Java虚拟机上，金将该语言描述为跨平台，意在凭借现代类库和更适合定义用户界面的语法，与Java并存。<sup>[2](https://www.theregister.com/2013/11/13/red_hat_ships_ceylon_1_0_0/)</sup>金还解释了红帽为何没有改用Scala，他写道，Scala的类型系统比团队想要的更为复杂，而锡兰有意包含更少的语言特性。<sup>[9](https://arstechnica.com/information-technology/2011/04/the-rationale-for-ceylon-red-hats-new-programming-language/)</sup>

## 类型系统

锡兰的类型系统将子类型多态与参数多态相结合，一个类型可以是类、接口、类型参数，或其他类型的联合或交集。<sup>[5](https://www.saylong.org/documentation/current/spec/html_single/index.html)</sup>当时有三项特性使其区别于Java：

- **具体化泛型。** 与C#相同而与Java不同，泛型类型参数在运行时是具体化的，消除了Java类型擦除带来的问题。编译器无需修改JVM本身即可实现这一点。<sup>[5](https://www.saylong.org/documentation/current/spec/html_single/index.html)</sup>
- **类型安全的空值。** 锡兰中不存在`NullPointerException`。可能为null的值必须用联合类型声明，如`String?`，即`String | Null`的缩写，编译器要求先进行`if (exists ...)`检查，才能将该值作为字符串使用。<sup>[6](https://site.ceylon-lang.dev/documentation/1.2/introduction/)</sup>
- **流敏感类型。** `is`和`exists`等条件会在条件成立的分支中收窄值的类型，同一机制也处理了在Java中会引发`ClassCastException`的类型测试。<sup>[6](https://site.ceylon-lang.dev/documentation/1.2/introduction/)</sup>

Eclipse的创建审查后来称赞锡兰是首个展示自由形式[联合类型](https://www.edgepedia.org/zh/union-type)与交集类型实际应用的语言，也是首个或最早的两个具备流敏感类型的语言之一，这些构造此后已被其他语言采纳。<sup>[10](https://projects.eclipse.org/projects/technology.ceylon/reviews/creation-review)</sup>

该语言中没有原始类型或数组；每个值都是根类型`Anything`的实例，不过编译器可以优化代码以使用虚拟机的原始类型来提升性能。<sup>[5](https://www.saylong.org/documentation/current/spec/html_single/index.html)</sup>接口是无状态的，不能持有对其他对象的引用或定义初始化逻辑，也不能被直接实例化，从而在锡兰受限的多重继承中无需对超类型做任何线性化。<sup>[6](https://site.ceylon-lang.dev/documentation/1.2/introduction/)</sup>

## 模块化与工具

模块化是语言级特性，而非构建工具的约定。代码组织为包和模块，特定模块版本之间的依赖在`module.ceylon`描述符中声明，可见性通过`shared`注解在块、包、模块和公开四级进行控制；没有与Java的`protected`等价的概念。<sup>[6](https://site.ceylon-lang.dev/documentation/1.2/introduction/)</sup><sup> • </sup><sup>[7](https://site.ceylon-lang.dev/documentation/1.2/tour/modules/)</sup>

针对JVM编译时，一个模块会生成`.car`模块归档，其中包含编译后的类文件、描述符，以及面向锡兰模块运行时、OSGi容器和Maven的内建元数据。模块在运行时由基于JBoss Modules运行时的对等类加载器架构加载。针对JavaScript，编译器生成与Node.js和require.js兼容的CommonJS模块。Ceylon Herd充当社区模块仓库。<sup>[7](https://site.ceylon-lang.dev/documentation/1.2/tour/modules/)</sup>

发行包包含面向Java和JavaScript的编译器、文档编译器、测试运行器、WAR归档打包器、“胖”JAR打包器，以及在JVM和Node.js上运行模块化程序的支持。锡兰提供了基于Eclipse和[IntelliJ IDEA](https://www.edgepedia.org/zh/intellij-idea)的集成开发环境。<sup>[4](https://site.ceylon-lang.dev/blog/)</sup>

## Java互操作性

锡兰没有自己的虚拟机；它借用JVM或JavaScript虚拟机。在模块描述符中声明对`java.base`等Java模块的依赖后，即可在锡兰中使用Java代码，此后Java类可以像普通锡兰类一样导入和使用。Java归档可以通过JBoss Modules元数据添加到锡兰模块仓库，或通过Aether从Maven仓库导入。<sup>[11](https://site.ceylon-lang.dev/documentation/1.1/tour/interop/)</sup>

互操作有明文记录的局限。不能用锡兰的命名参数语法调用Java方法，因为Java 7不在运行时暴露参数名。无法为重载方法获取方法引用。而且由于Java泛型类型在运行时不携带具体化的类型参数，依赖具体化泛型的操作（如`is`测试）对Java类型会失败；因此锡兰为Java互操作支持使用点变型通配符，如`List<out Object>`，同时在纯锡兰代码中推荐声明点变型。<sup>[11](https://site.ceylon-lang.dev/documentation/1.1/tour/interop/)</sup>`ceylon.interop.java`模块提供了`CeylonIterable`等适配器，以便用锡兰的迭代方式使用Java集合。<sup>[11](https://site.ceylon-lang.dev/documentation/1.1/tour/interop/)</sup>

1.3.3版针对大量Java库和框架进行了测试，包括Vert.x、Spring Boot、WildFly、Hibernate（JPA）、RESTEasy、Weld和Guice、OSGi容器、[JavaFX](https://www.edgepedia.org/zh/javafx)、RxJava、Vaadin和LWJGL。<sup>[4](https://site.ceylon-lang.dev/blog/)</sup>

## 发布历史与衰落

1.0.0版历经三年多开发，此前有一个测试版和六个里程碑版本，未增加新语言特性，而是专注于缺陷修复。<sup>[2](https://www.theregister.com/2013/11/13/red_hat_ships_ceylon_1_0_0/)</sup>此后主要版本每年发布：2014年的1.1、2015年的1.2、2016年的1.3。<sup>[10](https://projects.eclipse.org/projects/technology.ceylon/reviews/creation-review)</sup>最终版本1.3.3于2017年8月21日发布，同日宣布转入Eclipse基金会；计划中的1.4.0版从未面世。<sup>[4](https://site.ceylon-lang.dev/blog/)</sup><sup> • </sup><sup>[3](https://ceylon-lang.dev/)</sup>

交接之后，活动急剧减少。2019年一个询问项目是否已死的GitHub议题指出，项目自2017年起处于维护模式，IntelliJ插件已无法在较新的IntelliJ版本上正常工作。<sup>[8](https://github.com/eclipse-archived/ceylon/issues/7454)</sup>Eclipse项目页面现带有归档警告，主仓库于2023年4月13日设为只读。<sup>[12](https://projects.eclipse.org/projects/technology.ceylon)</sup><sup> • </sup><sup>[8](https://github.com/eclipse-archived/ceylon/issues/7454)</sup>包括网站、模块仓库和下载服务器在内的官方基础设施此后已下线；由项目提交者约翰·瓦西莱夫（John Vasileff）维护的独立“锡兰保存项目”归档了文档、工具和源代码。<sup>[3](https://ceylon-lang.dev/)</sup>

评论者在将锡兰与Kotlin（后者于2016年初发布1.0版，成为使用量第二大的JVM语言）比较时指出，锡兰使用自己的集合而非Java的集合、以Eclipse为中心的工具链，以及更重的模块与类型系统，是其未能获得可比采用度的原因。<sup>[13](https://news.ycombinator.com/item?id=22253844)</sup>

## References

1. [Gavin King (2011). Introduction to Ceylon Part 1. In Relation To.](https://in.relation.to/2011/04/27/introduction-to-ceylon-part-1/)
2. [Neil McAllister (2013). Red Hat ships piping hot Ceylon to curry favor with Java-weary devs. The Register.](https://www.theregister.com/2013/11/13/red_hat_ships_ceylon_1_0_0/)
3. [Ceylon Preservation Project](https://ceylon-lang.dev/)
4. [Eclipse Ceylon: Team blog](https://site.ceylon-lang.dev/blog/)
5. [The Ceylon Language Specification](https://www.saylong.org/documentation/current/spec/html_single/index.html)
6. [Eclipse Ceylon: Quick introduction](https://site.ceylon-lang.dev/documentation/1.2/introduction/)
7. [Eclipse Ceylon: Packages and modules](https://site.ceylon-lang.dev/documentation/1.2/tour/modules/)
8. [Is this project dead? Issue #7454, eclipse-archived/ceylon](https://github.com/eclipse-archived/ceylon/issues/7454)
9. [Ryan Paul (2011). The rationale for Ceylon, Red Hat's new programming language. Ars Technica.](https://arstechnica.com/information-technology/2011/04/the-rationale-for-ceylon-red-hats-new-programming-language/)
10. [Eclipse Ceylon Creation Review, projects.eclipse.org](https://projects.eclipse.org/projects/technology.ceylon/reviews/creation-review)
11. [Eclipse Ceylon: Interoperation with Java](https://site.ceylon-lang.dev/documentation/1.1/tour/interop/)
12. [Eclipse Ceylon project page, projects.eclipse.org](https://projects.eclipse.org/projects/technology.ceylon)
13. [Kotlin becomes second most popular language on the JVM, Hacker News discussion](https://news.ycombinator.com/item?id=22253844)

---
*Initially written Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Programming languages › Individual programming languages

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/ceylon-programming-language

English original: https://www.edgepedia.org/ceylon-programming-language
