SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Introducing the Ceylon Project
       Gavin King
       Red Hat
       in.relation.to/Bloggers/Gavin




Saturday, April 9, 2011
About this session

       • I’m going to talk about why we started work on this project
       • I’m going to cover some basic examples at a very shallow level
       • I’m not going to get into the details of the type system
       • If you’re interested, come to my second presentation: “The Ceylon
         Language”
       • This project is not yet available to the public and has not even been officially
         announced
              • QCon China is getting a special sneak preview - the first time I’m talking
                about the project in public!




Saturday, April 9, 2011
Why we’re (still) fans of Java

       • Java was the first language to feature the following “perfect” combination of
         features:
              • virtual machine execution, giving platform independence
              • automatic memory management and safe referencing
              • static typing
              • lexical scoping
              • readable syntax
       • Therefore, Java was the first language truly suitable for
              • large team development, and
              • large-scale deployments of multi-user applications.
       • It turns out that large teams developing multi-user applications describes the
         most interesting class of project in business computing



Saturday, April 9, 2011
Why we’re (still) fans of Java

       • Java is easy
              • Java’s syntax is rooted in standard, everyday mathematical notion taught
                in high schools and used by mathematicians, engineers, and software
                developers
                    • not the lambda calculus used only by theoretical computer scientists
              • The language is mostly simple to learn and the resulting code is extremely
                easy to read and understand
              • Static typing enables sophisticated tooling including automatic refactoring,
                code navigation, and code completion
                    • this kind of tooling is simply not possible without static typing
       • Java is robust
              • With static typing, automatic memory management, and no C-style
                pointers, most bugs are found at development time



Saturday, April 9, 2011
Why we’re (still) fans of Java

       • The Java community is made of ordinary people trying to solve practical
         problems
              • Java is unashamedly focussed on problems relevant to business
                computing
              • The culture is a culture of openness that rejects dominance by any single
                company or interest
              • Java has remained committed to platform independence and portability
              • The community has a huge tradition of developing and sharing reusable
                code (frameworks, libraries)




Saturday, April 9, 2011
Why we’re frustrated

       • After ten often-frustrating years developing frameworks for Java, we simply
         can’t go any further without a better solution for defining structured data and
         user interfaces
              • Java is joined at the hip with XML, and this hurts almost every Java
                developer almost every day
              • There is simply no good way to define a user interface in Java, and that is
                a language problem
       • Lack of a language-level modularity solution resulted in the creation of
         monstrous, over-complex, harmful technologies like Maven and OSGi.
              • Instead of modules, Java has multiple platforms, which has divided the
                developer community
       • Lack of support for first-class and higher-order functions results in much
         unnecessary verbosity in everyday code
       • Meta-programming in Java is clumsy and frustrating, reducing the quality of
         framework and other generic code

Saturday, April 9, 2011
Why we’re frustrated

       • A number of other “warts” and mistakes annoy us every day, for example
              • getters/setters
              • arrays and primitive types
              • non-typesafety of null values
              • the dangerous synchronized keyword
              • clumsy annotation syntax
              • verbose constructor syntax
              • broken = operator
              • checked exceptions
              • complex parametric polymorphism system (generics) that few developers
                completely understand
              • ad-hoc (broken?) block structure
              • clumsy, error-prone instanceof and typecast syntax

Saturday, April 9, 2011
Why we’re frustrated

       • Most of all, we’re frustrated by the SE SDK
              • designed in haste 15 years ago, and never properly modernized, it still has
                an experimental, work-in-progress feel about it
              • but is simultaneously bloated with obscure stuff
              • features some truly bizarre things
                    • e.g. all Java objects are semaphores ?!
              • many basic tasks are absurdly difficult to accomplish
                    • e.g. anything involving java.io or java.lang.reflect
              • overuses stateful (mutable) objects
                    • especially the highly overrated collections framework




Saturday, April 9, 2011
The Ceylon Project

       • What would a language and SDK for business computing look like if it were
         designed today, with an eye to the successes and failures of the Java
         language and Java SE SDK?




Saturday, April 9, 2011
The Ceylon Project

       • This much is clear:
              • It would run on the Java Virtual Machine
              • It would feature static typing
              • It would feature automatic memory management and safe referencing
              • It would retain Java’s readability
              • It would feature first-class and higher-order functions
              • It would provide a declarative syntax for defining user interfaces and
                structured data
              • It would feature built-in modularity
              • It would strive to be easy to learn and understand




Saturday, April 9, 2011
The Ceylon Project

       • Unfortunately, there’s no existing language that truly fits these requirements
       • My team has spent the past two years designing what we think the language
         should look like, writing a language specification, an ANTLR grammar, and a
         prototype compiler
              • You can’t write code in the language just yet!
              • We plan an initial release of the compiler later this year
       • I can’t cover the whole language, or even explain the most interesting
         principles and concepts in the short time I have here
              • The most I can do is give a taste of what some code looks like




