Skip to main content

Ballerina Specifications

Ballerina is defined by a set of formal specifications that govern the language semantics, standard library behavior, and platform requirements. These specifications serve as the authoritative reference for language implementors, library authors, and developers who need precise behavioral definitions.

Language specification

The Ballerina Language Specification defines the syntax, type system, semantics, and execution model of the Ballerina programming language.

AttributeDetail
Current version2024R1
SpecificationBallerina Language Specification
StatusActive, updated with each Swan Lake release
FormatHTML

Specification sections

SectionTopics Covered
Lexical StructureTokens, keywords, identifiers, literals, comments
Values, Types, and VariablesType system, basic types, structured types, behavioral types
ExpressionsOperators, literals, member access, function calls, query expressions
StatementsVariable declarations, assignments, control flow, transactions
Module and Program StructureModules, imports, visibility, program entry points
ConcurrencyStrands, workers, isolation, transactions
Error HandlingError type, check, trap, on fail
Type NarrowingType guards, type test expressions
Object TypesObject definitions, methods, constructors
Other TypesStream, future, typedesc, handle

Language specification versions

VersionSwan Lake ReleaseKey Changes
2024R1Swan Lake Update 9Regular expressions, resource method typing enhancements
2023R1Swan Lake Update 7Tuple rest descriptors, isolated inference improvements
2022R4Swan Lake Update 4Configurable variables refinements, query expression enhancements
2022R3Swan Lake Update 3Intersection types for errors, resource methods for client objects
2022R1Swan Lake GAInitial Swan Lake specification

Standard library specifications

Each standard library module has its own specification defining the module's API contract, behavior, and error semantics.

Core library specifications

ModuleDescription
ballerina/lang.valueOperations on all Ballerina values
ballerina/lang.arrayArray/Tuple operations (push, pop, sort, filter)
ballerina/lang.mapMap/Record operations (get, entries, keys, values)
ballerina/lang.stringString operations (substring, trim, split)
ballerina/lang.intInteger operations and limits
ballerina/lang.floatFloating-point operations
ballerina/lang.decimalDecimal operations
ballerina/lang.booleanBoolean operations
ballerina/lang.errorError type operations
ballerina/lang.xmlXML type operations
ballerina/lang.tableTable operations
ballerina/lang.regexpRegular expression operations
ballerina/lang.runtimeRuntime management operations
ballerina/lang.transactionTransaction management

Network library specifications

ModuleKey Topics
ballerina/httpHTTP service, client, request/response, security, interceptors
ballerina/grpcgRPC service, client, streaming patterns
ballerina/graphqlGraphQL service, schema generation, subscriptions
ballerina/websocketWebSocket service, client, lifecycle
ballerina/websubWebSub subscriber, hub integration
ballerina/tcpTCP listener, client, byte stream handling
ballerina/udpUDP datagram communication
ballerina/emailSMTP, POP3, IMAP protocols
ballerina/ftpFTP/SFTP client and listener

Data library specifications

ModuleKey Topics
ballerina/ioFile I/O, stream I/O, console I/O
ballerina/sqlGeneric SQL client, parameterized queries, transactions
ballerina/persistData persistence layer, entity modeling
ballerina/constraintData validation constraints

Platform specification

The Ballerina Platform Specification defines the build system, package management, and runtime environment.

AttributeDetail
Build toolbal CLI
Package formatBALA (Ballerina Archive)
Package registryBallerina Central
RuntimeJVM-based (Java 17+)
Native compilationGraalVM native image (experimental)

Platform components

ComponentSpecification AreaDescription
Package SystemModule structure, Ballerina.toml, Dependencies.tomlPackage layout, dependencies, versioning
Build Systembal build, bal run, bal testCompilation, execution, testing pipeline
Central RepositoryPackage publishing and resolutionVersioned package distribution
Type NarrowingFlow typing and type guardsCompile-time type inference
Concurrency ModelStrand-based executionCooperative concurrency on JVM threads
Transaction ManagerTwo-phase commit protocolDistributed transaction coordination

Specification versioning

Ballerina specifications follow a versioning scheme tied to Swan Lake releases.

SchemeFormatExampleDescription
Language specYYYYRN2024R1Year and release number within that year
DistributionYYYY.N.N2201.9.2Year, minor version, patch version
Module specSemantic versioning2.11.2Major.minor.patch per module

Where to find specifications

ResourceURL
Language specification (latest)ballerina.io/spec/lang/master/
Module specificationsEach module's GitHub repository under docs/spec/
Swan Lake release notesballerina.io/downloads/swan-lake-release-notes/

See also