
Ceylon: Quick introduction - mintplant
http://ceylon-lang.org/documentation/1.0/introduction/
======
roryokane
I was wondering how Ceylon is supposed to be different from Scala. I found
this blog post from 2011 that compares Scala, Ceylon, and Kotlin:
[http://blog.lunatech.com/2011/08/24/scala-ceylon-kotlin-
goal...](http://blog.lunatech.com/2011/08/24/scala-ceylon-kotlin-goals).
Basically, Scala aims to be concise and “scalable” by explicitly aiming for
both OOP and FP support. Ceylon aims to be an improved Java that is more
concise, powerful, and modular, while still being familiar. Ceylon also aimed
to be less complex than Scala while still being as powerful, but I don’t know
if it has succeeded.

There is also this huge 2013 article comparing eight JVM languages with each
other: [http://zeroturnaround.com/rebellabs/the-adventurous-
develope...](http://zeroturnaround.com/rebellabs/the-adventurous-developers-
guide-to-jvm-languages-java-scala-groovy-fantom-clojure-ceylon-kotlin-xtend/)

~~~
jshen
I really like the look of kotlin, but is there a release date for 1.0?

~~~
meddlepal
I've heard Q4/2014 thrown around. I wish Jetbrains updated their Kotlin blog
more often than every 2-3 months.

------
zimbatm
In the same space there is Haxe [http://haxe.org/](http://haxe.org/) . It's
also an Algol-like language that targets both JavaScript and Java (and flash,
c++, .net, php).

~~~
jdonaldson
Haxe has a few more language features (abstract types) and compiler features
(dead code elimination) but it lacks a few from Ceylon such as union types.

The Haxe compiler is much, much faster than Ceylon. I wonder if certain
features just can't pass a speed threshold.

~~~
zem
haxe's enums seem like full-fledged union types:
[http://haxe.org/manual/types-enum-
instance.html](http://haxe.org/manual/types-enum-instance.html)

~~~
jdonaldson
There's also Ceylon's enumerated subtypes, which look similar: [http://ceylon-
lang.org/documentation/1.0/introduction/#enume...](http://ceylon-
lang.org/documentation/1.0/introduction/#enumerated_subtypes)

However, Haxe's algebraic data types are really not the same thing. It takes a
bit more code to achieve an identical effect. On the other hand, algebraic
data types are much more general purpose, and allow techniques like pattern
matching.

[http://en.wikipedia.org/wiki/Algebraic_data_type](http://en.wikipedia.org/wiki/Algebraic_data_type)
[http://haxe.org/manual/lf-pattern-matching-
introduction.html](http://haxe.org/manual/lf-pattern-matching-
introduction.html)

In the case of Haxe, you can construct a pattern that uses guards and/or
extractors (e.g., a pattern that matches cases where you have an empty Tree,
or a tree that contains a specific Node. You could also do matches on
structural subtypes, etc.)

------
nemetroid
From the language specification[0]:

> This code is not legal, since all three statements occur in the initializer
> section of the class body:
    
    
        class Point() {
            Float x => y;  //compiler error: y is not referenceable
            Float y => x;
            Float->Float xy = x->y;
        }
    

> However, this code is legal, since the statements occur in the declaration
> section of the class body:
    
    
        class Point() {
            Float x => y;
            Float y => x;
        }
    

If I'm reading things correctly, class declarations are split up into
"initializer" and "declaration", with only an implicit split (the last
statement that is not allowed in the declaration section). This seems very
awkward.

0: [http://ceylon-
lang.org/documentation/1.0/spec/html_single/#r...](http://ceylon-
lang.org/documentation/1.0/spec/html_single/#referenceabilityofdeclaration)

~~~
edwardio
It's not that awkward, C# does the same thing:

    
    
       interface IPoint
        {
       // Property signatures: 
       int x
       {
          get;
          set;
       }
    
       int y
       {
          get;
          set;
       }
       }
    

(taken from [http://msdn.microsoft.com/en-
us/library/87d83y5b.aspx](http://msdn.microsoft.com/en-
us/library/87d83y5b.aspx))

~~~
nemetroid
I don't see the similarity. The Ceylon feature I find awkard is that class
definitions have two parts (initializer/declaration) with different semantics,
without explicit demarcation.

In the example above, this code:

    
    
        class Point() {
            Float x => y;
            Float y => x;
        }
    

is fine, because both declarations are parsed as being in the declaration
section. However, when you add another line _after_ that:

    
    
        class Point() {
            Float x => y;  //compiler error: y is not referenceable
            Float y => x;
            Float->Float xy = x->y;
        }
    

The original two declarations are now part of the initializer section, because
the third line is a statement that is not allowed in the declaration section.
This changes the semantics of the first two lines.

~~~
knocte
Seems like a bug.

------
dominotw
Seems like Gavin King of Hibernate fame is leading this project.

~~~
pkolaczk
I don't see how that is supposed to be any recommendation. If Ceylon is going
to be similar to Hibernate in terms of quality, simplicity, performance and
amount of design WTFs, I don't want to touch it.

~~~
strictfp
Too be fair, Hibernate was a whole lot leaner when Gaving was leading the
project. And Hibernate was one of the first ORMs, so he was at least
pioneering a field, even if the idea admittedly turned out to be less great
than initially thought.

And while working on CDI and Weld, Gaving really was the one who pushed for
"plug and play" in JBoss, mediating between departments and making sure stuff
got usable and in some cases even quite fast. In the end, the Seam guys more
or less abandoned EJB and more or less started the POJO trend.

Additionally, I thing that Gavin was one of the first to spot where Hibernate
was heading and started to work on ceylon quite early (I forgot when). And if
you read what he has written you can tell that he knows his stuff!

You have to give the guy some cred!

~~~
frowaway001
Well, not sure. When he started Ceylon, he wasn't even aware of the existence
of Scala.

Kind of reminds me of the quote from the Groovy creator.

Seems like most of the JVM languages these days are created because people are
too lazy to research the state of the art...

~~~
mgkimsal
Or... the other projects need to do a better job of marketing to raise
awareness in the first place?

------
thomasahle
I like the direct approach to Union and Intersection Types.

I wonder if the goal of making the language 'immediately readable to people
who aren't Ceylon programmers' limits them too much. This might be why the
type signature for functions in `void repeat(Integer times, void
iterate(Integer i))` is so macabre.

Tuples and comprehensions are always nice. The 'tree syntax' stuff seem a lot
like JSON-javascript, which I guess has found it useful.

At the end of the day I'm not convinced why this is a better language than the
lot of JVM languages out there.

------
ww520
Ceylon looks very interesting. The union type is a brilliantly simple way to
combine types. It's something that once you've seen it you would ask how come
type combination not done this way all along.

The map comprehension is very interesting, going beyond list comprehension.
Should make functional style programming easier.

I wonder how big the download of the runtime is for running as Javascript
inside the browser.

~~~
thomasahle
Python has map comprehensions like this:

    
    
        {i: i+1 for i in range(10)}
    

Works pretty well.

~~~
jmgrosen
Perhaps more comparable to the comprehensions shown in this post would be
generator comprehensions:

    
    
        list(p.first_name + " " + p.last_name for p in people)
        dict((p.first_name + " " + p.last_name, p) for p in people)
        set(j.organization for p in people for j in p.jobs)
        print(", ".join(p.first_name + " " + p.last_name for p in people))
    

(Of course, Python has sugar for the first three.)

~~~
iso8859-1
What's the sugar for the third?

~~~
andreasvc

        set(j.organization for p in people for j in p.jobs)
        {j.organization for p in people for j in p.jobs}
    

The latter is available from Python 2.7+.

------
Daishiman
The verbosity of reserved words seems like it would get annoying quickly, both
in writing and readability("shared actual X"? C'mon!).

I think that conflating clarity of keywords with the clarity of language is a
huge and pointless confusion, especially when touting metaprogramming,
comprehensions and variadic function arguments.

It doesn't look like a bad language; its features seem well rounded, yet
there's a lot of stuff out there that's both more capable, with features that
are more orthogonal. There's less feature mishmash than Scala, certainly, but
it doesn't seem that far up in the power spectrum to justify learning another
language, especially when compared to Kotlin, its closest competitor.

Kotlin just seems to be better in most regards: much more compact syntax,
similar features set without some of the questionable overhead of Ceylon, and
extension methods.

------
reitanqild
> If these code examples look boring to you, well, that's kinda the idea -
> they're boring because you understood them immediately!

This sales pitch finds me at home!

Also there seems to be some nifty features in there e.g native unions and
intersections.

------
sajithdilshan
Just so you know, Ceylon is a name of a country (now known as Sri Lanka). The
name is more popular due to the tea which is manufactured in Sri Lanka (Ceylon
Tea)

------
howeyc
I've been poking around the site and there was a mention of running in the
browser. I have been unable to find any examples. Does anyone see any?

I'm thinking of something modifying form text boxes or something simple like
that.

~~~
mintplant2
There's a bit about it on the linked page (look for the description of
"dynamic" blocks), plus a tutorial on their blog: [http://ceylon-
lang.org/blog/2013/02/26/ceylon-in-the-browser...](http://ceylon-
lang.org/blog/2013/02/26/ceylon-in-the-browser/)

------
rishi-dragon
Why is that we need new languages? Why not improve existing languages? We, as
a community, would benefit from solving the very limitations that lure
developers into other languages.

~~~
tormeh
Because that would break backwards compatibility.

~~~
reactor
I don't think that's the right argument. Re-writing few parts or writing
entire app in new lang, which one would be better for app developer?

~~~
iopq
If only you could write a new service in a different language and then make
requests to it... oh wait, you can!

At my last job we had a Node.js app talk to a Scala backend and the other end
of the system ran PHP. I mean we already had like 30 servers at least, so
dedicating one to Node and a few to Scala wasn't a problem.

------
knocte
I see that immutability is not a first-class citizen in this language...
mmmhhh....

~~~
ww520
Immutability is kind of an overrated fad. The world is very much mutable. I
want to see how languages manage mutability. Languages that provide simple
mechanisms and tools to manage mutability go a long way to help the
programmers to cope with the real problems.

~~~
frowaway001
> The world is very much mutable.

LOL, what?

~~~
jkrems
Depending on your concept of time, it very much is. If you choose the same
abstraction of time for reasoning about the program state and the real world,
the same "reference" might change its properties over time. The speed of a car
is mutable over time. The question is if the way we reason about time when
talking about the "real" world is appropriate for reasoning about time in
programs.

~~~
davidrusu
Attach a date stamp to your references and facts and BOOM, everything is
immutable!

------
diminish
The recent profileration of languages amazes me. Every major computing house
now has one or more programming languages. Is this a strategic approach to
reign the future.? Or has it become easier to design languages. Thinking of
how little Java helped Sun to escape disappearing I m curious of the opinions
of people in charge..

Ps: welcome again Ceylon, hope you'll give RedHat a brighter future in the
enterprise.

~~~
vorg
What is a language? How deeply up and down the abstraction scale does a
"language" need to implement to be called a language?

Some languages, like Go, implement a different edition directly atop many
various OS's, with their own garbage collection and type inference. Whereas
others, like Coffeescript, are text generators sitting atop and relying on
features of other languages. And there's many shades in between, such as
languages that produce JVM bytecode rather than executables for each different
hardware target the JVM sits atop.

Then there's the issue of how much support atop the text files a language
directly supports. Some, like Kotlin, make IDE support an official policy,
whereas others, like Java, don't, instead relying on third parties to provide
it. Some languages _only_ provide the visual interface. Macros, like in
Clojure, and compiler directives, like in C, could also be considered "atop
the text file syntax".

If readable source code in some certain language can be generated from a VM or
an AST that many different "languages" target, then in a sense they're not
really languages at all, only "bytecode generators" or "transpilers".

~~~
Chiba-City
This is a very good question. Unix/C came from the glorious "system building"
era. They took responsibility for building and documenting "the whole stack"
\- from assembly to signals to troff. Wirth's Oberon OS/language were
codesigned in the same fashion. Smalltalk/V took over a PC.

Ceylon seems like a very nicely designed language (and I don't mean syntax). I
would love to see a LLVM back end and the requisite docs for low level system
hacking.

------
lohankin
The beating of web programmers with new languages will continue until morale
improves :-) I mean, until somebody figures out that the HTML/CSS/DOM etc make
the task nearly impossible, no matter what language.

~~~
taeric
Oddly, I think the problem is orthogonal. Mayhap that isn't the correct word.

Regardless, my assertion is that the problem is when most of us write web
apps, we think of it as a single application. Frameworks often make this
worse, as half of them treat the goal as to hide that you are writing a
distributed application.

Contrast this with what is really going on, where you have -- at a minimum --
a front end and a backend operating independently of each other. And I'm not
just talking multithreaded. They are literally completely disconnected from
each other.

So, consider how we use all sorts of paradigms to try and make writing a
multithreaded program easier. Now, consider at the end of the day many of
these tasks can be done with simple locks and semaphores. Better yet, consider
that most of the higher abstractions build on those.

Now, when is the last time you saw a tutorial for using a semaphore between an
html front end and a backend?*

* I'm really hoping someone proves me wrong on this question. :)

~~~
ricardobeat
But they _are_ disconnected, one is running on the client, the other on the
server. Regardless of any magical unified framework, there will be two
processors talking asynchronously over network protocols. GWT does this kind
of integration and it's far from a panacea.

~~~
taeric
Apologies for poorly making that point. That is, my point was that we need
more ways to embrace this separation. I'm not sure unifying the language on
client/server would really help.

------
stefantalpalaru
> A new language

Version 0.1 was released on Dec 20 2011 : [http://ceylon-lang.org/download-
archive/](http://ceylon-lang.org/download-archive/) .

~~~
mintplant2
The first production-ready version was released in late 2013: [http://ceylon-
lang.org/blog/2013/11/12/ceylon-1/](http://ceylon-
lang.org/blog/2013/11/12/ceylon-1/)

The language is still relatively new, and under active development:
[https://github.com/ceylon](https://github.com/ceylon)

------
kp25
How come it is a new language if the version 0.1 was around 3 years old.? In
that sense i should call Python 2.7.8 a new language which was released a week
back.

------
Nilzor
>Ceylon's syntax is ultimately derived from C. So if you're a C, Java, or C#
programmer, you'll immediately feel right at home

...yet we introduce the VB-keyword "shared" instead of "public", "variable"
instead of C#'s "var" and use square brackets instead of curly braces for
array initialization. You know, just because fuck you.

Seriously I see this all the time in new languages. Why invent or change
keywords just for the sake of changing? Why does Rust use "let"? Why does
Scala use "def"? If you want easy adoptation from one of the two largest
languages in the world, change what matters and stick with the rest.

~~~
chrismonsanto
> Why does Rust use "let"?

let is the standard keyword for introducing a new, shadowing variable binding.
It is a very old tradition and is immediately recognizable to functional
programmers.

> If you want easy adoptation from one of the two largest languages in the
> world, change what matters and stick with the rest.

In the case of "let", it would be a false consistency with C/Java. Assignment
in C/Java does not have the same semantics as a let binding in Rust, although
a let binding in Rust has very similar semantics to a let binding in Scheme or
Haskell.

