Transcript Slides

Ceylon
Readability for the Modern Java Developer
History
•
Red Hat’s, Gavin King
•
Readability
•
Harmful constructs
•
1.0.0 (Nov. 2013)
•
1.1.0 (Oct. 2014)
•
Sri Lanka (1972)
Names, bindings, scoping
•
Case-sensitive
•
Immutable by default
•
Static scoping (Exception: JS)
Data Types
•
All objects (no primitives)
•
Integer, Float, String
•
Postfix “?” allows for null
•
Postfix “+” must contain a value
•
Postfix “*” denotes sequential (Iterating over arguments)
•
“value” keyword for type inference
•
Intersection and Union types ( & |)
•
“alias” keyword
Expression and Assignments
•
Same as Java
•
Pure, first-order functions (no object burden)
•
<keyword(s)> <type> <id> = <value> || <function>;
{String*} & Correspondence<Integer,String> strings = [“Hello”,”world”];
String? str = strings.get(0); //Call get() of Correspondence
Integer size = strings.size; //Call size of Iterable
Control Structures
•
If, switch, assert, for, while, try-catch
•
Curly braces regardless of number of lines
•
C-style for loops unnecessary (use range operator)
•
For-loops can have “else” block, optionally
•
No do-while
•
Remove type to infer exception type
Subprograms
•
Abstracted from “Callable” interface
•
shared interface Callable<out Return, in Arguments>
given Arguments satisfies Anything[]{ }
Abstraction and Encapsulation
•
•
Helps ease “this” usage
No “new” keyword for instantiation
"A polar coordinate" //Class annotation
class Polar(Float angle, Float radius) {
shared Polar rotate(Float rotation)
=> Polar(angle+rotation, radius);
shared Polar dilate(Float dilation)
=> Polar(angle, radius*dilation);
shared String description
= "(``radius``,``angle``)";
}
print(Polar(0.37, 10.0).description);
OOP Support
•
Ceylon supports “impure” OOP
•
Lack of structural polymorphism
•
Class is a constructor that produces a new instance of a given type
Concurrency
•
Concurrent models unavailable by default
•
Must use Java or a 3rd party module
Readability
•
Familiar syntax
•
Static typing for better understanding
•
Annotations
•
Hard for newer users to get used to heavy, static typing
Writability
•
Expressiveness is encouraged when writing in Ceylon
•
Great workflow
•
Functions and fields can be written as standalone (no class needed)
•
Standalones compiled into classes within the “.car” file
Reliability
•
Runs on the JVM
•
Static typing allows for much greater reliability
•
Immutable nature also enhances reliability
Cost
•
Free plug-in for Eclipse
•
Open source
•
Relies on JVM (resource intensive)
Extras
•
Uses modules
•
Ceylon Herd
•
Java and Javascript can be fully integrated into Ceylon code
•
Ceylon code can be compiled to JS code natively
Questions
•
Do you have them?