Questions tagged [ceylon]

Ceylon programming language for Java and JavaScript virtual machines.

Ceylon is a modern, modular, statically typed programming language for Java and JavaScript virtual machines. The language features a flexible and very readable syntax, a unique and uncommonly elegant static type system, a powerful module architecture, and excellent tooling, including awesome Eclipse- and IntelliJ-based IDEs.

The Ceylon language is defined by a readable specification.

Since 'Hello World' is the traditional way to introduce a language, here's how it looks in Ceylon:

shared void hello()
        => print("Hello, World!");

To learn more, you can start with the quick introduction or take the in-depth tour of Ceylon.


Current release: 1.3.3 (Contents May Differ)

  • Ceylon is open source on Github
  • Ceylon 1.4 is under development including migration of the compiler to the Eclipse Foundation.

Ceylon is:

  • Powerful: Ceylon's powerful flow-sensitive static type system catches many bugs while letting you express more, more easily: union and intersection types, tuples, function types, mixin inheritance, enumerated types, and reified generics.
  • Readable: We spend more time reading other people's code than writing our own. Therefore, Ceylon prioritizes readability, via a highly regular syntax, support for treelike structures, and elegant syntax sugar where appropriate.
  • Predictable: Ceylon controls complexity with clarity. The language eschews magical implicit features with ambiguous corner cases. The compiler follows simple, intuitive rules and produces meaningful errors.

Ceylon offers:

  • A platform: Ceylon is a whole platform with amodern SDK designed from scratch. It runs on both Java and JavaScript virtual machines, bridging the gap between client and server. Ceylon is fully interoperable with Java and the Java SDK, and with JavaScript and its libraries.
  • With modularity: Modularity is at the very core of the language, SDK, and tooling. The compiler produces module archives which are then distributed via a next-generation repository architecture with Ceylon Herd as its social focus point.
  • And tooling: Static typing is the technology that enables killer tools. Ceylon comes with a complete command line toolset, and awesome Eclipse- and IntelliJ-based IDEs with searching, refactoring, quick fixes + assists, autocompletion, debugging, and much more.
114 questions
2
votes
1 answer

How do I run Ceylon Eclipse projects from the terminal?

I wrote a simple Hello World program with the Ceylon Eclipse plugin: Here is the source code, in case anybody wants to reproduce the issue quickly: shared void main() { String omg = (process.arguments.first else "nothing"); print("You wrote…
fredoverflow
  • 256,549
  • 94
  • 388
  • 662
2
votes
2 answers

Recursive aliases in Ceylon

I am new to Ceylon, and am currently exploring how to port some existing software written in TypeScript (essentially JavaScript) to Ceylon, so that it can run both on JavaScript engines and JVM. Does anybody know how to code an equivalent of this…
user241495
  • 23
  • 3
2
votes
1 answer

Can a method from a Generic class return a Tuple with the same types as its argument-list?

I wanted to have something like this: [String, Integer] values = SomeClass("Hi", 1).values(); [Boolean, Float] others = SomeClass(true, 2.0).values(); // EDIT - should return tuple with same type as the arguments list [String] strs =…
Renato
  • 12,940
  • 3
  • 54
  • 85
2
votes
2 answers

How to filter by type in Ceylon in an elegant way?

I was hoping the following would work: void takeOnlyStrings(String* s) { print(s); } {String|Integer*} ab = {"Hi", 1}; takeOnlyStrings(for (item in ab) if (item is String) item); Or even this: Boolean isString(Object o) => (o is…
Renato
  • 12,940
  • 3
  • 54
  • 85
2
votes
1 answer

Return type of max{} in Ceylon

I get why the inferred return type of max({}) is Null (and I think it's awesome how that function works with empty/possibly-empty/non-empty iterables), but why is using an empty named argument list—max{}—inferred to return Nothing? Why are those…
gdejohn
  • 7,451
  • 1
  • 33
  • 49
2
votes
1 answer

How to turn a Ceylon class which extends a Java class into the Java class

Suppose you have a Java method in a legacy library you need to use that takes a Class as an argument: public void takeClass(Class cls); Now, suppose you have a Ceylon class which extends JavaClass: shared class CeylonClass()…
Renato
  • 12,940
  • 3
  • 54
  • 85
1
vote
1 answer

Does Ceylon allow explicit Type Casting (downcast)?

I know there's a concept of flow-sensitive typing in Ceylon in which we can narrow down the type of an expression by case. Is there a way to explicitly convert the type of an expression in Ceylon as in Java?
Baber
  • 301
  • 2
  • 6
  • 17
1
vote
1 answer

How do I do it in Ceylon

I've the following code in Java and would like to port it in Ceylon. public interface Condition { Condition FALSE = facts->false; Boolean evaluate(Fact fact); default Condition and(Condition other) { return fact ->…
Mohammad
  • 187
  • 1
  • 12
1
vote
1 answer

Ceylon fat-jar with non-default run function

I have a simple http server in a folder named POSTtoFile. It has one module (server) with one package (server) with a file runServer.ceylon with a function runServer which is the main method. Building a fat jar like this: ceylon fat-jar server/1.0.0…
user134055
1
vote
1 answer

How to make TestRunner pull tests from a separate class

I currently have a TestRunner (from ceylon.test) that can take tests from local functions. Now I'm trying to make it discover tests embedded in a class written in a separate file. However, the TestRunner does not find the test from the class, and I…
user134055
1
vote
1 answer

Eclipse won't show Ceylon source files

I have created a Ceylon project in Eclipse Oxygen. There are Ceylon source code files in the folder C:\Users\Jon\Aukitekt\milling\source\designs, but these are not shown inside Eclipse, as can be seen in this screenshot: EDIT: Making a single run,…
user134055
1
vote
2 answers

Integer to hexadecimal string

I know how to write hexadecimal literal integers (#A3) in Ceylon. I also know how to parse hexadecimal integers in Ceylon. Integer? integer = parseInteger("A3", 16); print(integer.string); // 163 How do I go the other way, get the hexadecimal…
drhagen
  • 8,331
  • 8
  • 53
  • 82
1
vote
1 answer

Cryptographic hashing in Ceylon

What is the recommended way to import the standard cryptographic hashing (message digest) libraries (MD5, SHA1, SHA2, SHA256, SHA3, etc.) in Ceylon?
drhagen
  • 8,331
  • 8
  • 53
  • 82
1
vote
1 answer

Format a time zone offset

If I have a TimeZone, the string property currently produces the time zone in ISO-8601 format. import ceylon.time.timezone { OffsetTimeZone } shared void run() { value timezone = OffsetTimeZone(27000000); print(timezone.string); //…
drhagen
  • 8,331
  • 8
  • 53
  • 82
1
vote
2 answers

Properties (getters and setters) in Ceylon

How do I define a property in Ceylon? I know I can write getName and setName functions to get and set a backing variable: class Circle(shared variable Float radius) { shared Float getArea() { return pi * radius ^ 2; } shared…
drhagen
  • 8,331
  • 8
  • 53
  • 82