Est. 2017 Intermediate

Ballerina

A cloud-native programming language that makes network integration a first-class concern, with built-in HTTP, gRPC, and data services alongside a unique sequence diagram visualization.

Created by WSO2 (Sanjiva Weerawarana, James Clark, and team)

Paradigm Concurrent, Integration, Compiled
Typing Static, Strong, Structural
First Appeared 2017
Latest Version Swan Lake Update 13 (2201.13.x, 2025)

Ballerina is a statically typed, compiled programming language designed for writing cloud-native applications that integrate over networks. Unlike general-purpose languages that treat HTTP clients, message brokers, and data services as external library concerns, Ballerina embeds these as first-class language constructs. Every Ballerina program also has an intrinsic graphical representation as a sequence diagram — not a visualization tool layered on top, but a bidirectional view derived directly from the language’s concurrency semantics.

History & Origins

Ballerina was born from a specific frustration with enterprise integration. WSO2, an open-source middleware company founded in 2005 by Sanjiva Weerawarana, had built its product suite around the Enterprise Service Bus (ESB) model. ESBs used XML-based domain-specific languages to configure integration logic. For simple cases, XML configuration worked. For complex cases, developers were forced to drop into Java extensions — creating two languages, two build systems, two deployment pipelines, and significant operational friction.

Weerawarana formalized the Ballerina project inside WSO2 in August 2016. The initial goal was modest: improve the ESB’s configuration language into something more programmer-friendly. That goal quickly expanded into building a full general-purpose language with integration as a core concern, rather than an afterthought. As the project grew, WSO2 brought in James Clark — creator of the expat XML parser, author of the XSLT and RELAX NG specifications — to help with language design. Clark joined as an advisor in early 2017 and, in February 2018, was asked to write the formal language specification. That process lasted over 18 months and significantly shaped the language’s type system and semantics.

Ballerina was publicly announced and open-sourced at WSO2Con US in San Francisco around February 2017. The project had originally estimated six to eight months to reach a 1.0 release. It took over three years. Version 1.0.0 was released on September 10, 2019, under the Apache 2.0 license.

The period between 1.0 and the major Swan Lake redesign was significant: WSO2’s own API Manager team deployed Ballerina to production internally in 2018, providing critical real-world feedback that informed the language’s evolution.

Design Philosophy

Ballerina’s philosophy is captured in its positioning as a language where “the program is the integration.” Rather than writing a general-purpose application that calls integration libraries, a Ballerina program is the network service, expressed in a language whose semantics are designed around distributed systems patterns.

Several core principles guide the design:

Network-first, not network-added. HTTP services, gRPC clients, WebSocket connections, GraphQL endpoints, message brokers (Kafka, NATS, RabbitMQ), and SQL databases are defined as language-level constructs using service and client keywords. They are not imported from third-party packages or configured in external YAML files.

Data independence. Ballerina takes a data-oriented approach rather than an object-oriented one. Data (records, arrays, maps, tables) is independent of behavior. JSON is a native data type with a direct one-to-one mapping to Ballerina’s in-memory types, eliminating the marshaling and unmarshaling layer common in other languages. XML is similarly a native type.

Graphical and textual duality. Every Ballerina function has an equivalent representation as a sequence diagram. This is not a post-hoc visualization — the language’s concurrency model (workers communicating via message passing) was deliberately designed to have a lossless mapping to sequence diagram notation. The VS Code extension renders live bidirectional diagrams: changes in source code update the diagram, and changes in the diagram update the source code.

Explicit errors, no exceptions. Errors are not thrown; they are returned as values. The error type is a distinct basic type in the language, and functions that can fail declare this via union return types (e.g., returns string|error). The compiler prevents silently ignoring error values. A check keyword provides concise error propagation without ceremony.

Safe concurrency by design. The concurrency model uses lightweight logical threads called strands, similar to Go’s goroutines. Within a single OS thread, strands yield cooperatively, eliminating the data races common in shared-memory multi-threaded models. Communication between concurrent workers happens via typed message passing, which maps naturally to the sequence diagram visual.

