Why Ballerina?

We just announced an entirely new open source programming language at WSO2Con — one that lets you write programs by drawing diagrams.

You might be wondering what’s gotten into us. After all, hasn’t Java been doing just fine all this time? Let us explain.

A little bit of history

At WSO2, we create open source integration middleware. Historically, integration has been about connecting systems together. The stuff that does this — which we build — has always been software glue; it brings a great deal of functionality to the table, sticks the important bits together and generally stayed out of the way.

This model was built for an age when enterprises were basically collections of heavily customised, monolithic on-premise systems that had to work together. In today’s world, however, we have so many excellent pre-built systems — especially cloud services — that we now spend most our time composing systems out of pre-built blocks. There’s always a library or a service that you can just plug in there instead of reinventing the wheel.

In this context, integration becomes part and parcel of the actual process of building systems. Connecting X to Y and making sure it works with Z is practically the real core of a developer’s workload.

You’d think that we’d have built tools for this, but we haven’t. Our integration logic is largely done in languages meant for something else — Java, Python, and so on.

This was why we decided to create a language meant for integration, and for integration only. Which brought us to the next problem: how would that work?

When words aren’t enough

Over the years, WSO2 architects have been in a great many situations where we’ve had to sit down with a customer and explain an integration scenario.

We found that every single time we ended up drawing sequence diagrams to help do the explaining. Sequence diagrams are an incredibly intuitive tool, and are so much easier to understand than lines of code.

Voila! We’d found exactly what we needed to make this work. By describing what we need in diagrams (which are then translated to code), anyone can not just explain, but also create integration logic with unprecedented ease.

For example, let’s take an echo service.

Here’s how it would look in Ballerina code:

import ballerina.net.http;
@BasePath(“/echo”)
service echo {
   @POST
   resource echo(message m) {
        http:convertToResponse(m );
        reply m;
   }
}

And this is how the Ballerina editor will visually represent this. See how everything can be mapped onto the diagram?

Let’s consider a more complex example: a passthrough service.

import ballerina.lang.messages;
import ballerina.net.http;
@http:BasePath ("/passthrough")
service passthrough {
@http:GET
resource passthrough (message m) {
http:ClientConnector nyseEP = create
http:ClientConnector("http://localhost:9090");
message response =
http:ClientConnector.get(nyseEP,"/nyseStock", m);
reply response;
}
}
@http:BasePath ("/nyseStock")
service nyseStockQuote {
@http:GET
resource stocks (message m) {
json payload = `{"exchange":"nyse", "name":"IBM",
"value":"127.50"}`;
message response = {};
messages:setJsonPayload(response, payload);
reply response;
}
}

This, with the Composer, can be built as:

The two formats are completely interchangeable. It makes no difference how you choose to write your program — whether you use code or the Composer to draw a diagram, the result is the same.

The state of the art

At present, Ballerina is a project. We still have a great many improvements to ship — including speed, stability and tooling.

Ballerina is also a language capable of anything, but chiefly designed for integrating to apps, data and services. Sure, you can write a calculator with it, but you wouldn’t want to: there are better languages for that. On the other hand, if you want to write integration logic, Ballerina will eventually be the go-to language for that.

However, the core of the Ballerina experience is available in our 0.8 GA release. You can check out the documentation, examine the code on GitHub, and join us at our dev group. Contributors are welcome — we’re driving the future of integration here, and we’d like all the help we can get.

So give Ballerina a whirl, and let’s go make integration great again!