Discover our knowledge. Read our blogs!

Learn more

We build all our solutions with WSO2 and we are proud that we are Platinum Value-Added Reseller of WSO.

Learn more

You need to learn to walk before you can dance with a ballerina

6 min read

You might have heard something about Ballerina, the new open source language developed by WSO2, launched in February 2017. Earlier we wrote a blog: A first dance with Ballerina. It is a complete language, to be positioned somewhere between Java and the Synapse environment. To be honest, more to the Java side than the Synapse side.

Ballerina

Why do we say that? Just to give you an idea where to position it. Both Synapse and Ballerina are written in Java. But there is a big difference between the two.

Balancé ballerina

Code will be king

Synapse is a mediation configuration language. You have a number of mediators that will allow to transform messages, for instance using the Enterprise Integration Patterns. If you need  additional functionality you can use a script mediator (e.g. Javascript) or create a custom mediator. This will allow you to do what ever you need to do with an Enterprise Service Bus, keeping in mind the specific nature of an ESB (statelessness and orchestration).

Ballerina is an actual language that actually goes beyond mere mediation. To quote the ballerina website:

“Ballerina is a general purpose, concurrent and strongly typed programming language with both textual and graphical syntaxes, optimized for integration”.

Ballerina, for instance, allows for file access, reading the contents of a file. But it also allows you to define an API and also the backend service behind it.  The fact that you can actually define transactions puts its purpose beyond an ESB in my opinion. The question is going to be: what is the sweet spot for ballerina.

You define variables and structs, use functions and define http service or web socket services. It allows you to use JMS queues and connect to relational databases (RDBMS) like MySQL. It also allows for parallelization out of  the box and documentation generation from the source code.

import ballerina

You use the graphical mode to define the general structure and the source view to create and finetune the program.

graphical mode ballerina

Are you a Balletomane?

You might ask: “am I a what?”. According to Wikipedia a Balletomane is “a ballet fan or enthusiast”. We at @YenloTeam surely are. We are already developing skills and training material to gauge the impact of ballerina on the WSO2 API Manager 3.0.0 and WSO2 EI 7.0.0.  Although we are currently at version 0.95.2 of Ballerina we are not as close to a version 1.0.0 as you might think. As Sanjiva said during WSO2Con 2017 in London , the version number increments will become smaller as witnessed by the 0.95.4 version (the previous version was 0.95.3).

The best way to get a feel for Ballerina is to play around with it. Just download ballerina from the site and run it. You will need Java 8, stick with the Oracle version of Java as with all WSO2 products.

You have a number of samples in the documentation (Ballerina By Example) and a number of samples in the [Ballerina home]/samples subdirectory.

You can also run ballerina in the cloud, for instance on Amazon. Just create an Amazon Machine Image with Java and install ballerina. The Composer will run in a browser and will throw an error if there is no Graphical Desktop like Gnome on your instance. However, you can run composer from outside the image.

You need to do two things:

  1. Allow traffic (IP address and port access) to access the VM
  2. Add a parameter to the Composer java startup script (-Dmsf4j.host=0.0.0.0 \)

The latter is needed because it is currently forcefully binding to the 127.0.0.1 for the composer as of now. Without this parameter, you can access it from within Amazon (with a graphical desktop and for instance NoMachine) but not from outside.

Another great setup is a vagrant script using for instance a standard Centos/7 environment without a graphical interface. Using a provisioning script to install Java, set JAVA_HOME and download the Ballerina version (don’t forget to add the parameter shown above) you can actually quickly create a VirtualBox VM with the latest version of Ballerina that is browser accessible. An error will be thrown because there is no browser / GDX installed but it will work.  

You can find  a script at our Yenlo Bitbucket account

Playing around with ballerina will allow you to make your first steps. Because, as you know, you need to learn to walk before you can dance!

Let us know via the comment section if you would like to see some blogs on Ballerina and on what topics. 

New Call-to-action 

Care to share?
   
Picture of Rob Blaauboer
Published December 21, 2017

Rob Blaauboer

Rob is an Integration Consultant & WSO2 Trainer with more than twenty year experience. In addition to his work he is an active blogger working on a number of articles on the ‘Internet of Things’ and a WSO2 ‘Getting Started with …’ series (WSO2 tutorial) in which he talks about WSO2 components and their purpose especially aimed at non-technical readers. Rob is a WSO2 expert and official WSO2 trainer.

Responses

Stay up to date with the latest articles