Ballerina makes it easy to write cloud native applications while maintaining reliability, scalability, observability, and security.

Download >

Ballerina is a compiled, transactional, statically and strongly typed programming language with textual and graphical syntaxes. Ballerina incorporates fundamental concepts of distributed system integration into the language and offers a type safe, concurrent environment to implement microservices with distributed transactions, reliable messaging, stream processing, and workflows.

Why did we build Ballerina?

Cloud native and microservices architectures enable enterprises to have trillions of programmable network endpoints, making integration the glue that brings APIs, microservices, and data together as a whole. Centralized and configuration-driven approaches to integration, with ESBs, are not agile or cloud native. Programming languages with frameworks like Spring and Node.js offer agility but require writing a lot of complex and boilerplate code to integrate endpoints.


ESBs, EAI, BPM, and DSLs require writing configuration-driven integration which is disrupting the iterative developer flow: edit, build, run, and test.

Not Agile


General Purpose
Programming Languages

Developers take responsibility for the hard problems of integrating endpoints with runtimes that lack adequate integration abstractions.

Not Integration Simple




Sequence diagrams are a reflection of how designers and developers document interconnected systems. Ballerina’s syntax and effective coding model requires developers to code using strong interaction best practices.


Ballerina’s language semantics model how independent parties communicate via structured interactions. Subsequently, every Ballerina program can be displayed as a sequence diagram of its flow.


Ballerina represents clients, workers, and remote systems as different actors in the sequence diagram. In code, remote endpoints are interfaced via connectors, which offer type-safe actions. Graphically, each connector is represented as an actor in the sequence diagram (i.e., a vertical line) and actions are represented as interactions with those actors.


Ballerina’s concurrency model is parallel-first since interactions with remote parties always involve multiple workers. Interactions between workers are handled as message passing, with no shared state.


Ballerina’s execution model is composed of lightweight parallel execution units known as workers. Workers use non-blocking policies to ensure no function locks an executing thread, such as an HTTP I/O call awaiting response.


Workers and fork/join language semantics abstract the underlying non-blocking approach to enable a simpler concurrency programming model.


Ballerina has a structural type system with primitive, record, object, tuple, and union types. This type-safe model incorporates type inference at assignment and provides numerous compile time integrity checks for connectors, logic, and network-bound payloads.


Individual network endpoints often return messages with different payload types and errors, depending on their inputs and logic. Ballerina’s type system embraces this variability with an approach based on union types. Union types explicitly capture this semantics without requiring developers to create unnecessary “wrapper” types. This approach also enhances the handling of null values. By default, types do not support null values. Developers must explicitly create union types to handle nulls. The result is that null exceptions cannot happen and the language syntax and compiler identifies whether null handling logic is required or not.


The Ballerina type system has rich built in support for JSON, XML, streams and tables, as well as direct support for ProtoBuf and gRPC. The result is clean, readable code for dealing with network payloads, SQL programming and stream processing. Data transformation logic isn’t encumbered with complex generated types, third-party library code or other obfuscation - simple clear readable code captures interactions with heterogeneous data and transformation logic.


This ensures that malicious data received by the program does not propagate through a system. In Ballerina, functions can mark returned values as tainted. Consumers of those functions are responsible for sanitizing such values. This analysis is performed statically, and using unsanitized data will result in compile time errors.


Functions can declare inputs to be security sensitive. Passing tainted data to such functions will result in compilation errors. The developer has to sanitize such data first.


Ballerina enforces multiple security checks and secure-defaults to prevent critical security vulnerabilities.


Services, endpoints, and networking concepts are first-class constructs in Ballerina, which are represented graphically as well as textually.


Interactions over the network are denoted by the arrow operator (->) to differentiate from normal function calls. Unreliability of the network is not ignored and calls over the network return an error in addition to the actual response.


Resiliency concepts such timeout, retry, and circuit breaking are in-built. Any data received over the network is treated as tainted and has to be sanitized.


Code annotations generate docker and kubernetes artifacts during the build, which allows the developer to maintain deployment aspects


Over the past 15 years, best practices and expectations on the associated toolset that a language provides have evolved. Now, a language is not ready for adoption unless it includes a unit test framework, build system, documentation generation, dependency management and versioning, and a way to share modules of reusable code. Ballerina includes all of these subsystems as part of its core distribution so that there is no risk of community drift, which is what happens when the ecosystem needs to build tools on top of a language instead of designing it within the language.


