Ceylon Project
Encyclopedia
The Ceylon Project is an upcoming programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 and SDK, created by Red Hat
Red Hat
Red Hat, Inc. is an S&P 500 company in the free and open source software sector, and a major Linux distribution vendor. Founded in 1993, Red Hat has its corporate headquarters in Raleigh, North Carolina with satellite offices worldwide....

. It is based on the Java programming language
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 and when it is released, will run under the Java Virtual Machine
Java Virtual Machine
A Java virtual machine is a virtual machine capable of executing Java bytecode. It is the code execution component of the Java software platform. Sun Microsystems stated that there are over 4.5 billion JVM-enabled devices.-Overview:...

.

The project is described to be what a language and SDK for business computing would look like if it were designed today, keeping in mind the successes and failures of the Java language and Java SE SDK. The project has been referred to by industry analysts as a "Java killer", though Red Hat themselves reject this term.

Language features

Ceylon inherits most of Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

's syntax. The following is the Ceylon version of the Hello world program
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

.:

void hello {
writeLine("Hello World!");
}

Operator overloading

Ceylon will not provide operator overloading, as it was deemed to be generally confusing, but instead supports operator polymorphism
Polymorphism in object-oriented programming
Subtype polymorphism, almost universally called just polymorphism in the context of object-oriented programming, is the ability to create a variable, a function, or an object that has more than one form. The word derives from the Greek "πολυμορφισμός" meaning "having multiple forms"...

, 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 mixin
Mixin
In object-oriented programming languages, a mixin is a class that provides a certain functionality to be inherited or just reused by a subclass, while not meant for instantiation , Mixins are synonymous functionally with abstract base classes...

s.


shared interface Comparable {
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
Inheritance (computer science)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

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.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK