Fork me on GitHub

Comparison between SARL and Other Languages

Java, Xtend and Scala are object-oriented programming languages. As SARL, Xtend is based on the Xtext libraries for compiling to the Java language.

The main features coming from the Java language are supported by SARL too. The following table provides the major differences between the SARL, Java, Xtend and Scala languages, excluding any feature provided by the development environment (Eclipse, IntelliJ…)

1. Agent-Oriented Programming Features

  SARL Java Xtend Scala
Agent, Capacity, Skill, Behavior… Yes No No Partial: actor paradigm

2. Object-Oriented Programming Features

  SARL Java Xtend Scala
Definition of class and interface types Yes Yes Yes Yes
Object-oriented enumeration No, only constants could be defined Yes, constants and functions could be defined No, only constants could be defined Yes, constants and functions could be defined
Definition of annotation types Yes Yes Yes Yes
Definition of static constructors Yes Yes No See companion object
Inheritance of constructors Yes No No No
Automatic creation of read-only data structure Manual with @Data annotation No Manual with @Data annotation No
Automatic creation of getters and setters Manual with Accessors annotation No Manual with @Accessors annotation Yes
Automatic creation of final-field constructor No No Manual with @FinalFieldsConstructor annotation No
Automatic creation of equals()        
and hashCode() Yes No Manual with @EqualsHashCode annotation Yes, see case class
Automatic creation of clone() when cloneable type Yes No No Yes
Automatic creation of a serialVersionUID field when        
serializable type Yes No No Manual with @SerialVersionUID
Automatic creation of the toString() function Manual with @ToString annotation No Manual with @ToString annotation Yes, see case class

3. Functions, Procedures and Operators

  SARL Java Xtend Scala
Definition of dispatch functions Yes No Yes No
Extension methods Yes No Yes Yes
Definition of variadic functions Yes Yes Yes Yes
Definition of default values for the formal parameters Yes No No Yes
Operator overloading (except assignment and casting, see below) Yes No Yes Yes
Cast operator overloading Yes No No No
Assignment operator overloading No No No No
Automatic detection of pure functions and marking Yes No No No

4. Code Expressions

  SARL Java Xtend Scala
Definition of lambda expressions Yes Yes Yes Yes
Inference of types Yes No Yes Yes
Support the break statement Yes Yes No Yes
Support the continue statement Yes Yes No Yes
Implicit typecasting between number values, including AtomicInteger, AtomicLong, AtomicDouble, BigInteger, and BigDecimal Yes Partial: primitive to primitive types, primitive to object wrapper types, and object wrapper to primitive types Partial: primitive to primitive types, primitive to object wrapper types, and object wrapper to primitive types Yes
Arithmetic operations with any type of number as operand, including AtomicInteger, AtomicLong, AtomicDouble, BigInteger, and BigDecimal Yes Partial: primitive and wrapper types Partial: primitive and wrapper types Yes

5. References

This documentation is based on elements from the following sources:

Copyright © 2014-2024 SARL.io, the Original Authors and Main Authors.

Documentation text and medias are licensed under the Creative Common CC-BY-SA-4.0; you may not use this file except in compliance with CC-BY-SA-4.0. You may obtain a copy of CC-BY-4.0.

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

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

Generated with the translator docs.generator 0.14.0.