Fork me on GitHub

General FAQ for SARL

1. General Questions about SARL

1.1. What is SARL?

SARL is a statically-typed agent-programming language. SARL aims at providing the fundamental abstractions for dealing with concurrency, distribution, interaction, decentralization, reactivity, autonomy and dynamic reconfiguration. These high-level features are now considered as the major requirements for an easy and practical implementation of modern complex software applications. We are convinced that the agent-oriented paradigm holds the keys to effectively meet this challenge.

Syntactically and semantically SARL has its roots in the Java programming language but improves on many aspects:

Unlike other JVM languages, SARL has zero interoperability issues with Java: everything you write interacts with Java exactly as expected. At the same time, SARL is much more concise, readable and expressive.

The language is platform- and architecture-independent.

For a brief comparison between SARL, Java and Xtend languages, see the Section "Comparison between SARL and other languages".

1.2. Can I use SARL to make agent-based software?

Yes.

SARL may be used to build agent based applications. Natively, SARL provides features for agent execution and direct communication. The agents may be deployed across multiple networked computers.

1.3. Can I use SARL to make agent-based simulation software?

Yes.

SARL may be used for agent based simulations. Natively, SARL provides features for agent execution and direct communication. An extension is provided for supporting the simulated environments (time management, environment model...)

1.4. Can I use SARL to make holonic software?

Yes.

Holon is recursively composed of holons. In SARL, agents are holons. SARL provides a complete support for holons.

1.5. Can I use SARL to make organizational software?

Yes.

An extension to SARL is available that defines an organizational space based on the CRIO meta-model (Capacity-Role-Interaction-Organization). This meta-model defines a system as a set of organizations in which roles are defined and interact together. Agents play roles in organization instances (or groups) and provides embedded capacity implementations required by the played roles.

Another organizational model may be in another space.

1.6. Is SARL an object-oriented programming language?

Yes and No.

While SARL is an agent-oriented programming language, it is possible to use object-oriented concepts when writing the agent code (skills...) A part of the grammar of SARL is inherited from the Xbase partial programming language, provided by the Xtext framework. It provides statements and rules that correspond to object-oriented languages.

1.7. Can I use my Java classes in SARL?

Yes.

SARL and Java are 100% interoperable. There are no exceptional cases and you do not have to think in two worlds. You can invoke SARL code from Java and vice versa without any surprises or hassles.

1.8. Must I use Maven to create a SARL project?

No.

You can create a SARL project with Eclipse without Maven. Indeed, the SARL Eclipse product supports creation of a SARL project.

However, the SARL developers recommend Maven because it simplifies the management of your project's dependencies on the SARL libraries.

1.9. What is the SRE?

SRE stands for "SARL Runtime Environment." The SRE is an implementation of an agent platform which is able to run a SARL program. The official standard SRE supported by the SARL developers is the Janus platform.

1.10. What is the difference between SARL and Janus?

SARL is a general-purpose agent-oriented language. Janus is a runtime environment (SRE) for multi-agent applications that fully supports the concepts of SARL.

We can compare the SARL universe with the Java universe:

SARL Universe Java Universe
Language Specification SARL Specification Java Specification
Standard Development Kit SARL SDK J(ava)DK
Runtime environment Janus, TinyMAS... Hotspot, IcedTea, Dalvik...

1.11. Where can I find information on the release planning of SARL?

The release planning of SARL is detailed on the milestones page on Github.

1.12. Where can I ask my question?

If your question is not addressed in the FAQ, the reference documents, or the existing issues, you may ask the SARL developers on the SARL forum.

A community driven list of useful SARL libraries, frameworks and software is maintained on Github. This is not a catalog of all the libraries, just a starting point for your explorations. This list is used by the SARL team to update the official web site of SARL.

2. Installation and Execution

2.1. Is my operating system compatible with SARL?

SARL is based on a part of the Eclipse API. Every operating system which has a compatible Java Virtual Machine with Eclipse may be used to run SARL.

2.2. What version of the Java virtual machine is required?

SARL requires the JRE and the JDK 1.8 or higher to compile and run. Note that if you plan to create Android applications, you should configure your JDK to produce 1.6 class files from 1.8 Java code.

2.3. Why does SARL display an error on startup?

Most of the time the problem is due to an incompatibility between the configuration of your operating system or Java virtual machine, and the SARL Eclipse product.

If a problem occured, find the ".log" file in which Eclipse is writting the complete error trace. Usually, it is in your home directory or in the folder of the SARL Eclipse executable file.

2.4. Why does SARL Eclipse fail on Windows 10?

This is due to a problem in your configuration. Most of the time the log file (see the previous question) contains the error "Cannot load 64-bit SWT libraries on 32-bit JVM".

It means that you're trying to run the 64-bit version of the SARL Eclipse with a Java virtual machine (JVM) that is 32-bit. You should install a fully 64-bit JVM, or use the 32-bit version of the SARL Eclipse product.

If another error occurs, you should go on the SARL forum and report this problem.

