Jump to content

Ceylon (programming language)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 98.114.11.16 (talk) at 04:37, 12 January 2015 (statement is correct as written according to ref). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Ceylon
ParadigmObject-oriented
Designed byGavin King, Red Hat
First appeared2011
Stable release
1.1.0[1] / October 9, 2014; 10 years ago (2014-10-09)
Typing disciplineStatic, strong, safe
LicenseApache v2
Filename extensions.ceylon
Websiteceylon-lang.org
Influenced by
Java, Scala, Smalltalk

The Ceylon Project is a high-level, statically and strong-typed programming language and SDK, created by Red Hat. It is based on the Java programming language. Ceylon programs run on the Java Virtual Machine and JavaScript Virtual Machines.[2][3]

Ceylon aims at solving the following problems its developers experienced with Java:[4][5][6]

  1. improved structured data and user interfaces
  2. language level modularity
  3. support for first-class and higher-order functions
  4. do away with clumsy metaprogramming

The name "Ceylon" is an oblique reference to Java, in that Java and Sri Lanka, formerly known as Ceylon, are caffeine growing islands.[7]

Language features

Ceylon inherits most of Java's syntax. The following is the Ceylon version of the Hello world program:[8]

shared void hello() {
    print("Hello, World!");
}

Operator polymorphism

Ceylon will not provide operator overloading, as it was deemed to be generally confusing, but instead supports operator polymorphism, where an operator is a shortcut for a method of a built-in type. This is supposed to be safer and simpler than true operator overloading.

Interfaces

Interfaces are data structures that contain member definitions and not actual implementation. They are useful to define a contract between members in different types that have different implementations. Every interface is implicitly abstract.

An interface is implemented by a class using the satisfies keyword. It is allowed to implement more than one interface, in which case they are written after satisfies keyword in a comma-separated list. Ceylon allows for limited code besides for the definitions. An interface may not contain initialization logic, but can contain mixins.

shared interface Comparable<in T> {
   shared formal Comparison compare(T other);

   shared Boolean largerThan(T other) {
      return compare(other)==larger;
   }

   shared Boolean smallerThan(T other) {
      return compare(other)==smaller;
   }
   ...
}

Inheritance

Classes in Ceylon, as in Java, may only inherit from one class. Inheritance is declared using extends keyword. A class may reference itself using this keyword.

Abstract classes are classes that only serve as templates and cannot be instantiated. Otherwise it is just like an ordinary class.

Only abstract classes are allowed to have abstract methods. Abstract methods do not have any implementation and must be overridden by a subclass unless it is abstract itself.

License

All the work, including even its website, the language specification, and Ceylon Herd, is freely available under open source licenses.[9]

Type system

The main principles behind the type system are:[10]

  • no special types, i.e. no primitive or compound types, "everything is an object".
  • no special functionality for built-in types.
  • everything should always work like "you expect" from Java / C / etc.
  • do not add complexity to type systems known from Java. Therefore no method overloading, wildcard types.

Reception

Ryan Paul says that while Red Hat's motivation for Ceylon is "eccentric", King makes a good argument for it.[11] On the other hand, Neil McAllister states in InfoWorld that Ceylon is a mistake, and that Red Hat's efforts would be better supporting existing JVM based alternatives such as Scala. [7] Andrew Oliver of JavaWorld describes pre-v.1.0 Ceylon as "promising" but not currently ready for use.[12]

See also

References

  1. ^ King, Gavin. "Ceylon 1.1.0 is now available". Retrieved 14 October 2014.
  2. ^ "Ceylon 1.0 beta". Retrieved 2013-09-26.
  3. ^ "Project Ceylon – Red Hat builds Java replacement". The Register. 2011-04-13. Retrieved 2011-11-27.
  4. ^ Introducing the Ceylon Project – Gavin King presentations at QCon Beijing 2011
  5. ^ Gavin King (2011-04-13). "Ceylon". Retrieved 2011-11-27.
  6. ^ "Ceylon JVM Language". infoq.com. 2011-04-13. Retrieved 2011-11-27. First, I never billed this as a Java Killer or the next generation of the Java language. Not my words. Ceylon isn't Java, it's a new language that's deeply influenced by Java, designed by people who are unapologetic fans of Java. Java's not dying anytime soon, so nothing's killing it
  7. ^ a b McAllister, Neil (2011-04-22). "Red Hat's Ceylon language is an unneeded tempest in a teapot". Retrieved 2014-09-27.
  8. ^ Gavin King (2011-04-27). "Introduction to Ceylon Part 1". Retrieved 2011-11-27.
  9. ^ licences, official website
  10. ^ The Ceylon Type System, Gavin King.
  11. ^ Paul, Ryan (2011-04-11). "The rationale for Ceylon, Red Hat's new programming language". Retrieved 2014-09-27.
  12. ^ Oliver, Andrew (2013-04-25). "A first look at Gavin King's Ceylon". Retrieved 2014-09-27.