SlideShare a Scribd company logo
1 of 33
the language and its tools
          Max Rydahl Andersen
                 Red Hat
      http://about.me/maxandersen

           EclipseCon 2012
About Me
•   Max Rydahl Andersen
•   Lead of JBoss Tools & Developer Studio
•   Committer on Hibernate Core, Seam & Weld
•   Co-host of JBoss Community Asylum Podcast
•   @maxandersen on Twitter
•   http://about.me/maxandersen
Ceylon Origins
•   Created and lead by Gavin King
•   Helped by others at JBoss
•   Frustrated love for Java
•   Lessons learned working in JCP
•   Starting blocks
    •   on the JVM
    •   in the spirit of Java
    •   practical
•   Slashdotted (with no web site)
Language Introduction
              z
doc "A familiar Rectangle"
class SimpleRectangle() {
	 Integer width = 0;
	 Integer height = 0;
	
	 function area() {
	 	 return width * height;
	 }
}
doc "A real Rectangle."
shared class Rectangle(Integer width, Integer
height) {
	 // initializer
  	if(width <=0 || height <=0) {
  		 throw;
  	}
  	
	 shared Integer width = width;
	 shared Integer height = height;
	
	 shared Integer area() {
	 	 return width * height;
	 }
	
}
Modular by default

package com.acme.dotcom.domain               package com.acme.dotcom.business
shared class Foo           class Woo         shared class Action       class Reaction
shared String bar()    shared String war()   shared String ping()       String pong()

   String baz()           String waz()
Immutable by default

Integer width = w;
Immutable by default

Integer width = w;
	
variable Integer width := w;
doc "A variable Rectangle with properties."
shared class VariableRectangle(Integer w,
Integer h) {
	
  shared variable Integer width := w;
	 shared variable Integer height := h;
	
	 shared Integer badArea {
	 	 return width * 42;
	 }             Text
	
	 assign badArea {
	 	 width := badArea/42;
	 }
	
	 shared actual String string {
	 	 return "w:" width ",h:" height "";
	 }
}
shared class
Point(Integer x, Integer y) {
    shared Integer x = x;
    shared Integer y = y;
}

shared class
Point3D (Integer x, Integer y, Integer z)
       extends Point(x, y) {
    shared Integer z = z;
}
Integer attribute = 1;
Integer attribute2 { return 2; }
void topmethod(){}
interface Interface{}

class Class(Integer x){
	 Integer attribute = x;
	 Integer attribute2 { return x; }
	 class InnerClass(){}
	 interface InnerInterface{}
	
	 void method(Integer y){
	 	 Integer attribute = x;
	 	 Integer attribute2 { return y; }
	 	 class LocalClass(){}
	 	 interface LocalInterface{}
	 	 void innerMethod(Integer y){}
	 }
}
No
     NullPointerException’s
void typesafety() {

     Rectangle? rectOrNoRect() { return null; }
     Rectangle? rect = rectOrNoRect();

     print(rect.string);	// compile error

	   if(exists rect) {
	   	 print(rect.string);
	   } else {
	   	 print("No rectangle");
	   }
}
What is in a



               Type ?
Union Type

• To be able to hold values among a list of
  types
• We must check the actual type before use
• `TypeA|TypeB`
• `Type?` is an alias for `Type|Nothing`
class Apple()
{ shared void eat() { print("Eat " this ""); }}

class Broccoli()
{ shared void throwAway() { print("Throw " this ""); } }

void unions() {
	 Sequence<Apple|Broccoli> plate =
    {Apple(), Broccoli()};
	
for (Apple|Broccoli food in plate) {
	 	 print("Looking at: " food.string "");
	 	 if (is Apple food) {
	 	 	 food.eat();
	 	 } else if (is Broccoli food) {
	 	 	 food.throwAway();
	 	 }
	 }
}
Intersection Type
interface Food { shared formal void eat(); }

interface Drink { shared formal void drink(); }

class Guinness() satisfies Food & Drink {
	 shared actual void drink() {}
	 shared actual void eat() {}
}

void intersections(){
	 Food & Drink specialStuff = Guinness();
	 specialStuff.drink();
	 specialStuff.eat();
}
No Overloading
No Overloading
   •   WTF!?
No Overloading
   •   WTF!?
   •   is overloading evil ?
No Overloading
   •   WTF!?
   •   is overloading evil ?
No Overloading
   •   WTF!?
   •   is overloading evil ?


   •   Only usecase:
       •   Optional parameters
       •   Work on different subtypes