Saturday, April 9, 2011
Hello World

                          put this in a file called hello.ceylon


                      void hello() {
                          writeLine(“Hello World!”);
                      }

                                 The language has a strict recursive, regular
                                 block structure governing visibility and
                                 lifecycle of declarations. Therefore, there’s no
                                 equivalent of Java’s static. Instead, a
                                 toplevel method declaration fills a similar role.




Saturday, April 9, 2011
Hello World

                     API documentation is specified using
                     annotations.


                      doc “The classic Hello World program”
                      by “Gavin”
                      void hello() {
                          writeLine(“Hello World!”);
                      }
                                                   Modifiers like abstract, variable,
                                                   shared, deprecated aren’t
                                                   keywords, they’re just annotations.



Saturday, April 9, 2011
Hello World

                    void is a keyword!

                      void hello(String name) {
                          writeLine(“Hello “ name ”!”);
                      }

                                         String interpolation has a simple
                                         syntax - very useful in user interface
                                         definitions.




Saturday, April 9, 2011
Hello World

                                       Defaulted parameters are optional.

                      void hello(String name = ”World”) {
                          writeLine(“Hello “ name ”!”);
                      }

                              Defaulted parameters are extremely
                              useful, since Ceylon does not
                              support method overloading (or any
                              other kind of overloading).




Saturday, April 9, 2011
Hello World

                          If a value of type T can be null, it must be declared as type
                          Optional<T>, which may be abbreviated to T?.

                     void hello() {
                         String? name = process.args.first;
                         if (exists name) {
                             writeLine(“Hello “ name ”!”);
                         }
                         else {
                             writeLine(“Hello World!”);
                         }
                     }          Use of an optional value must be guarded by
                                          the if (exists ... ) construct. Therefore,
                                          NullPointerExceptions are impossible.

Saturday, April 9, 2011
Classes
                          All values are instances of a class.

                     class Counter() {
                         variable Natural count := 0;
                                       Attributes and local variables are immutable by default.
                                       Assignable values must be annotated variable.

                              shared void increment() {
                                  count++;
                              }
                                          The shared annotation makes a
                                          declaration visible outside the block
                     }                    in which it is defined. By default, any
                                          declaration is block local.


Saturday, April 9, 2011
Classes

                     class Counter() {
                         variable Natural count := 0;
                         shared void increment() {
                             count++;
                         }
                         shared Natural currentValue {
                             return count;
                         }        A getter looks like a method
                     }            without a parameter list.



                                An attribute may be a simple value, a getter,
                                or a getter/setter pair.

Saturday, April 9, 2011
Classes


                                               There is no new keyword.

                      Counter c = Counter();
                      c.increment();
                      writeLine(c.currentValue);
                                               Attribute getters are called just like
                                              simple attributes. The client doesn’t
                                              care what type of attribute it is.


                           Attributes are polymorphic. A subclass may override
                          a superclass attribute. It may even override a simple
                          attribute with a getter or vice versa!


Saturday, April 9, 2011
Classes

                  The local keyword may be used in place
                  of a type for block-local declarations.

                      local c = Counter();
                      c.increment();
                      writeLine(c.currentValue);


                                      You can’t use local for shared
                                      declarations. One consequence of this
                                      is that the compiler can do type
                                      inference in a single pass of the code!



Saturday, April 9, 2011
Classes

                     class Counter() {
                         variable Natural count := 0;
                         ...
                         shared Natural currentValue {
                             return count;
                         }
                         shared assign currentValue {
                             count := currentValue;
                         }
                     }         Assignment to a variable value or attribute
                                    setter is done using the := operator. The =
                                    specifier is used only for specifying immutable
                                    values.


Saturday, April 9, 2011
Classes

                          There is no constructor syntax. Instead, the
                          class itself declares parameters, and the body
                          of the class may contain initialization logic.


          class Counter(Natural initialValue) {
              if (initialValue>1000) {
                  throw OutOfRangeException()
              }
              variable Integer count := initialValue;
              ...
          }
                                    How can a class have multiple constructors?
                                    It can’t! There’s no overloading in Ceylon.



Saturday, April 9, 2011
Sequences

                          Sequences are immutable objects that are a bit like arrays.

        Sequence<String> itin =
                Sequence(“Guanajuato”, “Mexico”,
                   “Vancouver”, “Auckland”,
                   “Melbourne”);

        String? mex = itin.value(1);
        Sequence<String> layovers =
                itin.range(1..3);

        Sequence<String> longer = join(itin,
                Sequence(“Hong Kong”, “Beijing”));

Saturday, April 9, 2011
Sequences

                          Syntactic abbreviations allow us to eliminate the verbosity.

        String[] itin =
                { “Guanajuato”, “Mexico”,
                   “Vancouver”, “Auckland”,
                   “Melbourne” };

        String? mex = itin[1];
        String[] layovers =
                itin[1..3];

        String[] longer = itin +
                { “Hong Kong”, “Beijing” };

Saturday, April 9, 2011
Higher-order functions

                               A parameter may be a method signature,
                               meaning that it accepts references to methods.


                     void repeat(Natural times,
                             void perform()) {
                         for (Natural n in 1..times) {
                             perform();
                         }
                                The “functional” parameter may be
                     }          invoked just like any other method.




Saturday, April 9, 2011
Higher-order functions


                          repeat(3, hello);

                                  A reference to a method is just the name of
                                  the method, without an argument list.




Saturday, April 9, 2011
Higher-order functions


                          repeat(3, person.sayHello);

                                  We can even “curry” the method receiver.




Saturday, April 9, 2011
Higher-order functions

                                   We may define a method “by reference”.

                          void hello(String name) = hello;
                                                         The name of the method, without
                                                         arguments, refers to the method itself.

        void hello2(String name) = person.sayHello;


                          Unlike other languages with first-class functions,
                          Ceylon doesn’t have a syntax for anonymous
                          functions (“lambdas”) that appear in expressions.




Saturday, April 9, 2011
Higher-order functions
                                    The method name
                          repeat(3)
                          perform() { A parameter name
                              writeLine(“Hola Mundo!”);
                          };
                                    Alternatively, a method may be defined inline,
                                    as part of the invocation. This syntax is stolen
                                    from Smalltalk.




Saturday, April 9, 2011
Higher-order functions

                          repeat(3)      We may omit the empty parameter list.
                          perform {
                              writeLine(“Hola Mundo!”);
                          };



                              This allows a library to define syntax for new control
                              structures, assertions, comprehensions, etc.




Saturday, April 9, 2011
Higher-order functions

                            A method may declare multiple lists of
                            parameters. The method body is executed
                            after arguments have been supplied to all
                            parameter lists.


                      Float add(Float x)(Float y) {
                          return x+y;
                      }




Saturday, April 9, 2011
Higher-order functions

                                 We can “curry” a list of arguments.

                          Float addOne(Float y) = add(1.0);
                          Float three = addOne(2.0);
                                           Providing arguments to just one parameter
                                           list produces a method reference.


                             The point of all this is that we are able to
                             provide all the functionality of first-class
                             and higher-order functions without needing
                             to resort to unnatural syntactic constructs
                             inspired by the lambda calculus notation.




Saturday, April 9, 2011
Closure
                              An inner declaration always has access to parameters,
                              locals, and attributes of the containing declaration.

                          void aMethod(String name) {
                              void hello() {
                                  writeLine(“Hello “ name “!”);
                              }
                          }             Notice how regular the language syntax is!

                          class AClass(String name) {
                              void hello() {
                                  writeLine(“Hello “ name “!”);
                              }
                          }
Saturday, April 9, 2011
Named argument syntax

              String join(String separator,
                      String... strings) { ... }


              join(“, ”, “C”, “Java”, Smalltalk”);

              join { separator = ”, “;
                  “C”, “Java”, Smalltalk” };
                          A named argument invocation is enclosed in
                          braces, and non-vararg arguments are listed
                          using the name=value; syntax.



Saturday, April 9, 2011
Higher-order functions and named arguments

                     repeat { The method name
          A parameter name times = 3;
                           void perform() { Another parameter name
                               writeLine(“Hola Mundo!”);
                           }
                                       A named argument may even
                     };                be a method definition.




Saturday, April 9, 2011
Named argument syntax

             Html hello {
                 Head head { title = “Squares”; }
                 Body body {
                     Div {
                          cssClass = “greeting”;
                          “Hello” name “!”
                     }
                 }
             }                This looks like a typesafe declarative
                                     language (for example XML) with built-in
                                     templating. But it’s actually written in a
                                     general-purpose language!



Saturday, April 9, 2011
Named argument syntax



          class Table(String title, Natural rows,
              Column... columns) { ... }

          class Column(String heading,
              String content(Natural row)) { ... }


                          We can define the “schema” of a declarative
                          language as a set of classes.




Saturday, April 9, 2011
Named argument syntax
            Table squares {
                title = “Squares”;
                rows = 10;
                Column {
                    heading = “x”;
                    String content(Natural row) {
                         return $row;
                    }
                }                        Notice the use of callback methods!
                Column {
                    heading = “x**2”;
                    String content(Natural row) {
                         return $row**2;
                    }
                }
            }

Saturday, April 9, 2011
What next?

       • If you’re interested to learn more, come to the next talk “The Ceylon
         Language”
       • We need help implementing the compiler and designing the SDK.
       • This isn’t worth doing unless we do it as a community!


                                Questions?




Saturday, April 9, 2011

Weitere ähnliche Inhalte

Was ist angesagt?