Key Features

Services and Clients

A Ballerina HTTP service requires no framework or annotation processor:

1
2
3
4
5
6
7
import ballerina/http;

service / on new http:Listener(8080) {
    resource function get hello() returns string {
        return "Hello, World!";
    }
}

The service keyword, listener, and resource functions are language syntax, not library conventions. Client objects for consuming remote APIs are symmetrically designed:

1
2
http:Client cl = check new ("https://api.example.com");
json response = check cl->get("/data");

Structural Type System

Ballerina uses structural (duck) typing rather than nominal typing. Type compatibility is determined by the shape of the data, not the name of the declared type. This is particularly valuable for network programming, where real-world data rarely conforms perfectly to expectations:

1
2
3
4
5
6
7
8
type Person record {
    string name;
    int age;
};

// Any record with 'name' (string) and 'age' (int) is compatible
json j = {"name": "Alice", "age": 30};
Person p = check j.cloneWithType(Person);

The type system simultaneously functions as a schema language for validating and describing network payloads — a dual role that is unusual and directly useful for integration work.

Integrated Query Expressions

Ballerina includes SQL-like query syntax for processing in-memory and streamed data:

1
2
3
4
Person[] seniors = from var p in persons
                   where p.age >= 60
                   order by p.name
                   select p;

These queries work uniformly across arrays, streams, tables, and XML sequences.

Error Handling

Functions that can fail return error as part of their type. The check keyword propagates errors to the caller without a try-catch block:

1
2
3
4
function fetchUser(int id) returns User|error {
    json response = check httpClient->get("/users/" + id.toString());
    return check response.cloneWithType(User);
}

Code to Cloud

Annotations in source code automatically generate Docker and Kubernetes deployment artifacts. Earlier versions used @docker:Expose and @kubernetes:Deployment annotations; current releases use the @cloud annotation module, which causes the compiler to produce the corresponding Dockerfile or deployment.yaml alongside the compiled program, reducing the operational burden of maintaining separate DevOps configuration files.

GraalVM Native Compilation

From Swan Lake Update 7 (2201.7.0, 2023) onward, Ballerina programs can be compiled to native executables using GraalVM’s ahead-of-time compilation. This capability is documented as experimental and requires a GraalVM installation alongside the standard Ballerina toolchain.

The Swan Lake Redesign

The Swan Lake release (2201.0.0, February 2022) represented a major evolution from the 1.0 foundation. Key changes included:

  • Revised object model: Objects became more principled, with a clearer separation between the class construct for defining reusable types and object expressions for creating anonymous instances.
  • Refined type system: The structural type system was formalized with semantic subtyping as its theoretical basis, especially effective for tree-structured data like JSON.
  • Isolated functions and objects: A isolated qualifier was introduced to express that a function or object can be safely called from concurrent contexts, enabling the compiler to verify concurrency safety.
  • New versioning scheme: The 2201.x.y version numbering encodes the year (22) and month (01) of the initial Swan Lake GA release, followed by the update number (x) and patch number (y).

Evolution

Subsequent updates after Swan Lake have progressively expanded Ballerina’s capabilities:

  • Update 7 (2023): Experimental GraalVM native compilation
  • Update 11 (February 2025): Java 21 LTS support, enabling Ballerina programs running on the JVM to use Java 21 virtual threads for improved concurrency
  • Update 12 (2025): Post-quantum cryptography support, adding TLS 1.3 with MLDSA and MLKEM algorithms to the standard library
  • Update 13 (2025): Experimental “natural expressions” for AI-assisted code generation; OpenShift deployment support added to Code to Cloud

Current Relevance

As of early 2026, Ballerina is under active development by WSO2, with regular updates roughly every three to six months for major releases and more frequent patch releases. The project is open source under Apache 2.0 and hosted at github.com/ballerina-platform.

