Ceylon (programming language)
   HOME

TheInfoList



OR:

Ceylon was an
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impleme ...
, strongly
statically typed In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
programming language with an emphasis on
immutability In object-oriented (OO) and functional programming, an immutable object (unchangeable object) is an object whose state cannot be modified after it is created.Goetz et al. ''Java Concurrency in Practice''. Addison Wesley Professional, 2006, Secti ...
, created by
Red Hat Red Hat, Inc. (formerly Red Hat Software, Inc.) is an American software company that provides open source software products to enterprises and is a subsidiary of IBM. Founded in 1993, Red Hat has its corporate headquarters in Raleigh, North ...
. Ceylon programs run on the
Java virtual machine A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally descr ...
(JVM), and could be compiled to
JavaScript JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior. Web browsers have ...
. The language design focuses on source code readability,
predictability Predictability is the degree to which a correct prediction or forecast of a system's state can be made, either qualitatively or quantitatively. Predictability and causality Causal determinism has a strong relationship with predictability. Perfec ...
, toolability,
modularity Modularity is the degree to which a system's components may be separated and recombined, often with the benefit of flexibility and variety in use. The concept of modularity is used primarily to reduce complexity by breaking a system into varying ...
, 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 In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an ...
* Support for generic programming and metaprogramming, with reified generics * Modularity built into the language, based on JBoss modules, interoperable with
OSGi OSGi is an open specification and open source project under the Eclipse Foundation. It is a continuation of the work done by the OSGi Alliance (formerly known as the Open Services Gateway initiative), which was an open standards organization fo ...
and Maven * powerful tools, including an Eclipse-based IDE The name "Ceylon" is an oblique reference to Java, in that
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
and
Sri Lanka Sri Lanka, officially the Democratic Socialist Republic of Sri Lanka, also known historically as Ceylon, is an island country in South Asia. It lies in the Indian Ocean, southwest of the Bay of Bengal, separated from the Indian subcontinent, ...
, formerly known as Ceylon, are islands known for growth and export of
coffee Coffee is a beverage brewed from roasted, ground coffee beans. Darkly colored, bitter, and slightly acidic, coffee has a stimulating effect on humans, primarily due to its caffeine content, but decaffeinated coffee is also commercially a ...
and
tea Tea is an aromatic beverage prepared by pouring hot or boiling water over cured or fresh leaves of '' Camellia sinensis'', an evergreen shrub native to East Asia which probably originated in the borderlands of south-western China and nor ...
. In August 2017, Ceylon was donated to the
Eclipse Foundation The Eclipse Foundation AISBL is an independent, Europe-based not-for-profit organization that acts as a steward of the Eclipse open source software development community, with legal jurisdiction in the European Union. It is an organization supp ...
. Development slowed down and finally stopped in 2020. In April 2023,
Eclipse Foundation The Eclipse Foundation AISBL is an independent, Europe-based not-for-profit organization that acts as a steward of the Eclipse open source software development community, with legal jurisdiction in the European Union. It is an organization supp ...
declared the termination of the transition.


Language features

Ceylon is heavily influenced by
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
's syntax, but adds many new features.


Type system

One of the most novel aspects of Ceylon compared to Java is its
type system In computer programming, a type system is a logical system comprising a set of rules that assigns a property called a ''type'' (for example, integer, floating point, string) to every '' term'' (a word, phrase, or other set of symbols). Usu ...
. Ceylon foregoes Java's primitive types and
boxing Boxing is a combat sport and martial art. Taking place in a boxing ring, it involves two people – usually wearing protective equipment, such as boxing glove, protective gloves, hand wraps, and mouthguards – throwing Punch (combat), punch ...
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 TypeScript (abbreviated as TS) is a high-level programming language that adds static typing with optional type annotations to JavaScript. It is designed for developing large applications and transpiles to JavaScript. It is developed by Micr ...
,
Whiley Whiley is the surname of: * Manning Whiley (1915–1975), British actor * Richard Whiley (born 1935), English cricketer * Jo Whiley (born 1965), English DJ * Matthew Whiley (born 1980), English cricketer * Jordanne Whiley (born 1992), British w ...
and Flow, which in fact, took the idea from Ceylon. 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 An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
or a
string String or strings may refer to: *String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects Arts, entertainment, and media Films * ''Strings'' (1991 film), a Canadian anim ...
: shared void integerOrString(Integer, String input) Intersection types, written A&B, are the theoretical foundation of flow-sensitive typing: shared void integerOrString(Integer, String input) 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 Nullable types are a feature of some programming languages which allow a value to be set to the special value NULL instead of the usual possible values of the data type. In statically typed languages, a nullable type is an option type, while i ...
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: Iterable removeNulls(Iterable stream); 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.