Smalltalk and ruby - 2012-12-08
Smalltalk and ruby  - 2012-12-08Smalltalk and ruby  - 2012-12-08
Smalltalk and ruby - 2012-12-08Koan-Sin Tan
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Hitesh-Java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.Tarunsingh198
 
Java tutorials
Java tutorialsJava tutorials
Java tutorialssaryu2011
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in javaElizabeth alexander
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_javaHoang Nguyen
 
Java Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsJava Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsAnton Keks
 
Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Hitesh-Java
 
You need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesYou need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesPhilip Langer
 
Model Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in ScalaModel Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in ScalaFilip Krikava
 
Core java lessons
Core java lessonsCore java lessons
Core java lessonsvivek shah
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigoujaxconf
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUGAlex Ott
 

Was ist angesagt? (18)

Smalltalk and ruby - 2012-12-08
Smalltalk and ruby  - 2012-12-08Smalltalk and ruby  - 2012-12-08
Smalltalk and ruby - 2012-12-08
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Metaprogramming ruby
Metaprogramming rubyMetaprogramming ruby
Metaprogramming ruby
 
Oop lec 2
Oop lec 2Oop lec 2
Oop lec 2
 
oop Lecture 16
oop Lecture 16oop Lecture 16
oop Lecture 16
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Java Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsJava Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & Encodings
 
Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews
 
You need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF ProfilesYou need to extend your models? EMF Facet vs. EMF Profiles
You need to extend your models? EMF Facet vs. EMF Profiles
 
Model Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in ScalaModel Manipulation Using Embedded DSLs in Scala
Model Manipulation Using Embedded DSLs in Scala
 
Cse java
Cse javaCse java
Cse java
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
 
The Road to Lambda - Mike Duigou
The Road to Lambda - Mike DuigouThe Road to Lambda - Mike Duigou
The Road to Lambda - Mike Duigou
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUG
 

Andere mochten auch

Jack el destripador. la leyenda continúa
Jack el destripador. la leyenda continúa Jack el destripador. la leyenda continúa
Jack el destripador. la leyenda continúa Nibia Hernendez
 
SAP ERP - Global Implementation
SAP ERP - Global ImplementationSAP ERP - Global Implementation
SAP ERP - Global ImplementationRosane Ricciardi
 
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 Virtual JBoss User Group
 
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 2014hwilming
 
Ceylon - the language and its tools
Ceylon - the language and its toolsCeylon - the language and its tools
Ceylon - the language and its toolsMax Andersen
 
Managing Information Systems
Managing Information SystemsManaging Information Systems
Managing Information SystemsAsanka Abeykoon
 
Ceylon SDK by Stéphane Épardaud
Ceylon SDK by Stéphane ÉpardaudCeylon SDK by Stéphane Épardaud
Ceylon SDK by Stéphane ÉpardaudUnFroMage
 
Ceylon introduction by Stéphane Épardaud
Ceylon introduction by Stéphane ÉpardaudCeylon introduction by Stéphane Épardaud
Ceylon introduction by Stéphane ÉpardaudUnFroMage
 
Ceylon/Java interop by Tako Schotanus
Ceylon/Java interop by Tako SchotanusCeylon/Java interop by Tako Schotanus
Ceylon/Java interop by Tako SchotanusUnFroMage
 
Ceylon.test by Thomáš Hradec
Ceylon.test by Thomáš HradecCeylon.test by Thomáš Hradec
Ceylon.test by Thomáš HradecUnFroMage
 
Ceylon.build by Loïc Rouchon
Ceylon.build by Loïc RouchonCeylon.build by Loïc Rouchon
Ceylon.build by Loïc RouchonUnFroMage
 
Introduction to Iteratees (Scala)
Introduction to Iteratees (Scala)Introduction to Iteratees (Scala)
Introduction to Iteratees (Scala)Alexander Lehmann
 
BRITISH AMERICAN TOBACCO PLC
BRITISH AMERICAN TOBACCO PLCBRITISH AMERICAN TOBACCO PLC
BRITISH AMERICAN TOBACCO PLCHardik Bendbar
 
Recruitment & Selection Process in BAT (British American Tobacco)
Recruitment & Selection Process in BAT (British American Tobacco)Recruitment & Selection Process in BAT (British American Tobacco)
Recruitment & Selection Process in BAT (British American Tobacco)Syeda Nafisa Noor
 
Lecture 7: Hidden Markov Models (HMMs)
Lecture 7: Hidden Markov Models (HMMs)Lecture 7: Hidden Markov Models (HMMs)
Lecture 7: Hidden Markov Models (HMMs)Marina Santini
 

Andere mochten auch (17)

Jack el destripador. la leyenda continúa
Jack el destripador. la leyenda continúa Jack el destripador. la leyenda continúa
Jack el destripador. la leyenda continúa
 