The language occupies a genuine niche that few others address directly: cloud-native service integration with the full expressiveness of a compiled, statically typed language. Competitors include Go (for microservices), Apache Camel (for integration DSLs), and MuleSoft (for commercial ESB tooling) — but none combine the sequence diagram visualization, the structural type system, and the code-to-cloud automation pipeline in a single language.

The community is growing but remains focused: strongest in the Asia-Pacific region and in organizations that have existing WSO2 investments. The case study portfolio includes international identity platforms (MOSIP), healthcare AI, and enterprise IT integration, but Ballerina has not yet achieved the broad adoption of Go or Kotlin in the cloud-native space.

Why It Matters

Ballerina represents a coherent answer to a real architectural question: what would a programming language look like if network integration were as fundamental as loops and functions? Most languages evolved from a time when network programming was exceptional; Ballerina starts from the premise that it is ordinary.

The sequence diagram duality is the language’s most intellectually distinctive contribution. The claim — that a concurrent program can have a lossless, bidirectionally editable graphical representation — is not a claim that any mainstream language has seriously attempted. Whether this proves to be a lasting innovation or a curiosity will depend on whether the developer community comes to value visual reasoning about concurrent network programs the way it values static typing or type inference.

What is already demonstrated is that the underlying design decisions — structural typing for JSON-native data, explicit error returns enforced by the compiler, strand-based concurrency that eliminates data races by construction — are individually sound and collectively coherent. Ballerina is a serious language built to solve a serious problem, and it reflects a genuine rethinking of what programming looks like when the network is the primary medium.

Timeline

2016
Project formally named 'Ballerina' and development begins at WSO2 in August, led by Sanjiva Weerawarana
2017
Ballerina publicly announced and open-sourced at WSO2Con US in San Francisco (around February 2017)
2018
Version 0.980 released at BallerinaCon in San Francisco (July 2018); James Clark begins writing the formal language specification
2018
WSO2 API Manager team deploys Ballerina to production internally, providing real-world validation before the 1.0 release
2019
Ballerina 1.0.0 released (September 10, 2019) under the Apache 2.0 license — a stable production release after more than three years of development
2020
Version 1.1 released in January; Swan Lake preview series begins, introducing major language redesign
2021
Swan Lake Beta 1 released, formalizing the new type system, object model, and language constructs
2022
Swan Lake GA released as version 2201.0.0 (February 2022), introducing a new versioning scheme encoding the initial release year and month
2023
Swan Lake Update 7 (2201.7.0, July 2023) adds experimental GraalVM ahead-of-time native compilation support
2025
Swan Lake Update 11 (2201.11.0, February 2025) adds Java 21 LTS support with virtual threads; Update 12 (2201.12.0, March 2025) introduces post-quantum cryptography (TLS 1.3 with MLDSA/MLKEM algorithms); Update 13 (2201.13.0, 2025) adds experimental natural expressions for LLM integration and OpenShift support in Code to Cloud

Notable Uses & Legacy

WSO2

WSO2 itself uses Ballerina for internal digital transformation initiatives, including integrations between Salesforce and NetSuite for enterprise operations.

MOSIP (Modular Open Source Identity Platform)

An international open-source digital identity platform adopted by multiple governments for civil registry digitization, using Ballerina for integration services.

RAAPID.AI

Healthcare AI company using Ballerina for risk adjustment and HCC (Hierarchical Condition Category) coding services in clinical data pipelines.

VisualizeHR

Cloud-native multi-tenant HR systems integration platform built on Ballerina for connecting enterprise HR data sources.

QHAna/QuAntiL

Research tooling for quantum computing application lifecycle management, using Ballerina for service orchestration in the quantum software engineering workflow.

Language Influence

Running Today

Run examples using the official Docker image:

docker pull ballerina/ballerina:latest

Example usage:

docker run --rm -v $(pwd):/home/ballerina -w /home/ballerina ballerina/ballerina:latest bal run hello.bal
Last updated: