The Case for Kotlin and Ceylon

43
Copyright © 2017 Russel Winder 1 The Case for Kotlin and Ceylon Russel Winder @russel_winder [email protected] https://www.russel.org.uk

Transcript of The Case for Kotlin and Ceylon

Page 1: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 1

The Case for Kotlin and Ceylon

Russel Winder

@[email protected]

https://www.russel.org.uk

Page 2: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 2

Java is stagnant,thankfully we have Kotlin and Ceylon

Russel Winder

@[email protected]

https://www.russel.org.uk

Page 3: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 3

The Case for Kotlin and Ceylon

Russel Winder

@[email protected]

https://www.russel.org.uk

Page 4: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 4

The “Prosecution” Advocate● Ex theoretical physicist● Ex UNIX systems programmer● Ex academic:

– Parallel programming– Software development and programming– HCI, UI, UX

● Ex Company director

● Ex Independent consultant● Ex analyst● Ex author● Ex expert witness● Ex trainer

Russel Winder

Page 5: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 5

The “Defence” Advocate

Appears to be missing. :-)

The audience will have to substitute.

Page 6: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 6

The Jury

That’s you the audience.

Page 7: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 7

Prologue

Page 8: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 8

An outline case presented,much, much more detail is available.

Page 9: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 9

Introduction

Page 10: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 10

Java is…● …an “old” programming language steeped in “imperative” and

“object oriented” history.● …a programming language, evolving very slowly.● …not really keeping up with modern programming ideas and

techniques.

Page 11: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 11

The Java Platform is…● …a mature and extensive hardware-independent platform.● …evolving very, very slowly.● …a platform for many programming languages:

– Java, Scala, Kotlin, Ceylon, Frege, Groovy, Fantom, Gosu, …– Groovy, Clojure, JRuby, Jython, Golo, …

Page 12: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 12

Some Philosophy

Page 13: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 13

Is Change Good?

Page 14: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 14

Is Change Good?● Change threatens backward compatibility, backward

compatibility is determined to be sacrosanct, ergo no.● Change enables new knowledge, new techniques, new tools,

ergo yes.

Page 15: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 15

Assembly languages

Procedural languages

Functional languages

Object-oriented languages

?Logic languages

Machine code

Page 16: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 16

Backward compatibility is theenemy of progress.

Page 17: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 17

Backward compatibility is theexcuse of the lazy to avoid work.

Page 18: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 18

Backward compatibility is theway applications become

outdated and broken.

Page 19: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 19

Is backward compatibility thebiggest threat to Java?

Page 20: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 20

Moving On

Page 21: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 21

Distinguish Java the language fromJVM and Java Platform.

Page 22: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 22

If Java will not change…

Page 23: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 23

Assembly languages

Procedural languages

Functional languages

Object-oriented languages

?Logic languages

Machine code

Page 24: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 24

Scala, touted as a replacement for Java,incorporates functional programming into an

object oriented language.

However…

Page 25: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 25

Many took to Scala, butmany found it unsatisfactory.

Kotlin and Ceylon are two of the results.

Page 26: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 26

The Two Languages● Kotlin

– Interwork with Java allowing incremental change of codebase.

– Influenced by Java, Groovy, Scala.

– Superior type system to Java.

● Ceylon– Replace Java but use the

Java Platform.– Module based from the

outset.– Far superior type system to

Java.

Page 27: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 27

Both Kotlin and CeylonCan compile to JVM or JavaScript.

Page 28: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 28

Both Kotlin and Ceylon arelanguages of the 2010s.

Page 29: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 29

Hello World has to be done

Page 30: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 30

/** * The Hello World program in Kotlin. * * @author Russel Winder */fun main(args:Array<String>) { println("Hello World.")}

"The Hello World program in Ceylon."by("Russel Winder")sharedvoid run() { print("Hello World.");}

Top level functions.

/** * The Hello World program in Java * * @author Russel Winder */public class HelloWorld_Java { public static void main(final String[] args) { System.out.println("Hello World."); }}

Page 31: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 31

Doing everything with classes and packages as in Java (and Scala) seen as too restrictive.

Adding top level functions, etc. seen as right, make the compiler do the work of creating classes for the JVM.

Page 32: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 32

Factorial is required

Page 33: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 33

Code

Page 34: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 34

Let’s look at anagramsOr word count

Page 35: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 35

Code

Page 36: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 36

Some Further Thoughts

Page 37: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 37

Operator overloading was deemed too hard for programmers to cope with by the inventors of Java.

Most JVM languages since have put it back,one way or another.

Page 38: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 38

Language evolution by replacement.

Page 39: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 39

Kotlin and Ceylon represent twopossible futures on the JVM.

Page 40: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 40

Headlines● Kotlin:

– More declarative than Java.– Less code.– Mixed language codebase.– More expressive than Java.

● Ceylon:– More declarative than Java.– Modules.– Far better type system

than Java.– More expressive than Java.

Page 41: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 41

Both Kotlin and Ceylon run on Android.

Page 42: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 42

A Challenge to You

Try all this in Java.

Page 43: The Case for Kotlin and Ceylon

Copyright © 2017 Russel Winder 43

The Case for Kotlin and Ceylon

Russel Winder

@[email protected]

https://www.russel.org.uk