Ceylon (programming language): Difference between revisions

Content deleted Content added
No edit summary
Template:Infobox programming language update, parameters: move, add, fill. WP:LINK updates. Nonlead nonproper noun MOS:CAPS > low-case. Template:Cite web updates. Terms define before WP:ABBRs. Small WP:EoS WP:COPYEDITs.
Line 2:
 
{{Infobox programming language
| name = Ceylon
| logo = [[image:Ceylon (programming language) logo.png]]
| paradigm = [[Object-oriented programming|Object-oriented]]
| released = {{Start date and age|2011}}
| designer = Gavin King, [[Red Hat]]
| latest release version = 1.3.01
| latest release date = {{Start date and age|2016|0911|1921}}
| typing = [[Type system|Static, strong, safe]]
| scope =
| implementations =
| programming language =
| dialects =
| influenced byplatform = [[Virtual machine|VMs]] of [[Java (programmingvirtual language)machine|Java]],<ref>{{cite web[[JavaScript]]
| operating system =
| url=http://ceylon-lang.org/documentation/1.2/faq/#what_is_ceylon
| license = [[Apache License|Apache v2]] v2
| title=Frequently Asked Questions: What is Ceylon?
 
| quote=Ceylon is a new programming language that's deeply influenced by Java
 
| accessdate=2015-12-04}}</ref> [[Scala (programming language)|Scala]], [[Smalltalk]], [[ML (programming language)|ML]],<ref>{{cite web
 
| url=https://gitter.im/ceylon/user?at=5660a7242cbea1d7054de9d9
 
| title=ceylon/user - Gitter
 
| accessdate=2015-12-04}}</ref> [[Lisp (programming language)|Lisp]]<ref>{{cite web
 
| url=https://gitter.im/ceylon/user?at=5660a90e5057376520db6f8b
 
| title=ceylon/user - Gitter
 
| accessdate=2015-12-04}}</ref>
 
| license = [[Apache License|Apache v2]]
| website = {{URL|ceylon-lang.org}}
| file ext = .ceylon<ref>{{cite web
| url=http://ceylon-lang.org/documentation/1.2/spec/html_single/#compilationunitstructure
| title=The Ceylon Language: §4.1 Compilation unit structure
| quote=A ''compilation unit'' is a text file, with the filename extension <code>.ceylon</code>.
| accessdateaccess-date=2015-12-04
| last=King | first=Gavin}}</ref>
| implementations =
| wikibooks =
| dialects =
| influenced by = [[Java (programming language)|Java]],<ref>{{cite web
| url=http://ceylon-lang.org/documentation/1.2/faq/#what_is_ceylon
| title=Frequently Asked Questions: What is Ceylon?
| quote=Ceylon is a new programming language that's deeply influenced by Java
| accessdateaccess-date=2015-12-04}}</ref> [[Scala (programming language)|Scala]], [[Smalltalk]], [[ML (programming language)|ML]],<ref>{{cite web
| url=https://gitter.im/ceylon/user?at=5660a7242cbea1d7054de9d9
| title=ceylon/user - Gitter
| accessdateaccess-date=2015-12-04}}</ref> [[Lisp (programming language)|Lisp]]<ref>{{cite web
| url=https://gitter.im/ceylon/user?at=5660a90e5057376520db6f8b
| title=ceylon/user - Gitter
| accessdateaccess-date=2015-12-04}}</ref>
| influenced =
| wikibooks =
}}
 
'''Ceylon''' is an [[Object-oriented programming|object-oriented]], [[Strong typing|strongly]] [[Type system|statically typed]] programming language with an emphasis on [[Immutable object|immutability]], created by [[Red Hat]]. Ceylon programs run on the [[Java Virtualvirtual Machinemachine]] (JVM), and can be compiled to [[JavaScript]].<ref>{{cite web
| url=http://ceylon-lang.org/blog/2013/09/22/ceylon-1/
| title=Ceylon 1.0 beta
| accessdateaccess-date=2013-09-26}}</ref><ref>{{cite web
| url=http://www.theregister.co.uk/2011/04/13/red_hat_unveils_project_ceylon
| title=Project Ceylon – Red Hat builds Java replacement
| date=2011-04-13
| publisher=[[The Register]]
| accessdateaccess-date=2011-11-27}}</ref>
The language design focuses on [[Computer programming#Readability of source code|source code readability]], [[Predictability#Predictability in human–computer interaction|predictability]], [[Programming tool|toolability]], [[Modular programming|modularity]], and [[Metaprogramming|metaprogrammability]].<ref>{{cite web
| url=http://ceylon-lang.org/blog/2012/01/10/goals/
| title=Principles that guide this project
| date=2012-01-10
| last=King | first=Gavin
| accessdateaccess-date=2015-12-04}}</ref>
 