class
Rectangle(Integer width = 2, Integer height = 3) {
    shared Integer area(){
        return width * height;
    }
}

void method() {
    Rectangle rectangle = Rectangle();
    Rectangle rectangle2 = Rectangle {
        width = 3;
        height = 4;
    };
}
interface Shape2D of Triangle|Circle|Figure2D {}
class Triangle() satisfies Shape2D {}
class Circle() satisfies Shape2D {}
class Figure2D() satisfies Shape2D {}

void workWithRectangle(Triangle rect){}
void workWithCircle(Circle circle){}
void workWithFigure2D(Figure2D fig){}

void supportsSubTyping(Shape2D fig) {
    switch(fig)
    case(is Triangle) {
      workWithRectangle(fig);
    }
    case(is Circle) {
      workWithCircle(fig);
    }
    case(is Figure2D) {
      workWithFigure2D(fig);
    }
}
Other features
•   Interface based Operator overloading
•   Closures
•   Annotations
•   Type aliases
•   Meta-model
•   Interception
•   Interface with default implementations / “multiple inheritance”
•   Declarative syntax for datastructures
•   ...and more
Table table = Table {
    title="Squares";
    rows=5;
    border = Border {
        padding=2;
        weight=1;
    };
    Column {
        heading="x";
        width=10;
        String content(Natural row) {
             return row.string;
        }
    },
    Column {
        heading="x**2";
        width=12;
        String content(Natural row) {
             return (row**2).string;
        }
    }
};
Ceylon Today
•   Website (http://ceylon-lang.org)
•   Active and growing community
•   Fully open source (http://github.com/ceylon)
•   Targets JVM and JS (http://try.ceylon-lang.org)
•   Milestone 2 just released
    •   Java interopability
    •   Full IDE support
Ceylon IDE
Ceylon IDE

•   Incremental compiler and error reporting
•   Full editor with outline, folding and navigation
•   Refactoring, Quick fixes, Search
•   Wizards, Module repository integration
•   Debugging
Ceylon IDE -
      Behind the Scenes
•   Considered XText, DLTK, IMP & “DIY”
•   XText - very complete, but does not allow Antlr
    and require XText custom parser and
    typechecker
•   DLTK - allows Antlr, but at the time no good
    documentation and a preference to by “too
    dynamic language focused”
•   IMP - allows antlr and custom typechecker and
    just worked, but..
Ceylon IDE -
            Next Steps
•   IMP has many limitations when you push it
•   XText still too much “XText”
•   DLTK looks interesting
•   End result probably a mix of the above in a
    “DIY” solution
•   Contributors welcome!
Ceylon - Tomorrow
•   M3:
    •   - Annotations
    •    - Reified type parameters
    •    - Interception
    •    - Meta-model
    •   <Your Name Here>
?
•   http://try.ceylon-lang.org
•   http://ceylon-lang.org
•   http://ceylon.github.com/
       Text
        Text




            bit.ly/ec12ceylon

More Related Content

What's hot

Scala jeff
Scala jeffScala jeff
Scala jeff
jeff kit
 

What's hot (19)

Java Performance MythBusters
Java Performance MythBustersJava Performance MythBusters
Java Performance MythBusters
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Kotlin
KotlinKotlin
Kotlin
 
Scala jeff
Scala jeffScala jeff
Scala jeff
 
Java for beginners
Java for beginnersJava for beginners
Java for beginners
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
Poniendo Kotlin en producción a palos (Kotlin in production, the hard way)
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
Intro to Kotlin
Intro to KotlinIntro to Kotlin
Intro to Kotlin
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
Xbase - Implementing Domain-Specific Languages for Java
Xbase - Implementing Domain-Specific Languages for JavaXbase - Implementing Domain-Specific Languages for Java
Xbase - Implementing Domain-Specific Languages for Java
 
Python internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvandPython internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvand
 
Scala jargon cheatsheet
Scala jargon cheatsheetScala jargon cheatsheet
Scala jargon cheatsheet
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
 
Kotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparisonKotlin Language Features - A Java comparison
Kotlin Language Features - A Java comparison
 
Java OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - InheritanceJava OOP Programming language (Part 5) - Inheritance
Java OOP Programming language (Part 5) - Inheritance
 
Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010
 

Viewers also liked

Viewers also liked (9)

Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming Ceylon From Here to Infinity: The Big Picture and What's Coming
Ceylon From Here to Infinity: The Big Picture and What's Coming
 
The Ceylon Type System - Gavin King presentation at QCon Beijing 2011
The Ceylon Type System - Gavin King presentation at QCon Beijing 2011The Ceylon Type System - Gavin King presentation at QCon Beijing 2011
The Ceylon Type System - Gavin King presentation at QCon Beijing 2011
 
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014
 
Ceylon/Java interop by Tako Schotanus
Ceylon/Java interop by Tako SchotanusCeylon/Java interop by Tako Schotanus
Ceylon/Java interop by Tako Schotanus
 
Ceylon introduction by Stéphane Épardaud
Ceylon introduction by Stéphane ÉpardaudCeylon introduction by Stéphane Épardaud
Ceylon introduction by Stéphane Épardaud
 
Ceylon.build by Loïc Rouchon
Ceylon.build by Loïc RouchonCeylon.build by Loïc Rouchon
Ceylon.build by Loïc Rouchon
 
Ceylon SDK by Stéphane Épardaud
Ceylon SDK by Stéphane ÉpardaudCeylon SDK by Stéphane Épardaud
Ceylon SDK by Stéphane Épardaud
 
Ceylon.test by Thomáš Hradec
Ceylon.test by Thomáš HradecCeylon.test by Thomáš Hradec
Ceylon.test by Thomáš Hradec
 
Introducing the Ceylon Project - Gavin King presentation at QCon Beijing 2011
Introducing the Ceylon Project - Gavin King presentation at QCon Beijing 2011Introducing the Ceylon Project - Gavin King presentation at QCon Beijing 2011
Introducing the Ceylon Project - Gavin King presentation at QCon Beijing 2011
 

Similar to Ceylon - the language and its tools

Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
mircodotta
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
frwebhelp
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
Miles Sabin
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java Developers
Skills Matter
 

Similar to Ceylon - the language and its tools (20)

Kotlin for Android Development
Kotlin for Android DevelopmentKotlin for Android Development
Kotlin for Android Development
 
core java
core javacore java
core java
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 
CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
 
BCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
C# for Java Developers
C# for Java DevelopersC# for Java Developers
C# for Java Developers
 
Clojure Small Intro
Clojure Small IntroClojure Small Intro
Clojure Small Intro
 
Clojure class
Clojure classClojure class
Clojure class
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
A Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java DevelopersA Brief Introduction to Scala for Java Developers
A Brief Introduction to Scala for Java Developers
 
Miles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java DevelopersMiles Sabin Introduction To Scala For Java Developers
Miles Sabin Introduction To Scala For Java Developers
 
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
 
Scala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian DragosScala: Object-Oriented Meets Functional, by Iulian Dragos
Scala: Object-Oriented Meets Functional, by Iulian Dragos
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
 
ActiveJDBC - ActiveRecord implementation in Java
ActiveJDBC - ActiveRecord implementation in JavaActiveJDBC - ActiveRecord implementation in Java
ActiveJDBC - ActiveRecord implementation in Java
 

More from Max Andersen

JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010
Max Andersen
 

More from Max Andersen (16)

Quarkus Denmark 2019
Quarkus Denmark 2019Quarkus Denmark 2019
Quarkus Denmark 2019
 
Docker Tooling for Eclipse
Docker Tooling for EclipseDocker Tooling for Eclipse
Docker Tooling for Eclipse
 
OpenShift: Java EE in the clouds
OpenShift: Java EE in the cloudsOpenShift: Java EE in the clouds
OpenShift: Java EE in the clouds
 
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
Case study: JBoss Developer Studio, an IDE for Web, Mobile and Cloud applicat...
 
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
Red Hat and Oracle: Delivering on the Promise of Interoperability in Java EE 7
 
Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOF
 
Google analytics for Eclipse Plugins
Google analytics for Eclipse PluginsGoogle analytics for Eclipse Plugins
Google analytics for Eclipse Plugins
 
JBoss Enterprise Maven Repository
JBoss Enterprise Maven RepositoryJBoss Enterprise Maven Repository
JBoss Enterprise Maven Repository
 
Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?
 
Making Examples Accessible
Making Examples AccessibleMaking Examples Accessible
Making Examples Accessible
 
OpenShift Express Intro
OpenShift Express IntroOpenShift Express Intro
OpenShift Express Intro
 
JBoss AS 7 from a user perspective
JBoss AS 7 from a user perspectiveJBoss AS 7 from a user perspective
JBoss AS 7 from a user perspective
 
How to be effective with JBoss Developer Studio
How to be effective with JBoss Developer StudioHow to be effective with JBoss Developer Studio
How to be effective with JBoss Developer Studio
 
JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010JBoss Asylum Podcast Live from JUDCon 2010
JBoss Asylum Podcast Live from JUDCon 2010
 
How To Make A Framework Plugin That Does Not Suck
How To Make A Framework Plugin That Does Not SuckHow To Make A Framework Plugin That Does Not Suck
How To Make A Framework Plugin That Does Not Suck
 
Kickstart Jpa
Kickstart JpaKickstart Jpa
Kickstart Jpa
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Ceylon - the language and its tools

  • 1. the language and its tools Max Rydahl Andersen Red Hat http://about.me/maxandersen EclipseCon 2012
  • 2. About Me • Max Rydahl Andersen • Lead of JBoss Tools & Developer Studio • Committer on Hibernate Core, Seam & Weld • Co-host of JBoss Community Asylum Podcast • @maxandersen on Twitter • http://about.me/maxandersen
  • 3. Ceylon Origins • Created and lead by Gavin King • Helped by others at JBoss • Frustrated love for Java • Lessons learned working in JCP • Starting blocks • on the JVM • in the spirit of Java • practical • Slashdotted (with no web site)
  • 5. doc "A familiar Rectangle" class SimpleRectangle() { Integer width = 0; Integer height = 0; function area() { return width * height; } }
  • 6. doc "A real Rectangle." shared class Rectangle(Integer width, Integer height) { // initializer if(width <=0 || height <=0) { throw; } shared Integer width = width; shared Integer height = height; shared Integer area() { return width * height; } }
  • 7. Modular by default package com.acme.dotcom.domain package com.acme.dotcom.business shared class Foo class Woo shared class Action class Reaction shared String bar() shared String war() shared String ping() String pong() String baz() String waz()
  • 9. Immutable by default Integer width = w; variable Integer width := w;
  • 10. doc "A variable Rectangle with properties." shared class VariableRectangle(Integer w, Integer h) { shared variable Integer width := w; shared variable Integer height := h; shared Integer badArea { return width * 42; } Text assign badArea { width := badArea/42; } shared actual String string { return "w:" width ",h:" height ""; } }
  • 11. shared class Point(Integer x, Integer y) { shared Integer x = x; shared Integer y = y; } shared class Point3D (Integer x, Integer y, Integer z) extends Point(x, y) { shared Integer z = z; }
  • 12. Integer attribute = 1; Integer attribute2 { return 2; } void topmethod(){} interface Interface{} class Class(Integer x){ Integer attribute = x; Integer attribute2 { return x; } class InnerClass(){} interface InnerInterface{} void method(Integer y){ Integer attribute = x; Integer attribute2 { return y; } class LocalClass(){} interface LocalInterface{} void innerMethod(Integer y){} } }
  • 13. No NullPointerException’s void typesafety() { Rectangle? rectOrNoRect() { return null; } Rectangle? rect = rectOrNoRect(); print(rect.string); // compile error if(exists rect) { print(rect.string); } else { print("No rectangle"); } }
  • 14. What is in a Type ?
  • 15. Union Type • To be able to hold values among a list of types • We must check the actual type before use • `TypeA|TypeB` • `Type?` is an alias for `Type|Nothing`
  • 16. class Apple() { shared void eat() { print("Eat " this ""); }} class Broccoli() { shared void throwAway() { print("Throw " this ""); } } void unions() { Sequence<Apple|Broccoli> plate = {Apple(), Broccoli()}; for (Apple|Broccoli food in plate) { print("Looking at: " food.string ""); if (is Apple food) { food.eat(); } else if (is Broccoli food) { food.throwAway(); } } }
  • 17. Intersection Type interface Food { shared formal void eat(); } interface Drink { shared formal void drink(); } class Guinness() satisfies Food & Drink { shared actual void drink() {} shared actual void eat() {} } void intersections(){ Food & Drink specialStuff = Guinness(); specialStuff.drink(); specialStuff.eat(); }
  • 19. No Overloading • WTF!?
  • 20. No Overloading • WTF!? • is overloading evil ?
  • 21. No Overloading • WTF!? • is overloading evil ?
  • 22. No Overloading • WTF!? • is overloading evil ? • Only usecase: • Optional parameters • Work on different subtypes
  • 23. class Rectangle(Integer width = 2, Integer height = 3) { shared Integer area(){ return width * height; } } void method() { Rectangle rectangle = Rectangle(); Rectangle rectangle2 = Rectangle { width = 3; height = 4; }; }
  • 24. interface Shape2D of Triangle|Circle|Figure2D {} class Triangle() satisfies Shape2D {} class Circle() satisfies Shape2D {} class Figure2D() satisfies Shape2D {} void workWithRectangle(Triangle rect){} void workWithCircle(Circle circle){} void workWithFigure2D(Figure2D fig){} void supportsSubTyping(Shape2D fig) { switch(fig) case(is Triangle) { workWithRectangle(fig); } case(is Circle) { workWithCircle(fig); } case(is Figure2D) { workWithFigure2D(fig); } }
  • 25. Other features • Interface based Operator overloading • Closures • Annotations • Type aliases • Meta-model • Interception • Interface with default implementations / “multiple inheritance” • Declarative syntax for datastructures • ...and more
  • 26. Table table = Table { title="Squares"; rows=5; border = Border { padding=2; weight=1; }; Column { heading="x"; width=10; String content(Natural row) { return row.string; } }, Column { heading="x**2"; width=12; String content(Natural row) { return (row**2).string; } } };
  • 27. Ceylon Today • Website (http://ceylon-lang.org) • Active and growing community • Fully open source (http://github.com/ceylon) • Targets JVM and JS (http://try.ceylon-lang.org) • Milestone 2 just released • Java interopability • Full IDE support
  • 29. Ceylon IDE • Incremental compiler and error reporting • Full editor with outline, folding and navigation • Refactoring, Quick fixes, Search • Wizards, Module repository integration • Debugging
  • 30. Ceylon IDE - Behind the Scenes • Considered XText, DLTK, IMP & “DIY” • XText - very complete, but does not allow Antlr and require XText custom parser and typechecker • DLTK - allows Antlr, but at the time no good documentation and a preference to by “too dynamic language focused” • IMP - allows antlr and custom typechecker and just worked, but..
  • 31. Ceylon IDE - Next Steps • IMP has many limitations when you push it • XText still too much “XText” • DLTK looks interesting • End result probably a mix of the above in a “DIY” solution • Contributors welcome!
  • 32. Ceylon - Tomorrow • M3: • - Annotations • - Reified type parameters • - Interception • - Meta-model • <Your Name Here>
  • 33. ? • http://try.ceylon-lang.org • http://ceylon-lang.org • http://ceylon.github.com/ Text Text bit.ly/ec12ceylon

Editor's Notes

  1. \n
  2. \n
  3. JBoss: Emmanuel, Pete Muir, David Lloyd, Ales Justin, and more...\n\n\n
  4. \n
  5. simple class, should be nice and familiar.\nA few rules: classes always starts with a capital letter, and methods/attributes always starts with a lowercase letter.\n\nThe doc is a string/annotation to help \narea is a function using type inference.\n\nBut where is the constructor ?\n
  6. constructor in the blocks\n\nThe area now have to be explicit about its type to avoid exposing too specific types.\n\nstarting to use shared for scope/visibility.\n\n\n
  7. shared is the only scope modifier.\nmodule, package, class/methods\n\nshared are seen by those within my parent and outside if parent is shared too.\nYou can talk to the kids if you also can see the parents.\n\nTo be public you really need to mean it\n
  8. To have mutable data you really need to mean it.\n
  9. variable properties with values and methods (badArea)\n\n\n
  10. class extends - parameters passed into the class constructor.\n
  11. Ceylon is extremely regular - everything can be nested, allowing a lot more modularity than we are used to in java.\n
  12. There is no way ceylon code can get an NPE. Its checked by the compiler and if you must you use if exists or the elvis operator ?.\n\n
  13. One of the exotic but key features of Ceylon is its type system - it is after all a strongly typed language. \n\n
  14. You are used to having a variable just having &amp;#x201C;one type&amp;#x201D; but in Ceylon they can actually be representing multiple types all at the same time.\n\n
  15. Notice that I can call shared methods on union types - such as food.string.\nIf I tried to call food.eat() before it would not let me. \n
  16. Here Guiness is both a food and drink and thus I can call both Food and Drink methods - but I can&amp;#x2019;t assign just a Food.\n
  17. \n
  18. \n
  19. \n
  20. \n
  21. Just one rectangle constructor/method - all handled with default parameters.\n\nYou can use named parameters too.\n
  22. use type switch for handling visitor patterns and similar type based &amp;#x2018;overloading&amp;#x2019;\n\n\n\n\n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n