HOME

TheInfoList



OR:

Ceylon is an
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
, strongly statically typed programming language with an emphasis on immutability, created by
Red Hat Red Hat, Inc. is an American software company that provides open source software products to enterprises. Founded in 1993, Red Hat has its corporate headquarters in Raleigh, North Carolina, with other offices worldwide. Red Hat has become a ...
. 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 describe ...
(JVM), and could be compiled to
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, of ...
. 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. Per ...
, toolability,
modularity Broadly speaking, 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 sy ...
, 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 Generic or generics may refer to: In business * Generic term, a common name used for a range or class of similar things not protected by trademark * Generic brand, a brand for a product that does not have an associated brand or trademark, other ...
* 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 MAVEN is an American spacecraft orbiting Mars to study the loss of its atmospheric gases to space, providing insight into the history of the planet's climate and water. The spacecraft name is an acronym for "Mars Atmosphere and Volatile Evolu ...
* powerful tools, including an Eclipse-based IDE The name "Ceylon" is an oblique reference to Java, in that
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
and
Sri Lanka Sri Lanka (, ; si, ශ්‍රී ලංකා, Śrī Laṅkā, translit-std=ISO (); ta, இலங்கை, Ilaṅkai, translit-std=ISO ()), formerly known as Ceylon and officially the Democratic Socialist Republic of Sri Lanka, is an ...
, formerly known as Ceylon, are islands known for growth and export of
coffee Coffee is a drink prepared from roasted coffee beans. Darkly colored, bitter, and slightly acidic, coffee has a stimulating effect on humans, primarily due to its caffeine content. It is the most popular hot drink in the world. Seeds of ...
and tea. In August 2017, Ceylon was donated to the
Eclipse Foundation The Eclipse Foundation AISBL is an independent, Europe-based not-for-profit corporation that acts as a steward of the Eclipse open source software development community, with legal jurisdiction in the European Union. It is an organization suppo ...
. At that time Ceylon's development got arrested. Neither its version, nor its source code has changed beyond August 2017.


Language features

Ceylon is heavily influenced by
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
'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 to every "term" (a word, phrase, or other set of symbols). Usually the terms are various constructs of a computer progra ...
. Ceylon foregoes Java's primitive types and
boxing Boxing (also known as "Western boxing" or "pugilism") is a combat sport in which two people, usually wearing protective gloves and other protective equipment such as hand wraps and mouthguards, throw punches at each other for a predetermined ...
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 type In type theory, an intersection type can be allocated to values that can be assigned both the type \sigma and the type \tau. This value can be given the intersection type \sigma \cap \tau in an intersection type system. Generally, if the ranges ...
s, in a similar fashion to
TypeScript TypeScript is a free and open source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language. It is designed for the development of large app ...
,
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. 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 (), a positive natural number (, , , etc.) or a negative integer with a minus sign ( −1, −2, −3, etc.). The negative numbers are the additive inverses of the corresponding positive numbers. In the languag ...
or a string: 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 in ...
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 function In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. This means the language supports passing functions as arguments to other functions, returning them as the values from ...
s and
higher order function In mathematics and computer science, a higher-order function (HOF) is a function that does at least one of the following: * takes one or more functions as arguments (i.e. a procedural parameter, which is a parameter of a procedure that is itself ...
s, including function types and
anonymous function In computer programming, an anonymous function (function literal, lambda abstraction, lambda function, lambda expression or block) is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed t ...
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, and a categorical variable in statistics) is a data type consisting of a set of named values called ''elements'', ''members'', '' ...
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 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 branches of computer science and linguistic ...
. 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 or libre software is computer software distributed under terms that allow users to run the software for any purpose as well as to study, change, and distribute it and any adapted versions. Free software is a matter of liberty, n ...
, mostly the Apache License. Part of the source code is licensed under LGPL.


See also

*
Dart (programming language) Dart is a programming language designed for client development, such as for the web and mobile apps. It is developed by Google and can also be used to build server and desktop applications. It is an object-oriented, class-based, garbage-colle ...
, has its own VM, compiles to JS, type system not very strict, supports
mixin In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin's methods depen ...
s *
Fantom (programming language) Fantom is a general purpose object-oriented programming language created by Brian and Andy Frank that runs on the Java Runtime Environment (JRE), JavaScript, and the .NET Common Language Runtime (CLR) (.NET support is considered "prototype" ...
, compiles to JVM, type system not very strict, supports
mixin In object-oriented programming languages, a mixin (or mix-in) is a class that contains methods for use by other classes without having to be the parent class of those other classes. How those other classes gain access to the mixin's methods depen ...
s


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