Important features of Ceylon include:<ref>{{cite web
| url=http://ceylon-lang.org/documentation/1.2/faq/language-design/#goals
| title=FAQ about language design: Goals
| accessdateaccess-date=2015-12-04}}</ref>
* aA type system enforcing null safety and list element existence at compile time;
* regularRegular syntax and semantics, avoiding special cases and primitively-defined constructs in favor of [[syntactic sugar]];
* supportSupport for generic programming and metaprogramming, with [[Reification (computer science)|reified]] [[Parametric polymorphism|generics]];
* modularityModularity built into the language, based on [[WildFly|JBoss modules]], interoperable with [[OSGi]]<ref>{{cite web
| url=http://ceylon-lang.org/blog/2014/10/10/ceylon-osgi-jee/
| title=Write in Ceylon, deploy as OSGI, use in Java EE
| date=2014-10-10
| last=Festal | first=David
| accessdateaccess-date=2015-12-04}}</ref> and [[Apache Maven|Maven]];<ref>{{cite web
| url=http://ceylon-lang.org/documentation/1.2/reference/repository/maven/#maven_repositories
| title=Maven repositories
| accessdateaccess-date=2015-12-04}}</ref> and
* powerful tools, including an Eclipse-based IDE.<ref>{{cite web
| url=http://ceylon-lang.org/documentation/1.2/ide/features/
| title=Features of Ceylon IDE
| accessdateaccess-date=2015-12-04}}</ref>
 
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]].
Line 122 ⟶ 136:
| url=http://ceylon-lang.org/documentation/1.2/spec/html_single/#compiletimesafety
| title=The Ceylon Language: §1.4.3 Compile-time safety for null values and flow-sensitive typing
| accessdateaccess-date=2015-12-04
| last=King | first=Gavin}}</ref>
 
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 <code>null</code> elements from a stream of values could be:
For example, the signature of a function that removes <code>null</code> elements from a stream of values could be:
 
<source lang="ceylon">
Line 132 ⟶ 145:
</source>
 
When <code>removeNulls</code> is called with a stream of <code>Integer|Null</code> elements, the result will be a stream of <code>&lt;Integer|Null&gt; & Object</code> elements, which simplifies to <code>Integer</code>.
the result will be a stream of <code>&lt;Integer|Null&gt; & Object</code> elements,
which simplifies to <code>Integer</code>.
 
==== Functions ====
Similarly to many modern languages, Ceylon supports first class functions and higher order functions, including function types and anonymous functions <ref>{{cite web|last=King|first=Gavin|title=The Ceylon Language: 4.7 Functions |url=http://ceylon-lang.org/documentation/1.2/spec/html/declarations.html#functions|accessdateaccess-date=5 December 2015}}</ref>
 
<source lang="ceylon">
Line 157 ⟶ 168:
String reversed2 = process("one", (text) => text+text);
</source>
 
==== 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. <ref>{{cite web|last=King|first=Gavin|title=The Ceylon Language: 4.5.8 Enumerated classes |url=http://ceylon-lang.org/documentation/1.2/spec/html/declarations.html#classeswithcases|accessdateaccess-date=6 December 2015}}</ref>
 
<source lang="ceylon">
Line 187 ⟶ 199:
</source>
 
==== Type Inferenceinference ====
Ceylon is strongly and statically typed, but also has support for type inference.
The <code>value</code> keyword is used to infer the type of a variable,
Line 208 ⟶ 220:
| url=http://ceylon-lang.org/documentation/1.2/spec/html_single/#typeinference
| title=The Ceylon Language: §3.2.9 Type inference
| accessdateaccess-date=2015-12-04
| last=King | first=Gavin}}</ref>
 
Line 222 ⟶ 234:
but any other function can be used as main calling the program with the --run parameter, like this:
 
<code>ceylon run --compile=force --run hello default</code>
 
== License ==
Line 228 ⟶ 240:
| url=http://ceylon-lang.org/code/licenses
| title=Ceylon: Licenses
| accessdateaccess-date=2015-12-04}}</ref> Part of the source code is licensed under LGPL.
 
== See also ==
{{Portal|Free and open-source software}}
* [[Dart (programming language)]], has its own VM, compiles to JS., Typetype system not very strict, supports [[mixin]]s.
* [[Fantom (programming language)]], compiles to JVM., Typetype system not very strict, supports [[mixin]]s.
 
== References ==