diff --git a/docs/io.sarl.docs.markdown/src/main/documentation/index.md b/docs/io.sarl.docs.markdown/src/main/documentation/index.md index d5189d6d6a..500882f63e 100644 --- a/docs/io.sarl.docs.markdown/src/main/documentation/index.md +++ b/docs/io.sarl.docs.markdown/src/main/documentation/index.md @@ -74,6 +74,7 @@ * [Assertions](./reference/general/Assertion.md) * Meta-programming: * [Active annotations](./reference/general/ActiveAnnotations.md) +* [Comparison between SARL and other Languages](./reference/LanguageComparison.md) ### Agent-Oriented Programming @@ -88,6 +89,7 @@ ### Object-Oriented Programming * [Basic Object-Oriented Programming Support](./reference/OOP.md) +* [Comparison between SARL and other Languages](./reference/LanguageComparison.md) ## Compilation and Generation Infrastructure diff --git a/docs/io.sarl.docs.markdown/src/main/documentation/reference/LanguageComparison.md b/docs/io.sarl.docs.markdown/src/main/documentation/reference/LanguageComparison.md new file mode 100644 index 0000000000..d2136a1559 --- /dev/null +++ b/docs/io.sarl.docs.markdown/src/main/documentation/reference/LanguageComparison.md @@ -0,0 +1,160 @@ +# Comparison between SARL and Other Languages + +Java, [Xtend](https://www.eclipse.org/xtend/) and +[Scala](http://scala-lang.org/) are object-oriented programming languages. +As SARL, Xtend is based on the [Xtext](https://www.eclipse.org/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...) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SARLJavaXtendScala
Agent-oriented programming
Agent, Capacity, Skill, Behavior...YesNoNoPartial: actor paradigm
Object-oriented programming
Definition of class and interface typesYesYesYesYes
Object-oriented enumeration + No, only constants could be definedYes, constants and functions could be definedNo, only constants could be definedYes, constants and functions could be defined
Definition of annotation typesYesYesYesYes
Definition of static constructorsYesYesNoSee companion object
Inheritance of constructorsYesNoNoNo
Automatic creation of read-only data structureManual with @Data annotationNoManual with @Data annotationNo
Automatic creation of getters and settersManual with @Accessors annotationNoManual with @Accessors annotationYes
Automatic creation of final-field constructorNoNoManual with @FinalFieldsConstructor annotationNo
Automatic creation of equals() + and hashCode()YesNoManual with @EqualsHashCode annotationYes, see case class
Automatic creation of clone() + when cloneable typeYesNoNoYes
Automatic creation of a serialVersionUID field when + serializable typeYesNoNoManual with @SerialVersionUID
Automatic creation of the toString() function.Manual with @ToString annotationNoManual with @ToString annotationYes, see case class
Functions, Procedures and Operators
Definition of dispatch functionsYesNoYesNo
Extension methodsYesNoYesYes
Definition of variadic functionsYesYesYesYes
Definition of default values for the formal parametersYesNoNoYes
Operator overloadingYesNoYesYes
Automatic detection of pure functions and markingYesNoNoNo
Expressions
Definition of lambda expressionsYesYesYesYes
Inference of typesYesNoYesYes
Support the break statementYesYesNoYes
Support the continue statementYesYesNoYes
Implicit typecasting between number values, including AtomicInteger, AtomicLong, AtomicDouble, BigInteger, and BigDecimalYesPartial: primitive to primitive types, primitive to object wrapper types, and object wrapper to primitive typesPartial: primitive to primitive types, primitive to object wrapper types, and object wrapper to primitive typesYes
Arithmetic operations with any type of number as operand, including AtomicInteger, AtomicLong, AtomicDouble, BigInteger, and BigDecimalYesPartial: primitive and wrapper typesPartial: primitive and wrapper typesYes
+ + +## References + +This documentation is based on elements from the following sources: + +* [Xtend](https://www.eclipse.org/xtend/documentation.html) +* [Xtext](https://www.eclipse.org/Xtext/documentation.html) +* [Java Tutorials](https://docs.oracle.com/javase/tutorial/) +* [Scala Home Page](https://www.scala-lang.org/) + + + +[:Include:](../legal.inc) diff --git a/docs/io.sarl.docs.markdown/src/main/documentation/reference/OOP.md b/docs/io.sarl.docs.markdown/src/main/documentation/reference/OOP.md index 33ac8ccf59..af9317ac4b 100644 --- a/docs/io.sarl.docs.markdown/src/main/documentation/reference/OOP.md +++ b/docs/io.sarl.docs.markdown/src/main/documentation/reference/OOP.md @@ -18,140 +18,7 @@ complete support of the OOP, you should use a dedicated language, such as Java, ## Comparison between SARL and Other Languages -Java, [Xtend](https://www.eclipse.org/xtend/) and -[Scala](http://scala-lang.org/) are object-oriented programming languages. -As SARL, Xtend is based on the [Xtext](https://www.eclipse.org/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...) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SARLJavaXtendScala
Agent-oriented programming
Agent, Capacity, Skill, Behavior...YesNoNoPartial: actor paradigm
Object-oriented programming
Definition of class and interface typesYesYesYesYes
Object-oriented enumeration - No, only constants could be definedYes, constants and functions could be definedNo, only constants could be definedYes, constants and functions could be defined
Definition of annotation typesYesYesYesYes
Definition of static constructorsYesYesNoSee companion object
Inheritance of constructorsYesNoNoNo
Automatic creation of read-only data structureManual with @Data annotationNoManual with @Data annotationNo
Automatic creation of getters and settersManual with @Accessors annotationNoManual with @Accessors annotationYes
Automatic creation of final-field constructorNoNoManual with @FinalFieldsConstructor annotationNo
Automatic creation of equals() - and hashCode()YesNoManual with @EqualsHashCode annotationYes, see case class
Automatic creation of clone() - when cloneable typeYesNoNoYes
Automatic creation of a serialVersionUID field when - serializable typeYesNoNoManual with @SerialVersionUID
Automatic creation of the toString() function.Manual with @ToString annotationNoManual with @ToString annotationYes, see case class
Functions, Procedures and Operators
Definition of dispatch functionsYesNoYesNo
Extension methodsYesNoYesYes
Definition of variadic functionsYesYesYesYes
Definition of default values for the formal parametersYesNoNoYes
Operator overloadingYesNoYesYes
Automatic detection of pure functions and markingYesNoNoNo
Expressions
Definition of lambda expressionsYesYesYesYes
Inference of typesYesNoYesYes
Support the break statementYesYesNoYes
Support the continue statementYesYesNoYes
+A comparison between SARL and other programming languages could be found [here](./LanguageComparison.md). ## Class diff --git a/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Cast.md b/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Cast.md index 53851962e8..2e0e9295eb 100644 --- a/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Cast.md +++ b/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Cast.md @@ -23,6 +23,10 @@ be typed after the expression and before the casting type. In the first example, the [:a:] expression is casted to [:integer:]. In the second example, the [:b:] expression is casted to [:integer:] too. +## Implicit Conversions + +Coming soon. + [:Include:](../generalsyntaxref.inc) diff --git a/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Types.md b/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Types.md index 757789d67b..082af758c4 100644 --- a/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Types.md +++ b/docs/io.sarl.docs.markdown/src/main/documentation/reference/general/Types.md @@ -29,16 +29,16 @@ may be performed on it. In addition to [:inttype:], the SARL programming languag A primitive type is predefined by the language and is named by a reserved keyword. Primitive values do not share state with other primitive values. The eight primitive data types supported by the SARL programming language are: -| Type | Object Equivalent | Definition | -| --------- | --------------------- | ----------------------------------------------------- | -| `byte` | `java.lang.Byte` | The `byte` data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of `int` where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation. | -| `short` | `java.lang.Short` | The `short` data type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with byte, the same guidelines apply: you can use a short to save memory in large arrays, in situations where the memory savings actually matters. | -| `int` | `java.lang.Integer` | By default, the `int` data type is a 32-bit signed two's complement integer, which has a minimum value of -2^31 and a maximum value of 2^(31)-1. In SARL, you can use the `int` data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 2^(32)-1. Use the `Integer` class to use `int` data type as an unsigned integer. Static methods like `compareUnsigned`, `divideUnsigned` etc have been added to the `Integer` class to support the arithmetic operations for unsigned integers. | -| `long` | `java.lang.Long` | The `long` data type is a 64-bit two's complement integer. The signed `long` has a minimum value of -2^63 and a maximum value of 2^(63)-1. In SARL, you can use the `long` data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 2^(64)-1. Use this data type when you need a range of values wider than those provided by `int`. The `Long` class also contains methods like `compareUnsigned`, `divideUnsigned` etc to support arithmetic operations for unsigned long. | -| `float` | `java.lang.Float` | The `float` data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the SARL Language Specification. As with the recommendations for `byte` and `short`, use a `float` (instead of `double`) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the `java.math.BigDecimal` class Numbers and Strings covers `BigDecimal` and other useful classes provided by the SARL platform. | -| `double` | `java.lang.Double` | The `double` data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the SARL Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency. | -| `boolean` | `java.lang.Boolean` | The `boolean` data type has only two possible values: `true` and `false`. Use this data type for simple flags that track `true`/`false` conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined. | -| `char` | `java.lang.Character` | The `char` data type is a single 16-bit Unicode character. It has a minimum value of `\u0000` (or 0) and a maximum value of `\uffff` (or 65,535 inclusive). | +| Type | Object Equivalent (Wrapper) | Definition | +| --------- | --------------------------- | ----------------------------------------------------- | +| `byte` | `java.lang.Byte` | The `byte` data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of `int` where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation. | +| `short` | `java.lang.Short` | The `short` data type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). As with byte, the same guidelines apply: you can use a short to save memory in large arrays, in situations where the memory savings actually matters. | +| `int` | `java.lang.Integer` | By default, the `int` data type is a 32-bit signed two's complement integer, which has a minimum value of -2^31 and a maximum value of 2^(31)-1. In SARL, you can use the `int` data type to represent an unsigned 32-bit integer, which has a minimum value of 0 and a maximum value of 2^(32)-1. Use the `Integer` class to use `int` data type as an unsigned integer. Static methods like `compareUnsigned`, `divideUnsigned` etc have been added to the `Integer` class to support the arithmetic operations for unsigned integers. | +| `long` | `java.lang.Long` | The `long` data type is a 64-bit two's complement integer. The signed `long` has a minimum value of -2^63 and a maximum value of 2^(63)-1. In SARL, you can use the `long` data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 2^(64)-1. Use this data type when you need a range of values wider than those provided by `int`. The `Long` class also contains methods like `compareUnsigned`, `divideUnsigned` etc to support arithmetic operations for unsigned long. | +| `float` | `java.lang.Float` | The `float` data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the SARL Language Specification. As with the recommendations for `byte` and `short`, use a `float` (instead of `double`) if you need to save memory in large arrays of floating point numbers. This data type should never be used for precise values, such as currency. For that, you will need to use the `java.math.BigDecimal` class Numbers and Strings covers `BigDecimal` and other useful classes provided by the SARL platform. | +| `double` | `java.lang.Double` | The `double` data type is a double-precision 64-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in the Floating-Point Types, Formats, and Values section of the SARL Language Specification. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as currency. | +| `boolean` | `java.lang.Boolean` | The `boolean` data type has only two possible values: `true` and `false`. Use this data type for simple flags that track `true`/`false` conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined. | +| `char` | `java.lang.Character` | The `char` data type is a single 16-bit Unicode character. It has a minimum value of `\u0000` (or 0) and a maximum value of `\uffff` (or 65,535 inclusive). | ## String of Characters diff --git a/tests/io.sarl.lang.core.tests/pom.xml b/tests/io.sarl.lang.core.tests/pom.xml index 3f78864742..afc8813321 100644 --- a/tests/io.sarl.lang.core.tests/pom.xml +++ b/tests/io.sarl.lang.core.tests/pom.xml @@ -19,11 +19,6 @@ io.sarl.tests.api test - - com.google.guava - guava-testlib - test -