Fork me on GitHub

Changes in 0.10.0

Release date: 2019-10-26.

1. Major Changes

Number of major changes : 8

1.1. Support of Java 11

The entire SARL project was tested against the versions 8 and 11 of Java. The version 8 must still be used for running the SARL DSL Environment in order to create SARL libraries that could be used on a JRE 1.8.

For application developers who are using SARL, they could use either Java 8 or Java 11 for running the SARL Development environment, or the SARL applications that are the result of the SARL compilation.

1.2. Try-with-resources

The try-with-resources statement is a try statement that declares one or more resources. A resource is an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements AutoCloseable, which includes all objects which implement Closeable, can be used as a resource.

The following example reads the first line from a file. It uses an instance of BufferedReader to read data from the file. BufferedReader is a resource that must be closed after the program is finished with it:

def readFirstLineFromFile(path : String) : String {
	try (var br = new BufferedReader(new FileReader(path))) {
		return br.readLine
	}
}

In this example, the resource declared in the try-with-resources statement is a BufferedReader. The declaration statement appears within parentheses immediately after the try keyword. The class BufferedReader, inherited from Java libraries, implements the interface AutoCloseable. Because the BufferedReader instance is declared in a try-with-resource statement, it will be closed regardless of whether the try statement completes normally or abruptly.

1.3. Implicit Names for Lambda Formal Parameters

When a lambda (also known as closure) has multiple parameters, and no name is provided by the SARL developer, the SARL compiler in its previous version generates an error because it was able to consider only it as an implicitly declared variable, i.e. there was too many implicit parameter to declare by the compiler and it cannot do that.

In its version 0.10, the SARL compiler is able to a generate default name for each of the formal parameters of a lambda, even if there are multiple unnamed parameters. The implicit name for the first parameter becomes $0, $1 for the second, $2 for the third, etc.

The example below shows the definition of an interface, a class that is calling an instance of the previous interface, and a piece of code that is invoking the class. It is interesting to note that the arguments’ values of the lambda expressions are accessed with their implicit names.

interface MyInterface {
	def a(a : int, b : char, c : String)
}

class MyClass {
	def b(lambda : MyInterface) {
		lambda.a(1, '2', "3")
	}
}

var i = new Myclass
i.b [
	println($0)
	println($1)
	println($2)
]

1.4. Introduction of the two events ParticipantJoined and ParticipantLeft

The events ParticipantJoined and ParticipantLeft are introduced. The first is fired when an agent has joined a space that has participants, e.g. an event space. The second is fired when an agent has left a space.

1.5. Better Concurrent Execution with Read-Write Locks

The uses of mutual exclusion locks were replaced by similar uses of read-write locks.

A read-write lock maintains a pair of associated locks, one for read-only operations and one for writing. The read lock may be held simultaneously by multiple reader threads, so long as there are no writers. The write lock is exclusive. The read-write lock implementation guarantees that the memory synchronization effects of writeLock operations also hold with respect to the associated readLock. That is, a thread successfully acquiring the read lock will see all updates made upon previous release of the write lock.

A read-write lock allows for a greater level of concurrency in accessing shared data than that permitted by a mutual exclusion lock. It exploits the fact that while only a single thread at a time (a writer thread) can modify the shared data, in many cases any number of threads can concurrently read the data (hence reader threads). In theory, the increase in concurrency permitted by the use of a read-write lock will lead to performance improvements over the use of a mutual exclusion lock.

1.6. Tool for generating the API documentation

Sarldoc is a documentation generator for the SARL language for generating API documentation in HTML format from SARL source code. The HTML format is used for adding the convenience of being able to hyperlink related documents together. To pass source code to sarldoc, you have to provide the names of the folders in which the SARL code files are located. Then, the sarldoc tool generates a set of HTML files that contains the API documentation of your program.

1.7. Performance improvements

The SARL compiler was reviewed in order to remove several memory leaks that cause low performances when compiling large number of SARL files. Even if this task is always active, several improvements have been obtained in this version of SARL.

1.8. New demonstration: the Reynold’s Boids

Boids is an artificial life program, developed by Craig Reynolds in 1986, which simulates the flocking behaviour of birds. The name “boid” corresponds to a shortened version of “bird-oid object”, which refers to a bird-like object. As with most artificial life simulations, Boids is an example of emergent behavior; that is, the complexity of Boids arises from the interaction of individual agents (the boids, in this case) adhering to a set of simple rules. The rules applied in the simplest Boids world are as follows:

The SARL development environment provides an implementation of the Reynold’s Boids within the set of available “examples.” This version of the Boids is implemented with the Java AWT graphical library.

2. Detailed Changes

2.1. SARL Language

2.1.1. SARL Syntax

2.1.2. SARL Validator

2.1.3. Java Model Inferrer

2.1.4. SARL Core Library

2.1.5. SARL Batch Compiler

2.2. SARL Development Toolkit (SDK)

2.3. Eclipse Development Environment

2.3.1. General Changes

2.3.2. Outline Component

2.3.3. Wizards

2.3.4. Other Components

2.4. External Contributions to SARL

2.4.1. Examples

2.4.2. LaTeX Styles

2.5. Janus Run-time Environment

2.6. Maven Tools

2.6.1. Maven Base Library

2.6.2. Bootique Application Module

2.6.3. JavaFX Application Module

2.6.4. Documentation Generator Plugin

2.7. Command-Line Tools

2.7.1. sarlc

2.7.2. sarldoc

2.8. SARL Documentation

2.9. Tools for SARL Contributors

2.9.1. Development Environment

2.9.2. Dependencies

2.9.3. Back Door to the SRE

2.9.4. Unit Tests

2.9.5. Generator of the SARL Compiler (MWE2 Tools)

3. Changes in the Previous Versions