Releases: ballerina-platform/ballerina-lang
Ballerina 1.1.1 Released!
Overview of JBallerina 1.1.1
Ballerina 1.1.1 is a patch release iteration of its previous 1.1.0 release, which introduces the below functionalities. Also, this release addresses a few bug fixes
and improvements.
You can use the inbuilt updating capability (introduced in Ballerina 1.1.0) to update to Ballerina 1.1.1 by executing the respective command from the below list.
Installed version | Current active version | Command |
---|---|---|
jBallerina-1.1.0 | jBallerina-1.1.0 | ballerina dist update |
jBallerina-1.1.0 | versions below jBallerina-1.1.0 | ballerina dist pull jballerina-1.1.1 |
If you have not installed jBallerina or if you have installed a version prior to 1.1.0, then download the installers to install.
Note: However, if you installed jBallerina via the installers when you have jBallerina 1.1.0 installed, execute the following command to activate it:
ballerina dist use jballerina-1.1.1
Standard Library
- HTTP2 response trailer support
- Add support for reading array values via the config-api
- Add cache for OAuth2-based inbound authentication
Build Tools
Add major improvements to the Ballerina build phase to reduce the total build time by ~30%.
IDE Plugins
Add support for the Signature Help feature.
Language Specification Deviation Fixes
Previously, the implementation initialized an object field’s default value in the __init()
function of the object, which caused the default values to be set to the field even when the __init()
method was called explicitly.
For example, the below sample prints “foo” as the value of f.s
since the default value “foo” was set as the value of f.s
whenever the __init()
method was called.
import ballerina/io;
type Foo object {
string s = "foo";
function __init() {
}
function reInit() {
self.__init();
}
};
public function main() {
Foo f = new();
// Update field `s`.
f.s = "bar";
f.reInit();
io:println(f.s);
}
This is fixed in 1.1.1 so that now this sample prints “bar”.
Ballerina 1.1.0 Released!
Overview of JBallerina 1.1.0
Ballerina 1.1.0 is the year end release which has significant improvements to the developer tooling, standard library modules, compiler, and runtime.
Highlights
- Enhanced
ballerina
CLI tool to keep your Ballerina installation up to date - Improved runtime performance
- Improved support for Java interoperability
- Optimized compiler for better IDE experience
- Based on a stable language specification: 2019R3
- Includes a number of important bug fixes
What's new in JBallerina 1.1.0
Ballerina tool
Ballerina 1.1.0 introduces ballerina tool with set of commands which allows users to manage Ballerina distributions. These are functionalities allowed by the tool.
- Update current distribution to the latest patch version
ballerina dist update
- Fetch a specified distribution and set it as the active version
ballerina dist pull
- Set a specified distribution as the active distribution
ballerina dist use
- List locally and remotely available distributions
ballerina dist list
- Remove a specified distribution
ballerina dist remove
Apart from that in order update tool itself following command could be used
ballerina update
Language
The language implementation is based on the stable language specification version 2019R3. The implementation has been improved and stabilized by fixing critical specification deviations and bugs in the 1.0.0 release. Some of these changes are backward incompatible. Check the "Language changes since JBallerina 1.0.0" section for the full list of changes.
The parser used by the compiler has been improved with a file-based cache. This significantly improves the performance of the JBallerina Language Server, which in turn improves the user experience of the IDEs. Additionally, few minor fixes have been done to Compiler AST to support better IDE insights.
Runtime
- Runtime performance improvements
- Improved runtime type checking performance
- Improved performance for creating and accessing maps, records and arrays.
- Java interoperability improvements
- Supports using
string
type, finite types, and function pointers, for parameters and/or return type in java interop functions. - Improved compile time validation for interop method signatures.
Project Structure & Build Tools
Standard Library
- Path param suffix support for HTTP service dispatcher
- HTTP cookie support
- 100-continue support for HTTP2
- Add observability support for gRPC
- Add observability support for WebSocket
- Add observability support for NATS connector
- Add support for publishing messages with a replyTo callback service in NATS
IDE Plugins & Language Server
- IntelliJ live template support for ballerina code snippets.
- Go-to definition support for both VSCode & IntelliJ plugins
- Add CLI commands to start Language Server and start Debug Adaptor
- Diagram support for tests
- Improvements to language support
- Performance improvements to language server
- Significant improvements to decrease the response time for language intelligence features such as auto completion, diagnostics and etc.
Dev Tools
API Documentation generator
- Fix type label generation for array types
- Prevent link generation for non-public types
Open API tool
- Support for oneOf & allOf schema types
- Improvements to Ballerina record types generator
Detailed list of changes from 1.0.0 to 1.1.0
Language changes since JBallerina 1.0.0
This section highlights key Language changes since JBallerina 1.0.0. These changes are backward-incompatible and the 1.1.0 compiler generates compile-time errors now.
You can find the list of Language and Compiler related fixes in this release from here.
String Literal
The JBallerina 1.0.0 compiler allowed 0xA
and 0xD
code points in string literals even though they are invalid in a string literal. Validation has been added to disallow the same in this release.
// Following is a compile time error.
string s = "hello
world";
Foreach Statement
The compiler now validates the if the correct type is specified for record iteration. The following code should produce a compilation error now.
function testForeachRecord() {
record {| string s; anydata|error...; |} value = {s : "aString"};
foreach any item in value { // Now gives a compilation error.
// Some Code
}
}
While Statement
This release includes several bug fixes that improve the detection of potentially uninitialized variables inside a while loop. This may break source code compatibility with the 1.0.0 release.
Destructuring assignment statement
The Implicit variable type narrowing section of the Ballerina language specification says “the narrowed type for a variable x no longer applies as soon as there is a possibility of x being assigned to”. But this validation was not enforced properly when used in the context of a [Destructuring assignment statement](https://ballerina.io/spec/lang/2019R3/#section_7.14.4. Furthermore, final variable analysis was also incomplete with destructuring assignments. These validations are corrected with this release.
Check Expression
The 1.0.0 compiler does not properly validate the compatibility of the check expression’s error type with the enclosing function’s return type. This flaw leads to programs panicking at runtime when the expression evaluates to an incompatible error type. The 1.1.0 compiler introduces this compile-time validation.
The check
expression acts as a conditional return statement. This fact was ignored in taint analysis and within the transaction block, but has been fixed with this release. Now the check
expression enforces marking function return values as @tainted
where applicable and check
expressions are not allowed within a transaction block similar to the return statement.
Function Type and Value
Function type descriptors and anonymous functions now support rest parameters.
Example:
var foo = function (string b, int... c) returns int {
return 5;
};
function (string, int...) returns int bar = foo;
Additionally, the 1.0.0 compiler accepted arrays in place of functions pointer rest arguments. It has now been fixed to only accept rest arguments.
function myFuncton(string b, int... c) { }
public function main() {
function(string, int...) func1 = myFuncton;
// Worked in 1.0.0, now a compile time error.
func1("a", [1, 2, 3]); // Error
// Compile time error in 1.0.0, but correct behaviour
func1("a", ...[1, 2, 3]); // or func1("a", 1, 2, 3);
function (string a, int[] b) func2 = myFuncton; // Worked in 1.0.0, now a compile time error.
function (string a, int... b) func3 = myFuncton; // Not supported in 1.0.0, but correct behavior.
}
Object Type
Object Initialization specifies that if at any point in the __init
method there are any potentially uninitialized fields, then using the self
variable other than to access or modify the value of a field should produce a compile-time error. This validation has been added to the compiler in the 1.1.0 release. The following code should produce a compilation error now.
type Person object {
string name;
int age = 0;
public function __init(string name, int age) {
self.setAge(age); // error: field `name` is not initialized
self.name = name;
}
function setAge(int age) {
self.age = age;
}
};
When the __init
method is not present in an object, the 1.0.0 compiler skipped validating the arguments to the new
expression. This behavior is corrected with the 1.1.0 release.
Iterable Objects
This release adds support for Iterable objects. Moreover the result of a range expression has also been updated to be a new object belonging to the abstract object type Iterable<int>
.
import ballerina/io;
type IterableObject object {
function __iterator() returns IntIterator {
return new IntIterator();
}
};
type IntIterator object {
int i = 0;
public function next() returns record {|int value;|}? {
self.i += 1;
return self.i < 10 ? {value: self.i} : ();
}
};
public function main() {
foreach int i in new IterableObject() {
io:println(i);
}
}
Worker Actions
The 2019R3 specification defines that in a single receive action if the sending worker terminated with failure, the evaluation of the single receive completes normally with the result being the termination value of the sending worker, which will be an error. This validation was not enforced for the sync send action, but has been added with this release.
The following results in a compilation error now.
function WorkerInteraction () {
worker w1 returns error? {
int i = 10;
if (true) {
return error("Error!");
}
i ->> w2;
}
worker w2 {
int i = <- w1; // error: expected type int|error
}
}
Documentation String
Ballerina Flavored Markdown syntax provides conventions for referring Ballerina-defined names from within the documentation string in a source file. This support has been added in JBallerina 1.1.0.
Example:
...
Ballerina 1.0.5 Released!
Overview of Ballerina 1.0.5
The Ballerina 1.0.5 release contains bug fixes and improvements. Please refer to the Github repository for a list of bug fixes
and improvements.
Ballerina 1.0.4 Released!
Overview of Ballerina 1.0.4
The Ballerina 1.0.4 release contains bug fixes and improvements. Please refer to the Github repository for a list of bug fixes
and improvements.
Ballerina 1.0.3 Released!
Overview of Ballerina 1.0.3
The Ballerina 1.0.3 release is the successor for previous 1.0.2 with more stabilization. Please refer to the Github repository for a list of bug fixes
and improvements.
Ballerina 1.0.2 Released!
Overview of Ballerina 1.0.2
The Ballerina 1.0.2 release is a continuation of the effort to stabilize and improve the 1.0.0 release while maintaining backward compatibility.
This release also focuses on improving the performance of the compiler, runtime, build tools, and developer tools.
Please refer to the Github repository for a list of bug fixes
and improvements.
Ballerina 1.0.1 Released!
Overview to Ballerina 1.0.1
Ballerina 1.0.1 release is an iteration effort that aims to stabilize the previous 1.0 release with backward compatibility.
Please refer Github repository to list bug fixes and improvements
Ballerina 1.0.0 Released!
Overview of Ballerina 1.0.0
Ballerina 1.0.0 is here! We would like you to try it out and give us feedback via our Slack channel, Google Group, Twitter, or Github.
Ballerina 1.0.0 consists of improvements to the language syntax and semantics based on the stable language specification version 2019R3 and new features and enhancements to the standard library modules and developer tooling.
Highlights
- Based on a stable language specification: 2019R3
- Introduces a brand new Ballerina compiler back-end that targets the JVM
- Significant performance improvements over the previous Ballerina runtime (BVM)
- Java interoperability (allows you to call Java code from Ballerina)
- Major redesign of Ballerina developer tools
What's new in Ballerina 1.0.0
Language
-
A set of modules, which contain functions associated with the basic types have been introduced. Collectively, these modules are referred to as the lang library. Each basic type has a corresponding lang library module. Additionally, there is also the
lang.value
module, which holds functions common for all the types. The following is the list of lang library modules.ballerina/lang.value
ballerina/lang.array
for list typesballerina/lang.decimal
for basic typedecimal
ballerina/lang.error
for basic typeerror
ballerina/lang.float
for basic typefloat
ballerina/lang.future
for basic typefuture
ballerina/lang.int
for basic typeint
ballerina/lang.map
for mapping typesballerina/lang.object
for basic typeobject
ballerina/lang.stream
for basic typestream
ballerina/lang.string
for basic typestring
ballerina/lang.table
for basic typetable
ballerina/lang.typedesc
for basic typetypedesc
ballerina/lang.xml
for basic typexml
-
The basic type
handle
has been added. Ahandle
value is a reference to storage area of a Ballerina program that is managed externally.Handle
values are useful only in conjunction with functions that have external function bodies; in particular, a new handle value can be created only by a function with an external function body. -
The error reason is now optional if the reason can be inferred based on the contextually-expected type.
type Detail record { int code; }; const FOO = "foo"; type FooError error<FOO, Detail>; FooError e1 = error(FOO, code = 3456); FooError e2 = error(code = 3456); // Also valid now, reason is set as "foo"
-
A unary operator
typeof
has been introduced to retrieve a typedesc value for the runtime type of a value.typedesc t = typeof valueExpr;
-
A binary operator
.@
has been introduced to access annotation values at runtime.annotation Foo annot on service; typedesc t = typeof serviceValue; Foo? fooAnnot = t.@annot;
-
Expressions are now allowed as default values for function parameters.
-
The concept of lax typing has been introduced allowing less stricter static typing for types identified as lax. With lax typing, some of the static typing checks are moved to the runtime returning errors at runtime instead. With this release,
json
andmap<T>
whereT
is lax are considered as lax. -
An optional field access operator
?.
has been introduced to access possibly-undefined mapping members. Optional field access on lax types may returnerror
if applied to a non-mapping value.
Runtime
This release introduces a brand new implementation (jBallerina) of the Ballerina language spec, which targets the JVM. The jBallerina compiler produces an executable JAR file for a Ballerina program by directly transforming Ballerina sources to Java bytecode. With jBallerina, the previous Ballerina runtime implementation (BVM) will be deprecated and removed. jBallerina comes with significant performance improvements over the BVM.
Java Interoperability
Java interoperability is a key feature in jBallerina that allows you to call Java code from Ballerina. It also enables you to embrace the capabilities of Ballerina for new projects while utilizing existing Java libraries that you or your organization invested in for years.
Project Structure & Build Tools
-
Ballerina project structure should match the following.
project-name/ - Ballerina.toml - src/ -- mymodule/ --- Module.md <- module-level documentation --- main.bal <- Contains the default main method. --- resources/ <- resources for the module (available at runtime) --- tests/ <- tests for this module (e.g. unit tests) ---- main_test.bal <- test file for main ---- resources/ <- resources for these tests - target/ <- directory for compile/build output -- bin/ <- Executables will be created here -- balo/ <- .balo files one per built module --- mymodule.balo <- balo object of module1 -- caches/ <- BIR, JAR cache directory
-
To create a new project with a hello world, use the new command. This initializes a new directory.
$ ballerina new <project-name>
-
To add a module, use the add command inside the project.
$ ballerina add <modulename> [-t main|service]
-
To create an executable, use the build command.
$ ballerina build
-
To run the executable, use the run command.
$ ballerina run mymodule.jar
Ballerina Central
- Supports pushing of Ballerina modules with embedded, dependent native Java libraries.
Standard Library
- Revamp the NATS connector to support both NATS and Streaming Servers.
- Introduce the standard library module-wise errors as a replacement for the builtin
error
.
e.g., Ballerina HTTP Error types includehttp:ClientError
,http:ListenerError
,http:ClientAuthError
etc. - Introduce capability to engage custom providers and handlers for inbound/outbound authentication.
- Introduce OAuth2 inbound authentication.
- Introduce own modules for different authentication mechanisms (JWT, LDAP, OAuth2 etc.).
- Introduce prior knowledge support to the HTTP/2 client.
- Add flow control support to HTTP/2 client and server.
- Introduce XSLT transformation support.
ballerina/h2
andballerina/mysql
database client modules and theballerina/sql
module have been discontinued. Theballerinax/java.jdbc
client module can be used to interact with relational databases.- The byte channel read API was updated to return only
byte[]|io:Error
. - Introduce out of the box support for messaging with Kafka.
- RabbitMQ, JMS, Artemis, WebSub and LDAP modules are available through Ballerina Central.
- APIs for performing file system operations such as creating files, creating directories, moving directories, renaming files, fetching file metadata, copying files etc. are now available through the
ballerina/file
module. - Most of the APIs of the
ballerina/encoding
module were removed since they are now supported via the lang library. - Three new utility modules were introduced to manipulate built-in
string
,json
andxml
types.
IDEs & Language Server
IntelliJ IDEA Plugin
- Introduce Ballerina home auto detection capability.
- Introduce Ballerina sequence diagram view.
- Revamp the debugger using a DAP (Debugger Adapter Protocol) client.
Tooling
- Ballerina Formatter: Ballerina source formatting CLI tool.
- OpenAPI to Ballerina generator CLI tool.
- Ballerina to OpenAPI generator CLI tool.
- OpenAPI validator compiler plugin.
- Introduce Debug Adapter Protocol implementation.
Breaking Changes from 0.991.0
Breaking Language Changes
Builtin library
The ballerina/builtin
module has been removed. Some of the functionalities provided by the ballerina/builtin
library is now provided by the newly-added lang library.
-
The
freeze()
builtin method has been replaced with thecloneReadOnly()
lang library function.cloneReadOnly()
can be called only on variables of the typeanydata
. It creates and returns a clone of the value that has been made immutable (for non-simple basic types).Previous Method
map<string> m2 = m.freeze();
New Method
map<string> m2 = m.cloneReadOnly();
-
The
convert()
builtin method has been replaced with theconstructFrom()
lang library function.constructFrom()
can only be called on a type descriptorT
where theT
is a subtype ofanydata
. It accepts ananydata
value as an argument and returns a value of the typeT
constructed using a deep copy of the provided argument. If the construction fails, it returns an error.Previous Method
json j = {name:"tom", age:2}; Person|error p = Person.convert(j);
New Method
json j = {name:"tom", age:2}; Person|error p = Person.constructFrom(j);
-
The following behaviours, which were previously associated with the
convert()
method is now provided by the lang library functions of the relevant types.-
Previously,
convert()
was used to parse string literals. Now, thelang.int
,lang.float
, andlang.decimal
modules have afromString()
function, which accepts a string literal and parses it.Previous Method
int|error x = int.convert("100");
New Method
import ballerina/lang.'int; // Need to import `lang.int` int x = 'int:fromString("100");
-
Previously, when invoked on the
string
type descriptor, ...
-
Ballerina 0.991.0 Released!
Overview of Ballerina 0.991.0
Ballerina 0.991.0 consists of improvements to the language syntax and semantics based on the language specification and new features and improvements to the standard library modules, extensions, and tooling.
Highlights
- Improved error handling with new checkpanic expression. Now, error values cannot be ignored using "_".
- Improved type checking with the union type.
- Improved syntax for the closed record, closed arrays, and string/XML interpolation etc.
- Additionally, this release includes several fixes to address Ballerina language specification deviations from the Ballerina 0.990 specification.
Breaking Language Changes
- Closed record syntax was updated to use the {| and |} delimiters to indicate that the record is closed.
Previous syntax
type Person record {
string name;
int age;
!...;
};
New syntax
type Person record {|
string name;
int age;
|};
- The syntax for destructure binding pattern for closed records was also updated to use the {| and |} delimiters.
Previous syntax
Person p = { name: "John Doe", age: 25 };
Person { name: pName, age: pAge, !... } = p;
New syntax
Person p = { name: "John Doe", age: 25 };
Person {| name: pName, age: pAge |} = p;
- The syntax for closed arrays with inferred length was changed as follows.
Previous syntax
string[!...] array = ["a", "b", "c"];
New syntax
string[*] array = ["a", "b", "c"];
-
It is now mandatory for list element types to have an implicit initial value. Where a type
T
does not have an implicit initial value, aT?[]
could be used. -
Use of the
null
literal is now restricted to JSON contexts.
json response = null; // Allowed
string? name = null; // Compile error
- String template expression interpolation syntax was updated.
Previous syntax
string s = string `Hello {{name}}!`;
New syntax
string s = string `Hello ${name}!`;
- XML literal interpolation syntax was updated.
Previous syntax
xml x = xml `<Person name={{name}}>{{content}}</Person>`;
New syntax
xml x = xml `<Person name=${name}>${content}</Person>`;
-
Interpolating XML elements and attribute names are no longer supported.
-
The XML attribute expression now directly returns the attributes of a singleton
xml
element as amap<string>
or()
if the operand is not a singletonxml
.
Previous syntax
map<anydata> attributeMap = map<anydata>.convert(x1@);
New syntax
map<string>? attributeMap = x1@;
-
Error values can no longer be ignored using “”. If the result of an expression is an
error
type or is a union that contains anerror
type, the result cannot be ignored using “”. This is to enforce the user to handle all possible errors. -
The capability to consider (run) any public function as an entry point to a Ballerina program was removed.
-
The types of the parameters and the return type of the
main
function were restricted to subtypes ofanydata
anderror?
respectively. -
The diamond operator was updated to perform type-casting as follows:
Foo f = <Foo> value;
If value
belongs to Foo
, casting will be successful and value
will be assigned to f
. Else, casting will result in a panic.
-
The type of the
error
detail is now restricted to be a mapping that could only have fields of types that are subtypes ofanydata|error
. -
The default record rest field type was changed to
anydata|error
fromanydata
. -
anydata
was updated to include structures of pure values (values whose types are subtypes ofanydata|error
).anydata
is now the union of the following:
() | boolean | int | float | decimal | string | (anydata|error)[] | map<anydata|error> | xml | table
-
Module variable declarations are not allowed to be
public
now and also require an assignment. -
The syntax for functions with external implementations has been changed as follows:
Previous syntax
extern function externFunction();
New syntax
function externFunction() = external;
- The signature of the
__attach()
method ofAbstractListener
has been changed as follows:
Previous signature
public function __attach(service s, map<any> annotationData) returns error?
New signature
public function __attach(service s, string? name = ()) returns error?;
- Type narrowing does not apply to global variables now.
Breaking Standard Library Changes
Crypto Library Changes
- Ballerina crypto stdlib was made flexible enough to introduce new features and algorithms in future.
Previous syntax
string input = "Hello Ballerina";
crypto:hash(input, crypto:MD5)
New syntax
string input = "Hello Ballerina";
byte[] inputArr = input.toByteArray("UTF-8");
byte[] output = crypto:hashMd5(inputArr);
gRPC Library Changes
Ballerina gRPC client initialization in the generated code is changed. Generated file(*.pb.bal) from previous versions of Ballerina distributions will not be worked with this release. Regenerate the client stub using proto to Ballerina tool and replace the previously generated file with the new one.
Task Library Changes
Redesigned the Task library to function as a service. The previous task implementation of task:Timer
and task:Appointment
will be deferred and new task:Listener
and task:Scheduler
objects are introduced to create task timers and appointments.
Tasks now can be defined as a service and as an object. Both the previously existed Timer and Appointment functionalities can be used by new Listener and/or Scheduler.
Timer
Timer was previously created by providing onTrigger
and onError
functions along with the interval
and delay
parameters. Now interval
and delay
parameters are provided through a task:TimerConfiguration
record type, while onTrigger
function should be implemented as a resource function inside the attaching service.
Service can be created on top of a task:Listener
or can be manually attached to a task:Scheduler
object.
Previous Syntax
function startTimer() {
((function) returns error?) onTriggerFunction = cleanup;
function (error) onErrorFunction = cleanupError;
timer = new task:Timer(onTriggerFunction, onErrorFunction, 1000, delay = 500);
timer.start();
}
function cleanup() returns error? {
// onTriggerFunction
}
function cleanupError(error e) {
// handle error
}
New Syntax
function startTimer() {
task:TimerConfiguration timerConfiguration = {
interval: 1000,
initialDelay: 500
}
task:Scheduler timer = new(timerConfguration);
var attachResult = timer.attach(timerService);
if (attachResult is error) {
// handle error
} else {
var startResult = timer.start();
if (startResult is error) {
// handle error
} else {
// successfully started timer
}
}
}
Service timerService = service {
resource function onTrigger() {
// onTrigger function
}
}
OR
task:TimerConfiguration timerConfiguration = {
interval: 1000,
initialDelay: 3000
};
listener task:Listener timer = new(timerConfiguration);
Service timerService on timer {
resource function onTrigger() {
// onTrigger function
}
}
Appointment
task:Appointment
functionality can be implemented using task:Listener
and the task:Scheduler
objects. Previously the cronExpression
used for the appointment given as a parameter, along with the onTrigger
and onError
functions. Now the cronExpression
should be provided using appointmentDetails
field inside the task:AppointmentConfiguration
record type. Alternatively, task:AppointmentData
record can also be provided as the appointmentDetails
field (see below examples).
onTrigger
function should be implemented inside a service, and the service can be created on top a task:Listener
or the service can be attached to a task:Scheduler
object, manually.
Previous Syntax
function startAppointment() {
((function) returns error?) onTriggerFunction = cleanup;
function (error) onErrorFunction = cleanupError;
appointment = new task:Appointment(onTriggerFunction, onErrorFunction, "0/2 * * * * ?");
appointment.schedule();
}
function cleanup() returns error? {
// onTrigger function
}
function cleanupError(error e) {
// handle error
}
New Syntax
task:AppointmentData appointmentData = {
seconds: "0/2",
minutes: "*",
hours: "*",
daysOfMonth: "?",
months: "*",
daysOfWeek: "*",
year: "*"
};
task:AppointmentConfiguration appointmentConfiguration = {
appointmentDetails: appointmentData
};
listener task:Listener appointment = new(appointmentConfiguration);
service appointmentService on appointment {
resource function onTrigger() {
// onTriggerFunction
}
}
OR
function startAppointment() {
task:AppointmentConfiguration appointmentConfiguration = {
appointmentDetails: “0/2 * * * * ?”
};
task:Scheduler appointment = new(appointmentConfiguration);
var attachResult = appointment.attach(appointmentService);
if (attachResult is error) {
// handle error
} else {
var startResult = appointment.start();
if (startResult is error) {
// handle error
} else {
// succ...
Ballerina 0.990.3 Released!
Overview of Ballerina 0.990.3
Ballerina 0.990.3 is a release iteration done based on the 0.990 language specification. It includes improvements on standard library modules, extensions, tooling, and language syntax.
Compatibility and Support
- The record
rest-fields
descriptor should now be followed by a semi colon.
type Person record {
string name;
string...;
};
- Constrained JSON is no longer supported. The
stamp()
orconvert()
methods can be used instead depending on the requirement. - Binary integer literals are no longer supported.
- Use of
var
in the left hand side, with iterable operations ending withmap()
orfilter()
operations is disallowed.
int[] numbers = [-5, -3, 2, 7, 12];
// The following now results in a compilation error.
var filtered = numbers.filter(function (int i) returns boolean {
return i >= 0;
});
Improvements
Language & Runtime
In Ballerina, floating point types (float
and decimal
) adheres to the IEEE754-2008 standard. Hence, floating point types accommodate NaN and Infinity concepts. Now, along with the float
type, decimal
type also supports NaN and Infinity concepts.
Dividing a number by zero will no longer result in a panic situation. Rather, it will result in infinity(+/-) for all non-zero real numbers and NaN. Now, in addition to this, the decimal
type supports three built-in functions namely isNaN()
, isInfinite()
, and inFinite()
to check whether a given number is NaN, Infinity, or a finite number.
Standard Library
- Now, the type
time:Time
, which represents an instance of time with the associated timezone is arecord type
(not anobject type
). Member functions of the previoustime:Time
object are now provided as utility functions. - Support for using the
optional
configuration for client authentication in SSL. - The SimpleDurableTopicSubscriber, SimpleQueueReceiver, SimpleQueueSender, SimpleTopicPublisher, and SimpleTopicSubscriber were removed from the JMS API. The initialization API of the TopicPublisher, TopicSubscriber, DurableTopicSubscriber, QueueReceiver, and QueueSender has been modified to support all simple use cases as well.
- Support on WebSub Hub persistence.
- Basic auth support for WebSub Hub.
- Ballerina
crypto
standard library is reorganized to enhance the extensibility of the library and to increase reusability across other standard libraries.- Now, the
crypto
standard library provides RSA-signing capabilities in addition to hashing operations, HMAC generation, and CRC32B checksum generation. - Instead of returning Hex encoded
string
values, crypto operations now returnbyte[]
(byte array). This allows users to consume raw bytes as well as to use the newly addedencoding
standard library, to get string values encoded using different encoding algorithms. - Also, the
crypto
standard library now provides thecrypto:KeyStore
,crypto:PrivateKey
, andcrypto:PublicKey
records. These are usable across other standard libraries to represent key stores, private keys, and public keys.
- Now, the
- Ballerina
encoding
standard library provides functions to perform the following:- Encode
byte[]
(byte arrays) tostring
using different encoding algorithms. - Decode
string
values intobyte[]
(byte array) using different decoding algorithms. - The
byteArrayToString
function that can be used to encodebyte[]
into astring
using a selected character encoding.
- Encode
IDEs & Language Server
- Update LSP version to v3.13.0.
- Markup Content Support on Signature Help, Hover Provider, and Completion.
- Code Lens support.
IDEA Plugin
- Ballerina code folding support.
- Spell-checking support.
- Improved Signature Help.
- Minor bug fixes and improvements.
Compiler Extensions
- Support on AWS Lambda functions.
Performance Results
Refer Ballerina performance test results available in the repository.
Bug Fixes
Refer Github milestone issues to view bug fixes.
Getting Started
You can download the Ballerina distributions, try samples, and read the documentation at https://ballerina.io. You can also visit the Quick Tour to get started.
We encourage you to report issues, improvements, and suggestions at the Ballerina Github Repository.