Comparison of Programming Languages
(also testing out using a "?" in cells that haven't been completed or are otherwise unknown) |
(changed all the unfilled fields to question marks) |
||
Line 65: | Line 65: | ||
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Type_system#Compatibility:_equivalence_and_subtyping Compatibility Among Composite Types] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Type_system#Compatibility:_equivalence_and_subtyping Compatibility Among Composite Types] | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} name-based | | {{wikitable-td}} name-based | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Type_system#Type_checking Type Checking] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Type_system#Type_checking Type Checking] | ||
Line 91: | Line 91: | ||
|- | |- | ||
! {{wikitable-th}} 8 bit ([http://en.wikipedia.org/wiki/Byte byte]) Signed | ! {{wikitable-th}} 8 bit ([http://en.wikipedia.org/wiki/Byte byte]) Signed | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} sbyte | | {{wikitable-td}} sbyte | ||
| {{wikitable-td}} sbyte | | {{wikitable-td}} sbyte | ||
Line 106: | Line 106: | ||
|- | |- | ||
! {{wikitable-th}} 16 bit ([http://en.wikipedia.org/wiki/Short_integer short integer]) Unsigned | ! {{wikitable-th}} 16 bit ([http://en.wikipedia.org/wiki/Short_integer short integer]) Unsigned | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} ushort | | {{wikitable-td}} ushort | ||
| {{wikitable-td}} ushort | | {{wikitable-td}} ushort | ||
Line 116: | Line 116: | ||
|- | |- | ||
! {{wikitable-th}} 32 bit Unsigned | ! {{wikitable-th}} 32 bit Unsigned | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} uint | | {{wikitable-td}} uint | ||
| {{wikitable-td}} uint | | {{wikitable-td}} uint | ||
Line 126: | Line 126: | ||
|- | |- | ||
! {{wikitable-th}} 64 bit [http://en.wikipedia.org/wiki/Long_integer long integer]) Unsigned | ! {{wikitable-th}} 64 bit [http://en.wikipedia.org/wiki/Long_integer long integer]) Unsigned | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} ulong | | {{wikitable-td}} ulong | ||
| {{wikitable-td}} ulong | | {{wikitable-td}} ulong | ||
Line 152: | Line 152: | ||
! {{wikitable-th}} Arbitrarily Precise ([http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic bignum]) | ! {{wikitable-th}} Arbitrarily Precise ([http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic bignum]) | ||
| {{wikitable-td}} decimal | | {{wikitable-td}} decimal | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 206: | Line 206: | ||
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Array#Multi-dimensional_array multi-dimensional] fixed size array | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Array#Multi-dimensional_array multi-dimensional] fixed size array | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} type[size<sub>1</sub>, size<sub>2</sub>,...] | | {{wikitable-td}} type[size<sub>1</sub>, size<sub>2</sub>,...] | ||
| {{wikitable-td}} type[size<sub>1</sub>, size<sub>2</sub>,...]<br/>(note: currently these types of arrays can be created implicitly and used, but cannot be created explicitly) | | {{wikitable-td}} type[size<sub>1</sub>, size<sub>2</sub>,...]<br/>(note: currently these types of arrays can be created implicitly and used, but cannot be created explicitly) | ||
Line 216: | Line 216: | ||
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Array#Multi-dimensional_array multi-dimensional] dynamic size array | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Array#Multi-dimensional_array multi-dimensional] dynamic size array | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 232: | Line 232: | ||
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Record_(computer_science) Record] Simple Composite Types | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Record_(computer_science) Record] Simple Composite Types | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} struct name {type name;...} | | {{wikitable-td}} struct name {type name;...} | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Enumerated_type Enumeration] Simple Composite Types | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Enumerated_type Enumeration] Simple Composite Types | ||
Line 242: | Line 242: | ||
{{keypress|tab}} «item<sub>2</sub><br/> | {{keypress|tab}} «item<sub>2</sub><br/> | ||
{{keypress|tab}} …»<br/> | {{keypress|tab}} …»<br/> | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 256: | Line 256: | ||
|- | |- | ||
! {{wikitable-th}} array | ! {{wikitable-th}} array | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
| {{wikitable-td}} Array | | {{wikitable-td}} Array | ||
|} | |} | ||
Line 284: | Line 284: | ||
| {{wikitable-td}} synonym = typeof(type) | | {{wikitable-td}} synonym = typeof(type) | ||
| {{wikitable-td}} using synonym = type; | | {{wikitable-td}} using synonym = type; | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 320: | Line 320: | ||
«default: instructions; «jump statement;»» | «default: instructions; «jump statement;»» | ||
}</csharp> | }</csharp> | ||
− | | {{wikitable-?}} | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Conditional_(programming)#If_expressions conditional expression] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Conditional_(programming)#If_expressions conditional expression] | ||
Line 339: | Line 339: | ||
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/While_loop while] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/While_loop while] | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Do_while_loop do while] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Do_while_loop do while] | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/For_loop for i = first to last] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/For_loop for i = first to last] | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Foreach foreach] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Foreach foreach] | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 370: | Line 370: | ||
|- | |- | ||
! {{wikitable-th}} throw | ! {{wikitable-th}} throw | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} handler | ! {{wikitable-th}} handler | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} assertion | ! {{wikitable-th}} assertion | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 396: | Line 396: | ||
|- | |- | ||
! {{wikitable-th}} exit block(break) | ! {{wikitable-th}} exit block(break) | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} continue | ! {{wikitable-th}} continue | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} [http://en.wikipedia.org/wiki/Label_(programming_language) label] | ! {{wikitable-th}} [http://en.wikipedia.org/wiki/Label_(programming_language) label] | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} branch ([http://en.wikipedia.org/wiki/Goto goto]) | ! {{wikitable-th}} branch ([http://en.wikipedia.org/wiki/Goto goto]) | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} return value from generator | ! {{wikitable-th}} return value from generator | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 432: | Line 432: | ||
|- | |- | ||
! {{wikitable-th}} calling a function | ! {{wikitable-th}} calling a function | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} basic/void function | ! {{wikitable-th}} basic/void function | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} value-returning function | ! {{wikitable-th}} value-returning function | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Line 458: | Line 458: | ||
|- | |- | ||
! {{wikitable-th}} basic type to basic type | ! {{wikitable-th}} basic type to basic type | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} string to basic type | ! {{wikitable-th}} string to basic type | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} basic type to string | ! {{wikitable-th}} basic type to string | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} complex type to string | ! {{wikitable-th}} complex type to string | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|- | |- | ||
! {{wikitable-th}} complex type to complex type | ! {{wikitable-th}} complex type to complex type | ||
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
− | | {{wikitable- | + | | {{wikitable-?}} |
|} | |} | ||
Revision as of 05:07, 19 August 2009
This is a comparison of the features and instructions of the three high-level programming languages offered by Unity: JavaScript, C#, and Boo.
Contents |
Conventions of This Article
The bold is the literal code. The non-bold is interpreted by the reader. Statements in guillemets (« … ») are optional. tab indicates a necessary indent.
The following tables compare code differences of the Unity programming languages. See also the Comparison of Programming Languages for general information.
Features
The following tables compares major features of the Unity programming languages.
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
Paradigm(s) | |||
Standardized Variation? | Yes | Yes, ECMA, ISO ECMA-334; ISO/IEC 23270:2006 | No |
Type Strength | strong | strong | strong1 |
Type Safety | safe | safe | safe |
Expression of Types | implicit with optional explicit typing | explicit | implicit with optional explicit typing |
Compatibility Among Composite Types | ? | name-based | ? |
Type Checking | static with optional dynamic typing | static with optional dynamic typing | static with optional dynamic typing |
1 Normally Javascript in Unity uses type inference to statically type all variables when possible, in cases where the type is not explicitly stated. Dynamic typing can be forced if desired, and, in certain circumstances, dynamic typing is used unless forced otherwise. Use of the "#pragma strict" directive disables all dynamic typing.
Type Identifiers
Integer
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
8 bit (byte) Signed | ? | sbyte | sbyte |
8 bit (byte) Unsigned | byte | byte | byte |
16 bit (short integer) Signed | short | short | short |
16 bit (short integer) Unsigned | ? | ushort | ushort |
32 bit Signed | int | int | int |
32 bit Unsigned | ? | uint | uint |
64 bit (long integer) Signed | long | long | long |
64 bit long integer) Unsigned | ? | ulong | ulong |
Floating Point
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
Single Precision | single | float | float |
Double Precision | double | double | double |
Arbitrarily Precise (bignum) | decimal | ? | ? |
Other Types
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
Text Character | N/A | char | char |
Text String | string | string | String |
Boolean) | bool | bool | boolean |
Object/Universal) | object | object | Object |
Derived Types
Array
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
one-dimensional fixed size array | (type) | type[size] | type[size] |
multi-dimensional fixed size array | ? | type[size1, size2,...] | type[size1, size2,...] (note: currently these types of arrays can be created implicitly and used, but cannot be created explicitly) |
one-dimensional dynamic size array | List | System.Collections.ArrayList or System.Collections.Generic.List<type> |
Array or System.Collections.ArrayList |
multi-dimensional dynamic size array | ? | ? | ? |
Other Types
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
Record Simple Composite Types | ? | struct name {type name;...} | ? |
Enumeration Simple Composite Types |
enum condition: |
? | ? |
Basic Unity-Specific Types
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
array | ? | ? | Array |
Declarations
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
variable | name = initial_value | type name «= initial_value»; | var name «= initial_value»; |
constant | final name = initial_value | const type name = value; | const name = value; |
type synonym | synonym = typeof(type) | using synonym = type; | ? |
Flow of Control
Conditional Statements
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
if | ? | <csharp>if (condition) {instructions}
«else {instructions}»</csharp> |
? |
else if | ? | <csharp>if (condition) { instructions }
else if (condition) { instructions } … «else { instructions }»</csharp> |
? |
select case | ? | <csharp>switch (variable) {
case case1: instructions; «jump statement;» … «default: instructions; «jump statement;»» }</csharp> |
? |
conditional expression | N/A | condition ? valueIfTrue : valueIfFalse | ? |
Loop Statements
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
while | ? | ? | ? |
do while | ? | ? | ? |
for i = first to last | ? | ? | ? |
foreach | ? | ? | ? |
Exceptions
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
throw | ? | ? | ? |
handler | ? | ? | ? |
assertion | ? | ? | ? |
Other Flow of Control Statements
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
exit block(break) | ? | ? | ? |
continue | ? | ? | ? |
label | ? | ? | ? |
branch (goto) | ? | ? | ? |
return value from generator | ? | ? | ? |
Functions
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
calling a function | ? | ? | ? |
basic/void function | ? | ? | ? |
value-returning function | ? | ? | ? |
Type Conversions
Language | Boo | C# | UnityScript/JavaScript |
---|---|---|---|
basic type to basic type | ? | ? | ? |
string to basic type | ? | ? | ? |
basic type to string | ? | ? | ? |
complex type to string | ? | ? | ? |
complex type to complex type | ? | ? | ? |