Functions

Similarly to many modern languages, Ceylon supports first class functions and higher order functions, including function types and
anonymous function In computer programming, an anonymous function (function literal, expression or block) is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed to higher-order functions or used for const ...
s // A top-level higher-order function using block syntax (not associated with any user-created classes) String process(String text, String transformString(String toChange)) // A top-level function calling String.reverse in expression form. String reverse(String text) => text.reversed; // A function reference to String.reversed but mostly equivalent to the function above. String(String) reverseFunctionReference = String.reversed; // An example where the top-level function above is provided as an argument to the higher-order function above String reversed1 = process("one", reverse); // An example where an anonymous function - (text) => text+text - is provided to the higher-order function above. String reversed2 = process("one", (text) => text+text);


Enumerated types

Similar to Java and many other languages, and with a similar mechanism as algebraic types, Ceylon supports
enumerated type In computer programming, an enumerated type (also called enumeration, enum, or factor in the R (programming language), R programming language, a status variable in the JOVIAL programming language, and a categorical variable in statistics) is a data ...
s, 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. // Traditional syntax for enumerated type, in this case, limiting the instances to three objects(for this purpose: Singletons) abstract class Vehicle(shared String name) of plane , train , automobile object plane extends Vehicle("plane") object train extends Vehicle("train") object automobile extends Vehicle("automobile") // Compile error: type is not a subtype of any case of enumerated supertype: 'boat' inherits 'Vehicle' //object boat extends Vehicle("boat") // New (as of Ceylon 1.2.0) constructor-based syntax class Vehicle of plane , train , automobile


Type inference

Ceylon is strongly and statically typed, but also has support for
type inference Type inference, sometimes called type reconstruction, refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some bran ...
. 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: Integer i = 3; value i = 3; Integer add(Integer i1, Integer i2) function add(Integer i1, Integer i2) 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: /* The classic Hello World program */ shared void run() 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


Versions

Versions of Ceylon released: * M1 0.1 "Newton" (Dec 20 2011) * M2 0.2 "Minitel" (Mar 2 2012) * M3 0.3 "V2000" (Jun 21 2012) * M3.1 0.3.1 "V2000" (Jul 6 2012) * M4 0.4 "Analytical Engine" (Oct 29 2012) * M5 0.5 "Nesa Pong" (Mar 13 2013) * M6 0.6 "Virtual Boy" (Sep 23 2013) * 1.0 beta "Virtual Boy" (Sep 24 2013) * 1.0.0 "No More Mr Nice Guy" (Nov 13 2013) * 1.1.0 "Ultimate Ship The Second" (Oct 09 2014) * 1.2.0 "A Series of Unlikely Explanations" (Oct 28 2015) * 1.2.1 "Irregular Apocalypse" (Feb 11 2016) * 1.2.2 "Charming But Irrational" (Mar 11 2016) * 1.3.0 "Total Internal Reflection" (Sep 19 2016) * 1.3.1 "Now We Try It My Way" (Nov 22 2016) * 1.3.2 "Smile Tolerantly" (Mar 02 2017) * 1.3.3 "Contents May Differ" (Aug 21 2017)


License

All parts of Ceylon are available as
free software Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
, mostly the
Apache License The Apache License is a permissive free software license written by the Apache Software Foundation (ASF). It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software ...
. Part of the source code is licensed under LGPL.


See also

*
Dart (programming language) Dart is a programming language designed by Lars Bak and Kasper Lund and developed by Google. It can be used to develop web and mobile apps as well as server and desktop applications. Dart is an object-oriented, class-based, garbage-colle ...
, has its own VM, compiles to JS, type system not very strict, supports mixins *
Fantom (programming language) Fantom is a general-purpose object-oriented programming language, created by Brian Frank and Andy Frank. It runs on the Java Runtime Environment (JRE), JavaScript, and the .NET Common Language Runtime (CLR) (.NET support is considered "protot ...
, compiles to JVM, type system not very strict, supports mixins


References


External links

* {{Programming languages Java programming language family JVM programming languages Programming languages created in 2011 Red Hat software Software using the Apache license 2011 software High-level programming languages Source-to-source compilers