This is due to a problem in your configuration. SARL tools need the Eclipse framework to be run with a Java Development Kit 1.8 or higher. You are currently running the SARL product with a lower version of the JDK.

You must run the SARL product with a valid version of the JDK. Two ways are available for solving this issue:

  1. install the JDK 1.8, and configuring your operating system to use it by default; or
  2. force the SARL product to use the JDK 1.8 by editing the eclipse-sarl.ini file. Add the following parameter on a new line: -vm path, where path is the path to the binary file javaw[.exe] or java[.exe] of the JDK 1.8.

2.6. Why does the content assistant not propose any suggestion on MacOS?

By default in the SARL product, the shortcut key for invoking the content assistant is Ctrl+Space or Apple+Space. But, the Spotlight tool on MacOS is also using the same shortcut key.

For enabling the SARL product content assist, we recommend to change its shortcut in the SARL product. Go to:

Content assist shortcut change

3. Implementation of SARL Applications

3.1. Is it possible to obtain examples of SARL code for applications?

Yes.

The SARL development environment contains a collection of SARL applications that may be used for creating your own applications. They are called the "SARL examples".

In order to create a fresh project based on of these SARL examples, you have to use the menu File > New > Example. This menu opens a dialog box with a list of examples from which you may select one for creating your fresh project. The SARL examples have been put into several categories:

3.2. How can we know when an agent has been created fully after being spawn?

An event AgentSpawned will be emitted when an agent has been created and can be handled, say by a coordinator, to know the agent is now alive! For example:

on AgentSpawned {
    info("Agent {0} of type {1} has been created successfully and is now alive!",
        occurrence.agentIdentifiers, occurrence.agentType)
}

3.3. Be careful on the emit of events in "on Initialize"

The on Initialize event handler in agents is a bit special, as it is the code ran when an agent is born. As such, its execution is more "synchronous" than other on-behavior rules. In particular:

  1. Any event emitted within an on Initialize, will not be processed until that on Initialize code finishes. So, your agent initialization should not depend (and wait) on any fired event being processed, as they won't!
  2. When spawning an agent in on Initialize, the spawn instructions will return only after the agent has been created. However, creation of the agent (i.e., of the corresponding object) does not include initialization of the agent via its on Initialize handler. Said so, the Java thread manager may process those initialization processes of the new agent before continuing with the execution of the spawning agent (and this seems to be the case in many Linux boxes where the executor service of Java tends to have the same behavior during all the runs). If you change computer, it may be different. In the following example, the thread executor service of Java seems to give the priority to the on Initialize of Agent2 instead of continuing the run of the spawn function.
agent Agent1 {
    uses Logging, Lifecycle
    var agent_name = "agent1"
    on Initialize {
        info(agent_name + " spawned")
        info(agent_name + " spawning Agent2")
        spawn(Agent2)
        info(agent_name + " end")
    }
}
agent Agent2 {
    uses Logging
    var agent_name = "agent2"
    on Initialize {
        info(agent_name + " spawned")
        info(agent_name + " sleeping")
        Thread::sleep(5000)
        info(agent_name + " woke up")
        info(agent_name + " end")
    }
    on Initialize {
        info(agent_name + " init2")
        info(agent_name + " init2 end")
    }
}

The output has been:

Launching the agent: Agent1
agent1 spawned
agent1 spawning Agent2
agent2 spawned
agent2 init2
agent2 sleeping
agent2 init2 end
agent2 woke up
agent2 end
agent1 end

Here it appears as the on Initialize behaviors have been run all before the execution resumes after the spawn() statement, but this is just one way and one should not rely on that behavior being guaranteed: once the spawned agent is created, the spawn() commands returns.

3.4. How can the warnings given by the SARL compiler be avoided?

You can use @SupressWarnings(...) annotations in the entities you do not want to be warned. For example, a typical warning SARL will give is lack of synchronization for variables that can be accessed/edited concurrently: [WARNING] The field noToSpawn should be synchronized for avoiding value inconsistency due to parallel execution. [BootMultiSWIAgents.sarl:70]

To get rid of such warnings, assuming you are aware of the potential issue and have planned for it, you can do:

@SuppressWarnings("potential_field_synchronization_problem")
agent BootMultiSWIAgents {
    //...
}

See the Issue Codes for a complete list of what can be suppressed.

4. Contribute to SARL

4.1. Where are the sources for SARL?

The sources for SARL are available on Github. Details for getting the source code may be found on the download page.

4.2. How can I find the current issues?

SARL Core Developers use Github to manage bug tracking and project workflow. The issues are listed on Github.

4.3. How can I report a problem or a bug in SARL components?

You should submit your issue on this page.

Copyright © 2014-2019 the original authors or authors.

Licensed under the Apache License, Version 2.0; you may not use this file except in compliance with the License. You may obtain a copy of the License.

You are free to reproduce the content of this page on copyleft websites such as Wikipedia.

Generated with the translator io.sarl.maven.docs.generator 0.9.0.