Ballerina’s package management, dependency and versioning model is based on learnings from Docker, Elm, and NPM. While it is possible to build and run individual Ballerina source files, packages (modules) can only be built as part of a project, which is managed by Ballerina. Every project has its own dependency cache and all packages are versioned according to semver rules. Strict rules limit dependency conflicts from applications that import packages from a central registry. Packages can be pushed to Ballerina Central and shared with the other users.


Testing constructs are built-in. Test functions, dependent tests, and mocking are all part of the test framework in Ballerina.


Ballerina’s language and annotations are intentionally environment-aware, treating these other components as syntactical objects and also relationships as decorated annotations. By having the language and build system be environmentally aware of other components surrounding our service, we can generate essential artifact code ahead of CI/CD, perform data and integrity checks around network-bound payloads, and pre-package dependent but not yet deployed components as part of the Ballerina binary.

No pitfalls

Static code analysis tools which are designed to catch pitfalls in languages are not required when you code in Ballerina.

Return values cannot be ignored

A function return value indicates a result of some computation or whether the function is completed or some error occurred. Returns values should always be checked regardless of whether the function is a side-effect free function or not. Ballerina complains if the return values of function calls are ignored during the compile time.

Read-only (or effective final) function parameters

Ballerina treats function parameters as read-only variables to avoid intentional or unintentional reassigning of function parameters.

How does Ballerina work?

Ballerina's syntax, code, and compiler create runtime services and deployment artifacts that are cloud native ready for deployment within your IaaS, orchestrator, or service mesh of choice. The developer experience is designed to maintain flow, where the edit, build, debug cycle is rapid and integrated to your team's lifecycle toolchain.

Network-aware data types

Ballerina has built-in network aware data types such as JSON, XML, table & stream. Service code can directly work with these data types.

Built-in QoS

Built-in QoS in Ballerina enable developers to write resilient, transactional, secure & observable code without any additional libraries.


Service endpoints represent entry points to services. Client endpoints represent connections to external systems & APIs. These endpoints are bound to transport protocols.


The standard library has support for HTTP, gRPC, WebSocket, messaging and other transport protocols.

Workers & Asynchrony

A worker is a parallel unit of execution in Ballerina. Every bit of code runs within the context of a worker. Therefore, service logic runs within a worker. Also, the runtime is designed to have inherent asynchronous execution features, such as seamless non-blocking I/O


Using code annotations and the build system, Ballerina services and other runtime components like the API gateway can be packaged for deployment into any cloud native environment. On IaaS environments, Ballerina services can run as a VM or a container, with images optionally pushed to a registry during build.


Code annotations trigger compiler extensions that generate artifact packages of Ballerina components for different orchestrators such as Kubernetes or Cloud Foundry. Vendors or DevOps can add custom code annotations to generate environment-specific deployments, such as a custom blue-green deployment algorithm.


Ballerina services can optionally delegate circuit breaking and transaction flow logic to a service mesh like Istio or Envoy if present. Ballerina services embed equivalent capabilities, if a service mesh is missing.


The language server enables autocompletion and debugging with VS Code and IntelliJ. Ballerina's keyword and syntax structure is designed to represent sequence diagrams. Visualize and edit Ballerina code with Ballerina Composer. Bonus - it also visualizes runtime dev traces.


Compiles services into optimized byte code for execution with a memory-tuned BVM. Project structure, dependency management, package management, and unit testing with Testerina are provided. Build locks make it easy to recreate services and deployments. Generate executables (.balx) or libraries (.balo).


Deployment code annotations trigger build extensions that generate artifacts for continuous integration, continuous delivery, or orchestrator environments. Push build artifacts to your CI / CD system or skip it entirely.


Use or combine endpoint connectors, custom annotations and code functions as shareable packages. Push and pull versioned packages with Ballerina Central, a shared global repository.

What are Ballerina's language features?

Designed to be cloud-first, Ballerina has built-in support for modern web protocols and data formats, full power of a Turing-complete programming language, and native support for microservices architectures.










What’s in Ballerina for integration?

Ballerina is a language designed to be integration simple. Based around the interactions of sequence diagrams, Ballerina has built-in support for common integration patterns and connectors, including distributed transactions, compensation and circuit breakers. With first-class support for JSON and XML, Ballerina makes it simple and effective to build robust integration across network endpoints.


Try the language with Ballerina by Example

Ballerina by Example teaches you the language incrementally with commented examples that cover every nuance of our syntax.

Learn integration with Ballerina by Guide

Ballerina by Guide are long form examples that showcase how to build different types of integrations using a complete development lifecycle including IDE configuration, packages, dependencies, coding, unit testing, deployment and observability.