Red Hat's Ceylon [1] language has some interesting improvements over Java:
I don't know Scala but have heard it offers some similar advantages over Java.
How would Scala compare to Ceylon in this respect?
I assume you read the same Slashdot article [1] I did (with linked slides).
The short answer is that Scala already does everything that Ceylon is supposed to do except
It also does things that Ceylon does not (yet):
These features allow Scala to implement as libraries (or modifications to libraries) things that usually require changes to the language (or a new library), and allow the programmer to express powerful concepts in a compact and still relatively clear way.
(Also, note that the features of Ceylon are rather similar to those of Gosu [2].)
[1] http://developers.slashdot.org/story/11/04/13/0136229/Red-Hat-Uncloaks-Java-Killer-the-Ceylon-Projectapply
& companion objects substitute for syntactic sugar of <insert-any-collection>? - Daniel C. Sobral
As I read through the Ceylon presentations yesterday, I was astounded by how much Scala is already providing a solution for those issues which Ceylon claims to be addressing (with respect to shortcomings of Java).
In fact, I'd say that pretty much 95% of what Ceylon appears to be trying to accomplish, can already be done with Scala. (The obvious exception being union types).
So that means that the Ceylon designers, for a 5% feature difference, have decided to design a whole new language from scratch - an astonishing decision. As Daniel mentions above, getting scala to the stage where it's at now, with good IDE support and a number of useful frameworks providing library solutions to such areas as web-development and concurrency, has taken > 5 years. 5. YEARS.
If you add-in the most obvious concerns about Ceylon as a language:
For the extra 5% features you are sacrificing a lot of good stuff.
And for Gavin King to claim that it is conceptually simpler than Scala is breathtaking. From everything I've read so far, it looks a lot like a wish-list of minor functionality crammed awkwardly together, whereas Scala generates its power and scope from its simplicity.
In the comments on this blog post [1], Gavin mentions "extra features" as being more complex. But of course that is not necessarily true! Or rather, it depends stroingly upon your definition of an "extra feature". For example, you could argue that the ability to declare a value which is a type is an extra feature and therefore represents an addition of complexity. But, conversely, you could equally argue that treating types differently to values (i.e. disallowing them as values) is adding complexity (because it represents the "addition" of a feature, namely the special treatment conferred upon types). Similarly with higher-kinded types: why should a type parameter not also be allowed a type parameter? Why is that more complex?
EDIT - on additional comment is that Gavin King explicitly criticises Java because of its lack of declarative GUI tools. He has presented nothing to suggest at exactly how Ceylon addresses these issues, so I do wonder whether he's got something up his sleeve on this one. In fact, I strongly suspect that final judgement should probably be reserved for when a working prototype is available!
[1] http://in.relation.to/Bloggers/Ceylondef perform( t: A or B )
(to accompany t: A with B
) -- you could call anything straight on t
which is a member of both A
and B
, and for the rest you would use an exhaustive pattern match. Maybe in Scala 3? That way overloading could be removed :) - Sciss
def perform(e : Either[A, B])
would about do it - oxbow_lakes
Either
is OK sometimes, but for one you need to pimp it to accept A
or B
straight away. It looks ugly, and it doesn't scale when you need view bounds like A1 <% A
, and it doesn't scale to A | B | C
and so forth. Finally, how about higher kinded types, such as List[ A or B ]
? We already have like a type intersection with A with B with C
, wouldn't it be consequent to allow for type unions such as A or B or C
? - Sciss
I haven't read anything about Ceylon yet, so let me comment on your check points.
Scala does better:
Type inference via the "local" keyword
Scala's very syntax was designed to make type annotations optional everywhere; it does require type annotations on method parameters and return value of recursive methods or methods that use return
to break evaluation, but if a good type inference algorithm was designed to handle that, no modification would have to be made to the language's syntax.
Straight-forward implementation of higher-order functions
Scala provides higher kinded type inference as well, which is very important in a functional statically typed language.
Scala has:
The overall vision: learn from Java's mistakes, keep the good, ditch the bad
It is worth noting that Odersky, Scala's creator, co-designed Generic Java [1] -- which became Java 5's generics -- and Pizza -- a language created to mix functional aspects with Java. That means Scala is not only a result of that vision, but a result of previous iterations of that vision. See more about that history here [2].
Static Typing (find errors at compile time, not run time)
Nullable types
Actually, nullable types are Optional
types, just like Scala's Option
. From Gavin's blog, they are similar to Haskell's Maybe
, which is also the origin of Scala's Option
. From
InfoQ
[3], there no null
in Ceylon. This is a big advantage for people wanting reliability in their programs, but a major drawback for interoperability. One of Scala's goal was interoperability, which is the reason it has null
.
Scala intended, but many people claim it hasn't achieved:
Ease of learning/use
Actually, I think it does pretty well on readability, once one has actually learned the language. The learning curve starts shallow too, but gets steep further on.
Not sure:
Sequences (arrays) and their accompanying syntactic sugariness
One can write things like Set(1, 2, 3)
, Array("a", "b")
or val list = a :: b :: tail
. This is not because Set
, Array
or List
are given special treatment, but just syntactic sugar Scala allows any class.
EDIT
So, I have read about it. I think the ideas behind Ceylon are good -- in fact, they are pretty close to the ideas behind Scala.
The two most striking differences between Scala and Ceylon -- in my own opinion -- is the lack of implicits, and the syntax much closer to C++ than Scala (and even Java, I think).
The absence of implicits reduces complexity a lot, which is nothing to sneer at. By the same token, it makes the language less capable. Implicits makes libraries easier to use, increase the value of static typing, and helps the creation of DSL.
I personally prefer Scala syntax over Ceylon's -- it looks cleaner to me, but Ceylon will certainly be more familiar to Java and C++ programmers.
These are two very valid design decisions. I prefer Scala's choice for both, but taste is very much an individual matter.
I didn't see them crediting any other language, which gives the impression of being a blind effort, but that may not be the case at all. The lack of a running compiler and libraries is much more concerning to me -- Scala takes hell for being "IDE poor", even though it has probably the second best IDE support in the JVM space. I shudder to think how much effort they have ahead of them.
On the other hand, Gavin "Hibernate" King is behind Ceylon, so I expect the effort to have some success, at least.
[1] http://homepages.inf.ed.ac.uk/wadler/pizza/gj/T?
as an abbreviation for Optional<T>
. - Gabe
String?
being syntactic sugar for Optional<String>
. - Daniel C. Sobral
Gavin King's motivation seems to be quite transparent.
Java frameworks suck big time for contemporary applications (mostly web+db). Java syntax is just not equipped to model these things concisely and elegantly. Java frameworks are constantly accused for being hideous looking. Some really deserve it; some don't - the author has explored everything he can to make it easy to read/write, but he's eventually constrained by the Java syntax.
Gavin yearned to tweak Java just enough so that his frameworks look elegant in the modified language.
I agree with this approach. Design a language to best solve contemporary problems. Very practical.
Update after seeing Gavin's blog [1] ( cached here [2]):
[...] the number one technical problem that we simply can't solve to our satisfaction in Java [...] is the problem of defining user interfaces and structured data using a typesafe, hierarchical syntax.
[...]
But much of our frustration is not even with the Java language itself. The extremely outdated class libraries that form the Java SE SDK are riddled with problems. Developing a great SDK is a top priority of the project.
I'm not sure about the 2nd one. It's easy to accuse, for example, that Java collections don't even have readonly interfaces. But it's unclear which design is best for practical use, unless they are tested in real world applications. Sometimes stupid and retarded design outshines smart designs in practice.
In any case, good luck. The amount of work is simply astonishing if they want to fix the language AND design a new SDK (AND a lots of other things too if a modern language wants to get some legs)
[1] http://javablogs.com/Jump.action?id=651566Ceylon seems to be more conservative (in some ways) and more Java-like than Scala.
However, they have decided not to be fully Java-interoperable. (I currently don't know details about Ceylon <-> Java interoperability.) It looks strangely.
There are some differences: * Ceylon seems to allow to name some subexpressions. It can be useful in a declarative UI: you can do it really straightforwardly. * While Java has nulls and Scala supports them mostly for backward-compatibility reasons (but Scala has also Option), Ceylon does not have nulls in traditional sense. It sounds great until you realize that this is a problem when interoperating eith Java. * Generics: Java has simple generics with type erasure. Scala has more complex generics with type erasure, but you can bypass the type erasure by implicits and Manifest. Ceylon will have some generics (I don't know how much advanced they are.), probably with no type erasure. This will be probably another Ceylon's interoperability issue in Ceylon. In Scala, you can do this probably without any serious issue.
In fact, I like Scala and I don't have many reasons to switch to Ceylon. But there are two positives:
It looks like they are going to ditch Swing and go with a web GUI. In this day, this might be advisable. However, I would be curious how they are going to deal with Browser dependencies. The "new SDK" might have a lot of misfeatures/bloat for dealing with various browsers. What is Ceylon's plan?