How to write web applications using Ceylon?

Ceylon hitting 1.0 caught my attention lately. The most interesting feature is that it can be compiled for both the JVM and Javascript engines (node.js, browsers) so it makes code sharing possible from the beginning between the server backend and web application running in the browser.

I've started looking up the documentation for details how to create a WAR deployable application with Ceylon where i have some REST endpoints serving stuff to the browser side. I was not expecting Spring WebMVC support although this would be my final goal. For my surprise i didn't find anything useful in this topic. Is there any recommendations how to use Ceylon when i try to target a Servlet engine like Jetty or Tomcat the way i've described?

Right now i'm doing the following in a Java application:

  • Create a Maven webapp project
  • Put JQuery Javascript client code and other static stuff to src/main/webapp
  • Write some Spring MVC controllers to server JSON resources

A similar thing would be great where the client code is transposed from Ceylon code aswell. As i see Ceylon uses it's very own project layout and build system although i would be more happy to use Maven or Gradle to not steer away too much from existing projects.

Answers


Now that the language and its compilers have hit 1.0, we're able to shift some of our attention to development of things like web frameworks. Right now, Ceylon doesn't have a finished web framework.

What it does have is:

  1. A simple HTTP server based on JBoss Undertow, as part of the module ceylon.net. This makes it really easy to create a little web server, especially in conjunction with ceylon.html for rendering HTML pages.
  2. Julien Viet's vert.x bridge and promises module, which provide a wrapper for vert.x.
  3. A cartridge for Red Hat's OpenShift, that lets you deploy a Ceylon web application on Red Hat's cloud.

I understand that this is not a full solution to your question of how can you run Ceylon on a traditional servlet engine. The truth is that you actually can take a compiled Ceylon module archive, embed it in a .war and use it inside Tomcat or Jetty or JBoss or whatever. A .car is, after all, just a .jar with some extra metadata. The problem with that is that you will lose the advantages of Ceylon's module runtime that you usually have when you use ceylon run. You'll need to:

  • manually make sure all the dependencies your module uses are are available in the .war, and
  • you won't get the classloader isolation.

If you can live with that, then, go for it. It will work. But from my point of view the vision we have is to get away from the legacy servlet engines and run something like Undertow (ceylon.net) or vert.x on top of the module runtime. Remember that this "module runtime" we're talking about is anyway just JBoss Modules, the tiny core of JBoss itself.


There is initial work on Ceylon's own web server:

And some simple example / demo / test:


I realize this is an old question, but as I was just looking for the same, almost 2 years later, it seems that someone is building one (called Cayla):

https://github.com/vietj/ceylon-cayla


Need Your Help

Setting BOLD font on iOS UILabel

ios objective-c fonts uifont

I have assigned a custom font of 'Helvetica' with size 14 already for the text in UILabel using Interface Builder.

What Oracle privileges do I need to use DBMS_METADATA.GET_DDL?

oracle metadata privilege

(Excuse any ignorance of mine here - I'm not a seasoned Oracle user.)