Top Banner
Ceylon Readability for the Modern Java Developer
16

Ceylon Readability for the Modern Java Developer.

Jan 04, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ceylon Readability for the Modern Java Developer.

CeylonReadability for the Modern Java Developer

Page 2: 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)

Page 3: Ceylon Readability for the Modern Java Developer.

Names, bindings, scoping• Case-sensitive

• Immutable by default

• Static scoping (Exception: JS)

Page 4: Ceylon Readability for the Modern Java Developer.

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

Page 5: Ceylon Readability for the Modern Java Developer.

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

Page 6: Ceylon Readability for the Modern Java Developer.

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

Page 7: Ceylon Readability for the Modern Java Developer.

Subprograms• Abstracted from “Callable” interface

• shared interface Callable<out Return, in Arguments>

given Arguments satisfies Anything[]{ }

Page 8: Ceylon Readability for the Modern Java Developer.

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);

Page 9: Ceylon Readability for the Modern Java Developer.

OOP Support• Ceylon supports “impure” OOP

• Lack of structural polymorphism

• Class is a constructor that produces a new instance of a given type

Page 10: Ceylon Readability for the Modern Java Developer.

Concurrency• Concurrent models unavailable by default

• Must use Java or a 3rd party module

Page 11: Ceylon Readability for the Modern Java Developer.

Readability• Familiar syntax

• Static typing for better understanding

• Annotations

• Hard for newer users to get used to heavy, static typing

Page 12: Ceylon Readability for the Modern Java Developer.

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

Page 13: Ceylon Readability for the Modern Java Developer.

Reliability• Runs on the JVM

• Static typing allows for much greater reliability

• Immutable nature also enhances reliability

Page 14: Ceylon Readability for the Modern Java Developer.

Cost• Free plug-in for Eclipse

• Open source

• Relies on JVM (resource intensive)

Page 15: Ceylon Readability for the Modern Java Developer.

Extras• Uses modules

• Ceylon Herd

• Java and Javascript can be fully integrated into Ceylon code

• Ceylon code can be compiled to JS code natively

Page 16: Ceylon Readability for the Modern Java Developer.

Questions• Do you have them?