SAP ERP - Global Implementation
SAP ERP - Global ImplementationSAP ERP - Global Implementation
SAP ERP - Global Implementation
 
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
 
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 - the language and its tools
Ceylon - the language and its toolsCeylon - the language and its tools
Ceylon - the language and its tools
 
Managing Information Systems
Managing Information SystemsManaging Information Systems
Managing Information Systems
 
Ceylon SDK by Stéphane Épardaud
Ceylon SDK by Stéphane ÉpardaudCeylon SDK by Stéphane Épardaud
Ceylon SDK by Stéphane Épardaud
 
Ceylon introduction by Stéphane Épardaud
Ceylon introduction by Stéphane ÉpardaudCeylon introduction by Stéphane Épardaud
Ceylon introduction by Stéphane Épardaud
 
Ceylon/Java interop by Tako Schotanus
Ceylon/Java interop by Tako SchotanusCeylon/Java interop by Tako Schotanus
Ceylon/Java interop by Tako Schotanus
 
Ceylon.test by Thomáš Hradec
Ceylon.test by Thomáš HradecCeylon.test by Thomáš Hradec
Ceylon.test by Thomáš Hradec
 
Ceylon.build by Loïc Rouchon
Ceylon.build by Loïc RouchonCeylon.build by Loïc Rouchon
Ceylon.build by Loïc Rouchon
 
Hmm
HmmHmm
Hmm
 
Introduction to Iteratees (Scala)
Introduction to Iteratees (Scala)Introduction to Iteratees (Scala)
Introduction to Iteratees (Scala)
 
BRITISH AMERICAN TOBACCO PLC
BRITISH AMERICAN TOBACCO PLCBRITISH AMERICAN TOBACCO PLC
BRITISH AMERICAN TOBACCO PLC
 
Recruitment & Selection Process in BAT (British American Tobacco)
Recruitment & Selection Process in BAT (British American Tobacco)Recruitment & Selection Process in BAT (British American Tobacco)
Recruitment & Selection Process in BAT (British American Tobacco)
 
dominos
dominosdominos
dominos
 
Lecture 7: Hidden Markov Models (HMMs)
Lecture 7: Hidden Markov Models (HMMs)Lecture 7: Hidden Markov Models (HMMs)
Lecture 7: Hidden Markov Models (HMMs)
 

Ähnlich wie Introducing the Ceylon Project - Gavin King presentation at QCon Beijing 2011

Java Closures
Java ClosuresJava Closures
Java ClosuresBen Evans
 
Do Languages Matter?
Do Languages Matter?Do Languages Matter?
Do Languages Matter?Bruce Eckel
 
sete linguagens em sete semanas
sete linguagens em sete semanassete linguagens em sete semanas
sete linguagens em sete semanastdc-globalcode
 
Infusion for the birds
Infusion for the birdsInfusion for the birds
Infusion for the birdscolinbdclark
 
Into the Land of lambda, One Programmer's Journey Into Functional Programming
Into the Land of lambda, One Programmer's Journey Into Functional ProgrammingInto the Land of lambda, One Programmer's Journey Into Functional Programming
Into the Land of lambda, One Programmer's Journey Into Functional ProgrammingMike Pence
 
Java Swing ppt beginner learning study.ppt
Java Swing ppt beginner learning study.pptJava Swing ppt beginner learning study.ppt
Java Swing ppt beginner learning study.pptusha852
 
Joon Cho Java Swing.ppt
Joon Cho Java Swing.pptJoon Cho Java Swing.ppt
Joon Cho Java Swing.pptEyezgaming
 
Java programming language
Java programming languageJava programming language
Java programming languageSubhashKumar329
 
Java Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVA
Java Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVAJava Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVA
Java Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVAnikitaparmar61
 
Java Introduction - Quipoin.pptx
Java Introduction - Quipoin.pptxJava Introduction - Quipoin.pptx
Java Introduction - Quipoin.pptxquipoin04
 
Core java programming tutorial - Brainsmartlabs
Core java programming tutorial - BrainsmartlabsCore java programming tutorial - Brainsmartlabs
Core java programming tutorial - Brainsmartlabsbrainsmartlabsedu
 
01-Introduction.ppt
01-Introduction.ppt01-Introduction.ppt
01-Introduction.pptEmanAsem4
 
"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012
"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012
"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012Blend Interactive
 
Independent Development and Writing Your Own Engine
Independent Development and Writing Your Own EngineIndependent Development and Writing Your Own Engine
Independent Development and Writing Your Own EngineananseKmensah
 

Ähnlich wie Introducing the Ceylon Project - Gavin King presentation at QCon Beijing 2011 (20)

Java (1)
Java (1)Java (1)
Java (1)
 
Java Closures
Java ClosuresJava Closures
Java Closures
 
groovy & grails - lecture 1
groovy & grails - lecture 1groovy & grails - lecture 1
groovy & grails - lecture 1
 
Do Languages Matter?
Do Languages Matter?Do Languages Matter?
Do Languages Matter?
 
