Suvarna Garge (Editor)

Ceylon (programming language)

Updated on
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Paradigm  Object-oriented
Developer  Red Hat
Designed by  Gavin King
Typing discipline  Static, strong, safe
First appeared  2011; 6 years ago (2011)
Stable release  1.3.1 / November 21, 2016; 3 months ago (2016-11-21)

Ceylon is an object-oriented, strongly statically typed programming language with an emphasis on immutability, created by Red Hat. Ceylon programs run on the Java virtual machine (JVM), and can be compiled to JavaScript. The language design focuses on source code readability, predictability, toolability, modularity, and metaprogrammability.


Important features of Ceylon include:

  • A type system enforcing null safety and list element existence at compile time
  • Regular syntax and semantics, avoiding special cases and primitively-defined constructs in favor of syntactic sugar
  • Support for generic programming and metaprogramming, with reified generics
  • Modularity built into the language, based on JBoss modules, interoperable with OSGi and Maven
  • powerful tools, including an Eclipse-based IDE
  • The name "Ceylon" is an oblique reference to Java, in that Java and Sri Lanka, formerly known as Ceylon, are islands known for growth and export of coffee and tea.

    Language features

    Ceylon is heavily-influenced by Java's syntax, but adds many new features.

    Type system

    One of the most novel aspects of Ceylon is its type system. Ceylon foregoes Java's primitive types and boxing in favor of a type system composed entirely of first-class objects. While this may cause boxing overhead in some situations, it makes the type system more uniform.

    Ceylon allows for union and intersection types, in a similar fashion to TypeScript, Whiley and Flow.

    Union types, written A|B, allow a variable to have more than one type. The following example shows a Ceylon function which may take either an integer or a string:

    Intersection types, written A&B, are the theoretical foundation of flow-sensitive typing:

    The condition is Integer input narrows the type of input to <Integer|String> & Integer, which distributes to Integer&Integer | String&Integer, which, as String and Integer are disjoint types, is equivalent to Integer&Integer | Nothing (Nothing is the empty bottom type), which simplifies to just Integer.

    Null safety

    Union and intersection types are used to provide null safety. The top type of the Ceylon type hierarchy is the class Anything, which has two subclasses: Object, the superclass of all normal classes and all interfaces, and Null, with the only instance null. Since Object and Null are disjoint types, most regular types like Integer or List<String> are not nullable; a nullable type is the union Integer|Null, abbreviated Integer?.

    Intersection types can be used to get a non-optional type out of a possibly-optional type, such as a type parameter. For example, the signature of a function that removes null elements from a stream of values could be:

    When removeNulls is called with a stream of Integer|Null elements, the result will be a stream of <Integer|Null> & Object elements, which simplifies to Integer.


    Similarly to many modern languages, Ceylon supports first class functions and higher order functions, including function types and anonymous functions

    Enumerated types

    Similar to Java and many other languages, and with a similar mechanism as algebraic types, Ceylon supports enumerated types, otherwise known as enums. This is implemented in Ceylon with a pattern of limiting the instances of an abstract class at declaration to a limited set of objects (in this case, singleton instances). Another way to implement this pattern is with the new constructor feature in Ceylon 1.2 where the objects are implemented as different named constructor declarations.

    Type inference

    Ceylon is strongly and statically typed, but also has support for type inference. The value keyword is used to infer the type of a variable, and the function keyword is used to infer the type of a function. The following two definition pairs are each equivalent:

    However, to make single-pass type inference possible, type inference is only allowed for non-toplevel and unshared declarations.

    Entry point with names

    By default the starter (ceylon run) runs the shared run() function of a module:

    but any other shared function without parameters can be used as main calling the program with the --run parameter, like this:

    ceylon run --compile=force --run hello default


    All parts of Ceylon are available under open source licenses, mostly the Apache License. Part of the source code is licensed under LGPL.


    Ceylon (programming language) Wikipedia

    Similar Topics
    The Equalizer (film)
    Thierry Rey
    Felip Gomes