A programming language for integration.

Download >


The future apps we write increasingly depend upon APIs. Integration is the discipline of resilient communication between endpoints.

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?

Integration with ESBs is still waterfall development. The server must be deployed, connectors configured, service logic programmed with XML, and data querying and transformation with XPath. This is not developer friendly.

Programming languages with frameworks like Spring and Node.js offer agility, but do not make it simple to program distributed system constructs with concurrency models that are not suited for sequence parallelization.

Integration
Products

ESBs, EAI, BPM, and DSLs require XML and configuration disrupting the iterative developer flow: edit, build, run, and test.

Not Agile

The
Integration
Gap

General Purpose
Programming Languages

Developers take responsibility for the hard problems of integration with runtimes not suited to sequence parallelization.

Not Integration Simple

What are Ballerina's language design principles?

SEQUENCE DIAGRAMMATIC

LANGUAGE INSPIRATION

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

VISUALIZATION AS SEQUENCE DIAGRAMS

Ballerina’s language semantics model how independent parties communicate via structured interactions. Subsequently, every Ballerina program can be displayed as a sequence diagram of it’s flow. These visualizations are available in plugins for IntelliJ and VS Code. The Ballerina Composer is a tool for authoring Ballerina services with sequence diagrams.

ACTORS AND ACTIONS

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.

CONCURRENCY

SEQUENCE DIAGRAMS AND CONCURRENCY

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.

WORKER SEMANTICS

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.

PROGRAMMING MODEL

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

TYPE SYSTEM

TYPE SAFETY

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

UNION TYPES AND EXPLICIT NULLS

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.

HETEROGENEOUS DATA HANDLING

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 heterogenous data and transformation logic.

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.

RUNTIME ARCHITECTURE

BALLERINA API GATEWAY

Enforces performance and identity policies for running services. Configured and deployed through code annotations. Can run embedded in-line with a service, as a containered proxy managing multiple services, or with an API management solution like WSO2 API Manager.

BALLERINA SERVICE

Represent your API and execution logic. Services operate over different protocols and the internal code structure is compiled into API interfaces with support for OpenAPI and Swagger. Services communicate with endpoints, whether they are the calling client or other services.

BALLERINA BRIDGE

Enables legacy code and services to participate with Ballerina services in distributed transactions. The bridge wraps your existing service with a localhost proxy that enlists and brokers distributed transactions with invoking Ballerina services.

MESSAGE BROKER, TRANSACTION COORDINATOR, AND IDENTITY BROKER

Provide brokered infrastructure capabilities to Ballerina services participating in transactions, event-driven communications, or authentication flows. These components are embedded within services for single service deployments or can be separately deployed and scaled for managing multiple services.

DEPLOYMENT ARCHITECTURE

IAAS

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.

ORCHESTRATOR

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.

SERVICE MESH

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.

LIFECYCLE ARCHITECTURE

BALLERINA TOOLS

Get intellisense like autocomplete and debugging within VS Code and IntelliJ using our language server. Ballerina's keywords and syntax structure is designed to represent sequence diagrams. Visualize and edit Ballerina code with Ballerina Composer. Bonus - it also visualizes runtime dev traces.

BALLERINA BUILD

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).

CI/CD DEPLOYMENT

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.

REGISTRIES

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.