sete linguagens em sete semanas
sete linguagens em sete semanassete linguagens em sete semanas
sete linguagens em sete semanas
 
Infusion for the birds
Infusion for the birdsInfusion for the birds
Infusion for the birds
 
Into the Land of lambda, One Programmer's Journey Into Functional Programming
Into the Land of lambda, One Programmer's Journey Into Functional ProgrammingInto the Land of lambda, One Programmer's Journey Into Functional Programming
Into the Land of lambda, One Programmer's Journey Into Functional Programming
 
Java Swing ppt beginner learning study.ppt
Java Swing ppt beginner learning study.pptJava Swing ppt beginner learning study.ppt
Java Swing ppt beginner learning study.ppt
 
Joon Cho Java Swing.ppt
Joon Cho Java Swing.pptJoon Cho Java Swing.ppt
Joon Cho Java Swing.ppt
 
Java programming language
Java programming languageJava programming language
Java programming language
 
Intro
IntroIntro
Intro
 
Intro
IntroIntro
Intro
 
Oop Article Jan 08
Oop Article Jan 08Oop Article Jan 08
Oop Article Jan 08
 
Java Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVA
Java Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVAJava Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVA
Java Swing.ppt THIA GIVE YHR BASIC KNOWLEDGER ABOUT JAVA
 
Java Introduction - Quipoin.pptx
Java Introduction - Quipoin.pptxJava Introduction - Quipoin.pptx
Java Introduction - Quipoin.pptx
 
Core java programming tutorial - Brainsmartlabs
Core java programming tutorial - BrainsmartlabsCore java programming tutorial - Brainsmartlabs
Core java programming tutorial - Brainsmartlabs
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
01-Introduction.ppt
01-Introduction.ppt01-Introduction.ppt
01-Introduction.ppt
 
"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012
"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012
"Intro to iOS Development" - Derek Fernholz, South Dakota Code Camp 2012
 
Independent Development and Writing Your Own Engine
Independent Development and Writing Your Own EngineIndependent Development and Writing Your Own Engine
Independent Development and Writing Your Own Engine
 

Kürzlich hochgeladen

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 

