Today, we’re thrilled to announce the release of Ballerina Swan Lake Beta1! This marks the Ballerina language, standard library, and tooling as “feature complete” on the road to the Swan Lake general availability (GA) release and includes several major redesigns. This beta represents a full preview of what Swan Lake will include and builds on the existing work that was done for the alpha releases.
From now on, we expect to put most of our effort into fixing bugs, improving documentation, and making many usability improvements through a few more releases before the final release. We need your feedback to shape Swan Lake to hit the mark and deliver the programming experience it’s meant to provide. We’ll be keeping a close eye on our issue tracker to iron out issues with Beta1, so download it today and let us know how it works!
The Swan Lake release comes with significant improvements in multiple areas.
- We have redesigned Ballerina services to support RESTful services in a first-class way. Services have become service objects that work uniformly with client objects. Service objects can have both remote methods, which support RPC-style protocols, and resource methods, which support data-oriented protocols such as HTTP and GraphQL.
- Objects work in a more familiar and ergonomic way because we have introduced class definitions. Object type descriptors are now used purely to describe the type of an object, independent of its implementation. We have also introduced object constructor expressions to allow objects to be constructed without defining a class; these provide the semantic foundation for service declarations.
- We have introduced distinct types, which provide functionality similar to nominal types but within the framework of Ballerina’s structural type system. Distinct types work with errors and objects.
- We have significantly improved the way we handle errors. We have built on distinct types to rework how error types are defined. We have added on fail clauses, which allow control over the effect of check expressions.
- The table type has been redesigned to be more ergonomic and work consistently with other structural types. Tables are collections of records, in which records are uniquely identified by one of their fields, similar to a primary key in SQL.
- The language-integrated query feature has been fleshed out to support ordering and joins. It now works with tables and XML as well as lists.
- We have added the concept of configurability: module-level variables can be specified to be configurable, which allows their initial values to be specified at runtime.
- We now have enum declarations. They provide a more convenient and familiar syntax for working with unions of string constants.
- The isolated qualifier, which enables compile-time concurrency safety, is a new addition. This allows a listener to automatically determine when a service can safely handle incoming requests in parallel. It builds on the existing lock statement.
- We have added the readonly type, which makes it possible for the type system to provide immutability guarantees. This is part of the foundation for the design behind isolated and is also used for key fields in tables. The readonly type works in conjunction with intersection types, which are also used with distinct types.
- We have added limited support for dependent typing, in which the return type of a function with an external body can depend on the value of a parameter of typedesc type, which can be defaulted from the contextually expected type. This allows libraries that convert from external data into user-defined data types to provide a convenient, type-safe interface, which does not require type casts.
- We have redesigned language support for transactions, which makes interacting with a transaction manager more reliable and convenient. This replaces the previous experimental transactions feature.
- We have also added a new kind of template called a raw template, which allows a library to control how expressions within the template are handled. The SQL module uses this to provide better support for SQL parameters.
- We have redesigned how you structure your Ballerina code with the introduction of packages, which is a collection of logically related Ballerina modules. We have also made the package the unit of code sharing. As a result, Ballerina Central has been improved to work with packages.
- We have improved Ballerina package builds to be repeatable by default, without requiring an explicit lock file. We have redesigned package versioning to ensure that a program that you build today builds with the same set of dependency versions tomorrow. This behavior does not change even if there are newer versions of dependencies available in Ballerina Central. Package versions and their compatibility ranges strictly follow semantic versioning.
- The Ballerina Central UI has been refreshed to support packages and to enhance the user experience. We’ve also improved the module API docs design to overcome limitations in the previous versions.
- We have redesigned Ballerina standard library APIs by leveraging the latest language features. Library modules that support RESTful-style network protocols have been improved with resource methods, and modules that support RPC-style protocols have been improved with remote methods. Other common standard library modules, such as ballerina/file, ballerina/filepath, ballerina/log, and ballerina/time, have also been redesigned completely.
- We have further simplified the development and deployment of Ballerina code-to-cloud. This way, you can focus more on business logic and less on the underlying complexities of cloud-native development to run Ballerina code on diverse cloud platforms.
- We have also introduced an interactive command-line tool, known as bal shell, that allows you to rapidly learn and prototype Ballerina code.
- The Ballerina VSCode extension has been revamped for a better editing experience. It now comes with auto-completion, hover information, the ability to jump to definitions, formatting, range formatting, renaming, syntax highlighting, and auto-indentation.
- Ballerina programs have both a textual syntax and an equivalent graphical form based on sequence diagrams. Beta1 comes with limited support to visualize Ballerina code as a sequence diagram in the VSCode extension.
- The Ballerina VSCode extension also comes with new and improved debugging capabilities. It also has limited support for expression evaluation.
- Values for configurable variables can be specified via a TOML file or command-line arguments to the program.
- We have redesigned the command-line argument processing to be more ergonomic and also to support the standard POSIX command-line syntax like getopt, plus long option names like C getopt_long.
- We have also updated the bindgen tool to leverage new language features such as distinct objects and classes. The bindgen is a CLI tool that generates Ballerina bindings for Java APIs.
- We have entirely replaced the ANTLR4-generated lexer and parser with a hand-written lexer and recursive-descent parser. Generated lexer/parsers have limitations, and we have faced most of them. It is hard to get meaningful error messages from the generated ones. The new parser is resilient (generates a valid syntax tree even with syntax errors), provides better syntax errors, and supports incremental parsing (creates the syntax tree with only the updated nodes while reusing unchanged tree nodes).
- We have also redesigned the Ballerina compiler to expose the syntactic and semantic information about the source code as APIs. Additionally, we have refreshed the language server implementation, compiler extension design, build tool, etc., with these APIs.
- This release also comes with a new compiler extension design that leverages the new compiler APIs.
To see a detailed list of what has changed since Swan Lake Alpha5, please see the release note.
To recap, the Ballerina project began in 2016 and our goal has been to create a modern programming language that combines the best of programming languages, integration technology, and cloud-native computing into a textual and graphical language optimized for integration. With more than 16,500 downloads in total and over 1,000 Slack users, the Ballerina ecosystem continues to grow. As we move on to bigger and better things, we want to extend our sincerest thanks to every one of you in the Ballerina community for your valuable feedback and support. Swan Lake Beta1 is our best release yet and we couldn’t have done it without all of you!
The Ballerina Team
To report bugs, please create issues in the following GitHub repos:
Follow us for updates.