Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Red Hat's Ceylon language has some interesting improvements over Java:

  • The overall vision: learn from Java's mistakes, keep the good, ditch the bad
  • The focus on readability and ease of learning/use
  • Static Typing (find errors at compile time, not run time)
  • No “special” types, everything is an object
  • Named and Optional parameters (C# 4.0)
  • Nullable types (C# 2.0)
  • No need for explicit getter/setters until you are ready for them (C# 3.0)
  • Type inference via the "local" keyword (C# 3.0 "var")
  • Sequences (arrays) and their accompanying syntactic sugariness (C# 3.0)
  • Straight-forward implementation of higher-order functions

I don't know Scala but have heard it offers some similar advantages over Java.

How would Scala compare to Ceylon in this respect?


migration rejected from May 2 '14 at 7:45

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as too broad by gnat, MichaelT, amon, GlenH7, Martijn Pieters May 2 '14 at 7:45

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

Scala is functional. That's probably the biggest difference to start with – charisis Apr 13 '11 at 7:27
Scala recognises functions as first-class citizens, and makes extensive use of immutability, closures and pattern matching. It absolutely matches one very valid definition of "being functional" – Kevin Wright Apr 13 '11 at 10:55
Scala's collections are immutable per default, so are variables. I don't know your definition of "not making extensive use of immutability", but mine is different. – Axel Gneiting Apr 13 '11 at 13:00
For a strict language, Scala is as functional as any other, if "being functional" means "makes it easy to write programs in a functional style". If, however, "being functional" means "makes it hard to wite programs in a non-functional style", then Scala is not functional. The only thing I really miss in Scala in some kind of effect tracking system. – Daniel C. Sobral Apr 13 '11 at 14:12
I would compare them as follows: Scala exists, Ceylon doesn't. Ceylon today is where Scala was circa 2002. – Seth Tisue Apr 13 '11 at 19:35

I started using Scala this year, and really like it. I've also attended a conference by Gavin King and talked with him about Ceylon. The idea is to have an enterprise-level replacement for Java. Some of the key features of Ceylon (not all of these exist yet) are:

  • It is intended to be used for large projects involving large teams; readability is very important, since in large projects you can spend more time reading other people's code than writing your own.
  • Everything is an object
  • There is operator overloading BUT it's not arbitrary. For example if you want to implement "+" in your class, it must implement the Summable interface. EDIT actually this is called operator polymorphism, not overloading...
  • Union and intersection types. This is BIG, one of my favorite features of the language and I haven't seen it in Scala or any other JVM language (actually I don't know where Gavin got it from but it's one of those things that I would like to have NOW in Java or any other language).
  • Everything is immutable by default, but of course you can have mutable objects by adding the "variable" keyword to your declarations.
  • Built-in builder pattern which creates immutable objects
  • No nulls by default. If you declare "String x" then x can never be null; if you want x to be null at some point you have to declare it as "String? x", and then every time you want to use x you have to guard it like "if (exists x) {bla} else {bla}"
  • The generics are much better than in Java, thanks to union and intersection types.
  • No method overloading (not needed, because of union and intersection types).
  • Local type inference (ONLY locally)
  • Null is type-safe
  • Java Interop (it's not there yet, but you'll be able to use Java classes from Ceylon, and you are able to use Ceylon classes from Java today)
  • A completely new module system. This will solve many (or hopefully all) of the problems that are today managed by Maven/Ivy and even OSGi, dependency-wise.
  • Interfaces that can have concrete members (similar to Scala traits, but Ceylon's interfaces can only have methods, no state).
  • Top-level functions and higher-order functions.
  • String interpolation
  • Two levels of visibility for classes/methods/properties/etc: shared and private.
  • Default values for method/function parameters
  • Singletons similar to Scala, by using "object" instead of "class"
  • Declaration-site variance and generic type constraints

EDIT some other features I missed the first time around:

  • Algebraic types
  • Its own SDK (language module with all the basic classes and functions)
  • JVM and javascript backends

Union and intersection types allow you to do stuff such as:

  • Declaring variables/parameters/return types that can accept two or more different types. You can have a method such as "print(String|Int p)" and it can receive either type, or "write(Cloneable&Serializable p)" and it can only receive types which implement both interfaces.
  • Heterogeneous collections. You can have a List to store objects of either type. Or a List to accept only types that implement both interfaces.
  • Generics are actually much better and simple because of these types. Instead of having stuff such as Java's "?-capture-of" which practically nobody understands how to use, you can just declare the types you need.
I demonstrated how to code a union type in Scala (see last update), and it is nearly first-class. – Shelby Moore III Mar 2 '12 at 13:05