Introducing the Ceylon Project - Gavin King presentation at QCon Beijing 2011

  • 1. Introducing the Ceylon Project Gavin King Red Hat in.relation.to/Bloggers/Gavin Saturday, April 9, 2011
  • 2. About this session • I’m going to talk about why we started work on this project • I’m going to cover some basic examples at a very shallow level • I’m not going to get into the details of the type system • If you’re interested, come to my second presentation: “The Ceylon Language” • This project is not yet available to the public and has not even been officially announced • QCon China is getting a special sneak preview - the first time I’m talking about the project in public! Saturday, April 9, 2011
  • 3. Why we’re (still) fans of Java • Java was the first language to feature the following “perfect” combination of features: • virtual machine execution, giving platform independence • automatic memory management and safe referencing • static typing • lexical scoping • readable syntax • Therefore, Java was the first language truly suitable for • large team development, and • large-scale deployments of multi-user applications. • It turns out that large teams developing multi-user applications describes the most interesting class of project in business computing Saturday, April 9, 2011
  • 4. Why we’re (still) fans of Java • Java is easy • Java’s syntax is rooted in standard, everyday mathematical notion taught in high schools and used by mathematicians, engineers, and software developers • not the lambda calculus used only by theoretical computer scientists • The language is mostly simple to learn and the resulting code is extremely easy to read and understand • Static typing enables sophisticated tooling including automatic refactoring, code navigation, and code completion • this kind of tooling is simply not possible without static typing • Java is robust • With static typing, automatic memory management, and no C-style pointers, most bugs are found at development time Saturday, April 9, 2011
  • 5. Why we’re (still) fans of Java • The Java community is made of ordinary people trying to solve practical problems • Java is unashamedly focussed on problems relevant to business computing • The culture is a culture of openness that rejects dominance by any single company or interest • Java has remained committed to platform independence and portability • The community has a huge tradition of developing and sharing reusable code (frameworks, libraries) Saturday, April 9, 2011
  • 6. Why we’re frustrated • After ten often-frustrating years developing frameworks for Java, we simply can’t go any further without a better solution for defining structured data and user interfaces • Java is joined at the hip with XML, and this hurts almost every Java developer almost every day • There is simply no good way to define a user interface in Java, and that is a language problem • Lack of a language-level modularity solution resulted in the creation of monstrous, over-complex, harmful technologies like Maven and OSGi. • Instead of modules, Java has multiple platforms, which has divided the developer community • Lack of support for first-class and higher-order functions results in much unnecessary verbosity in everyday code • Meta-programming in Java is clumsy and frustrating, reducing the quality of framework and other generic code Saturday, April 9, 2011
  • 7. Why we’re frustrated • A number of other “warts” and mistakes annoy us every day, for example • getters/setters • arrays and primitive types • non-typesafety of null values • the dangerous synchronized keyword • clumsy annotation syntax • verbose constructor syntax • broken = operator • checked exceptions • complex parametric polymorphism system (generics) that few developers completely understand • ad-hoc (broken?) block structure • clumsy, error-prone instanceof and typecast syntax Saturday, April 9, 2011
  • 8. Why we’re frustrated • Most of all, we’re frustrated by the SE SDK • designed in haste 15 years ago, and never properly modernized, it still has an experimental, work-in-progress feel about it • but is simultaneously bloated with obscure stuff • features some truly bizarre things • e.g. all Java objects are semaphores ?! • many basic tasks are absurdly difficult to accomplish • e.g. anything involving java.io or java.lang.reflect • overuses stateful (mutable) objects • especially the highly overrated collections framework Saturday, April 9, 2011
  • 9. The Ceylon Project • What would a language and SDK for business computing look like if it were designed today, with an eye to the successes and failures of the Java language and Java SE SDK? Saturday, April 9, 2011
  • 10. The Ceylon Project • This much is clear: • It would run on the Java Virtual Machine • It would feature static typing • It would feature automatic memory management and safe referencing • It would retain Java’s readability • It would feature first-class and higher-order functions • It would provide a declarative syntax for defining user interfaces and structured data • It would feature built-in modularity • It would strive to be easy to learn and understand Saturday, April 9, 2011
  • 11. The Ceylon Project • Unfortunately, there’s no existing language that truly fits these requirements • My team has spent the past two years designing what we think the language should look like, writing a language specification, an ANTLR grammar, and a prototype compiler • You can’t write code in the language just yet! • We plan an initial release of the compiler later this year • I can’t cover the whole language, or even explain the most interesting principles and concepts in the short time I have here • The most I can do is give a taste of what some code looks like Saturday, April 9, 2011
  • 12. Hello World put this in a file called hello.ceylon void hello() { writeLine(“Hello World!”); } The language has a strict recursive, regular block structure governing visibility and lifecycle of declarations. Therefore, there’s no equivalent of Java’s static. Instead, a toplevel method declaration fills a similar role. Saturday, April 9, 2011
  • 13. Hello World API documentation is specified using annotations. doc “The classic Hello World program” by “Gavin” void hello() { writeLine(“Hello World!”); } Modifiers like abstract, variable, shared, deprecated aren’t keywords, they’re just annotations. Saturday, April 9, 2011
  • 14. Hello World void is a keyword! void hello(String name) { writeLine(“Hello “ name ”!”); } String interpolation has a simple syntax - very useful in user interface definitions. Saturday, April 9, 2011
  • 15. Hello World Defaulted parameters are optional. void hello(String name = ”World”) { writeLine(“Hello “ name ”!”); } Defaulted parameters are extremely useful, since Ceylon does not support method overloading (or any other kind of overloading). Saturday, April 9, 2011
  • 16. Hello World If a value of type T can be null, it must be declared as type Optional<T>, which may be abbreviated to T?. void hello() { String? name = process.args.first; if (exists name) { writeLine(“Hello “ name ”!”); } else { writeLine(“Hello World!”); } } Use of an optional value must be guarded by the if (exists ... ) construct. Therefore, NullPointerExceptions are impossible. Saturday, April 9, 2011
  • 17. Classes All values are instances of a class. class Counter() { variable Natural count := 0; Attributes and local variables are immutable by default. Assignable values must be annotated variable. shared void increment() { count++; } The shared annotation makes a declaration visible outside the block } in which it is defined. By default, any declaration is block local. Saturday, April 9, 2011
  • 18. Classes class Counter() { variable Natural count := 0; shared void increment() { count++; } shared Natural currentValue { return count; } A getter looks like a method } without a parameter list. An attribute may be a simple value, a getter, or a getter/setter pair. Saturday, April 9, 2011
  • 19. Classes There is no new keyword. Counter c = Counter(); c.increment(); writeLine(c.currentValue); Attribute getters are called just like simple attributes. The client doesn’t care what type of attribute it is. Attributes are polymorphic. A subclass may override a superclass attribute. It may even override a simple attribute with a getter or vice versa! Saturday, April 9, 2011
  • 20. Classes The local keyword may be used in place of a type for block-local declarations. local c = Counter(); c.increment(); writeLine(c.currentValue); You can’t use local for shared declarations. One consequence of this is that the compiler can do type inference in a single pass of the code! Saturday, April 9, 2011
  • 21. Classes class Counter() { variable Natural count := 0; ... shared Natural currentValue { return count; } shared assign currentValue { count := currentValue; } } Assignment to a variable value or attribute setter is done using the := operator. The = specifier is used only for specifying immutable values. Saturday, April 9, 2011
  • 22. Classes There is no constructor syntax. Instead, the class itself declares parameters, and the body of the class may contain initialization logic. class Counter(Natural initialValue) { if (initialValue>1000) { throw OutOfRangeException() } variable Integer count := initialValue; ... } How can a class have multiple constructors? It can’t! There’s no overloading in Ceylon. Saturday, April 9, 2011
  • 23. Sequences Sequences are immutable objects that are a bit like arrays. Sequence<String> itin = Sequence(“Guanajuato”, “Mexico”, “Vancouver”, “Auckland”, “Melbourne”); String? mex = itin.value(1); Sequence<String> layovers = itin.range(1..3); Sequence<String> longer = join(itin, Sequence(“Hong Kong”, “Beijing”)); Saturday, April 9, 2011
  • 24. Sequences Syntactic abbreviations allow us to eliminate the verbosity. String[] itin = { “Guanajuato”, “Mexico”, “Vancouver”, “Auckland”, “Melbourne” }; String? mex = itin[1]; String[] layovers = itin[1..3]; String[] longer = itin + { “Hong Kong”, “Beijing” }; Saturday, April 9, 2011
  • 25. Higher-order functions A parameter may be a method signature, meaning that it accepts references to methods. void repeat(Natural times, void perform()) { for (Natural n in 1..times) { perform(); } The “functional” parameter may be } invoked just like any other method. Saturday, April 9, 2011
  • 26. Higher-order functions repeat(3, hello); A reference to a method is just the name of the method, without an argument list. Saturday, April 9, 2011
  • 27. Higher-order functions repeat(3, person.sayHello); We can even “curry” the method receiver. Saturday, April 9, 2011
  • 28. Higher-order functions We may define a method “by reference”. void hello(String name) = hello; The name of the method, without arguments, refers to the method itself. void hello2(String name) = person.sayHello; Unlike other languages with first-class functions, Ceylon doesn’t have a syntax for anonymous functions (“lambdas”) that appear in expressions. Saturday, April 9, 2011
  • 29. Higher-order functions The method name repeat(3) perform() { A parameter name writeLine(“Hola Mundo!”); }; Alternatively, a method may be defined inline, as part of the invocation. This syntax is stolen from Smalltalk. Saturday, April 9, 2011
  • 30. Higher-order functions repeat(3) We may omit the empty parameter list. perform { writeLine(“Hola Mundo!”); }; This allows a library to define syntax for new control structures, assertions, comprehensions, etc. Saturday, April 9, 2011
  • 31. Higher-order functions A method may declare multiple lists of parameters. The method body is executed after arguments have been supplied to all parameter lists. Float add(Float x)(Float y) { return x+y; } Saturday, April 9, 2011
  • 32. Higher-order functions We can “curry” a list of arguments. Float addOne(Float y) = add(1.0); Float three = addOne(2.0); Providing arguments to just one parameter list produces a method reference. The point of all this is that we are able to provide all the functionality of first-class and higher-order functions without needing to resort to unnatural syntactic constructs inspired by the lambda calculus notation. Saturday, April 9, 2011
  • 33. Closure An inner declaration always has access to parameters, locals, and attributes of the containing declaration. void aMethod(String name) { void hello() { writeLine(“Hello “ name “!”); } } Notice how regular the language syntax is! class AClass(String name) { void hello() { writeLine(“Hello “ name “!”); } } Saturday, April 9, 2011
  • 34. Named argument syntax String join(String separator, String... strings) { ... } join(“, ”, “C”, “Java”, Smalltalk”); join { separator = ”, “; “C”, “Java”, Smalltalk” }; A named argument invocation is enclosed in braces, and non-vararg arguments are listed using the name=value; syntax. Saturday, April 9, 2011
  • 35. Higher-order functions and named arguments repeat { The method name A parameter name times = 3; void perform() { Another parameter name writeLine(“Hola Mundo!”); } A named argument may even }; be a method definition. Saturday, April 9, 2011
  • 36. Named argument syntax Html hello { Head head { title = “Squares”; } Body body { Div { cssClass = “greeting”; “Hello” name “!” } } } This looks like a typesafe declarative language (for example XML) with built-in templating. But it’s actually written in a general-purpose language! Saturday, April 9, 2011
  • 37. Named argument syntax class Table(String title, Natural rows, Column... columns) { ... } class Column(String heading, String content(Natural row)) { ... } We can define the “schema” of a declarative language as a set of classes. Saturday, April 9, 2011
  • 38. Named argument syntax Table squares { title = “Squares”; rows = 10; Column { heading = “x”; String content(Natural row) { return $row; } } Notice the use of callback methods! Column { heading = “x**2”; String content(Natural row) { return $row**2; } } } Saturday, April 9, 2011
  • 39. What next? • If you’re interested to learn more, come to the next talk “The Ceylon Language” • We need help implementing the compiler and designing the SDK. • This isn’t worth doing unless we do it as a community! Questions? Saturday, April 9, 2011