Uploaded by zamanarooba

Languages Comparison

advertisement
Python
C Based
Java/JS
Ada
Lisp
Fortran
Haskell
Ruby
Operator Precedence Order in Arithmetic Expressions
1. [] ( ) . ->
++ -- (postfix)
1. [] ( ) . ->
++ -- (postfix)
1. [] ( ) . ->
++ -- (postfix)
2. sizeof & * +
2. sizeof & * + - ~! 2. sizeof & * + - ~! ++ -++ -- (prefix) Unary ~! ++ -- (prefix)
(prefix) Unary
Unary
3. * / %
3. * / %
3. * / %
4. + 4. + 4. + 5. << >> Bitwise
5.
<<
>>
Shift
5.<<>>
Bitwise Shift
Bitwise Shift
Haskell's nonLisp doesn't
strict and lazy
have fixed
evaluation
operator
strategies
precedence as 2. sizeof & * + ~! ++ -- (prefix) distinguish it
seen in
from languages
languages like Unary
with strict
C or Java.
evaluation and
3. * / %
Instead, the
fixed left-to-right
order of
evaluation order.
4. + evaluation is
Haskell evaluates
determined by
expressions
the explicit use 5.<<>>
based on need
Bitwise Shift
of
and computation
parentheses.
requirements.
1. [] ( ) . ->
++ -- (postfix)
1. **, abs,
not
2. *, /,
mod, rem
3. +, (unary)
4. +, -, &
(binary)
1. [] ( ) . ->
++ -(postfix)
2. sizeof & *
+ - ~! ++ -(prefix)
Unary
3. * / %
4. + 5.<<>>
Bitwise Shift
Operator Precedence order in Relational Expressions
6. < > <= >=
6. < > <= >=
6. < > <= >=
5. < > <= >=
7. == !=
7. == !=
7. == !=
6. == !=
determined
by the explicit
use of
parentheses.
6. < > <= >=
7. == !=
based on need
and computation
requirements.
6. < > <= >=
7. == !=
Operator Precedence order in Boolean Expressions
8. & Bitwise
AND
9. ^ Bitwise
XOR
8. & BitwiseAND
9. ^ Bitwiseexclusive-OR
10.| Bitwise OR 10.| Bitwiseinclusive-OR
11. not x
12. and
11. &&
Boolean AND
Logical-AND
13. or Boolean
OR
12.|| LogicalOR
8. Bitwise NOT
(BNOT)
8. ==
9. !=equality
10. & bitwise
AND
11. ^ bitwise
XOR
12. | bitwise
OR
13. && logical
AND
14. || logical
OR
9. Logical NOT
(NOT)
8. not
9. Bitwise-& ,
|
10. &&
Logical-AND
11.|| LogicalOR
The order of
evaluation is
determined
by the
structure of
the
expressions
10. Bitwise
AND (IAND)
11. Bitwise OR
(IOR)
12. Logical
AND (AND)
8. Bitwise NOT
(BNOT)
Haskell
doesn't have
traditional
boolean
operators like
and and or;
instead, it
uses
functions like
&& and ||.
13. Logical OR
(OR)
9. Logical NOT
(NOT)
10. Bitwise AND
(IAND)
11. Bitwise OR
(IOR)
12. Logical AND
(AND)
13. Logical OR
(OR)
Operator Precedence Order of Simple and Compound Assignment
14. = *= /= %=
+= = <<= >>= &=
^= |=
13. = *= /= %=
+= = <<= >>= &=
^= |=
15. = *= /= %=
+= = <<= >>= &=
^= |=
12. = *= /= %=
+= = <<= >>= &=
^= |=
The order of
evaluation is
determined
by the
structure of
the
expressions
12. = *= /= %=
+= = <<= >>= &=
^= |=
Haskell
doesn't have
traditional
boolean
operators like
and and or;
instead, it
uses
14. = *= /= %=
+= = <<= >>= &=
^= |=
functions like
&& and ||.
Associativity
Associativity:
Left to right for
most
operators.
Notable
exceptions:
Exponentiation
(**) is rightassociative.
Associativity:
Left to right
for most
operators.
Notable
exceptions:
Assignment
operators (=,
+=, -=) are
rightassociative.
Associativity:
Associativity:
Various. Ada
Left to right for
allows
most
specifying the
operators.
associativity of
Notable
user-defined
exceptions:
operators.
Assignment
Default
operators (=,
associativity:
+=, -=) are
Left to right for
rightmost
associative.
operators.
Generally,
not
applicable in
Lisp because
it uses prefix
notation and
parentheses
determine
the order of
evaluation
Associativity:
Left to right
for most
operators.
Notable
exceptions:
Assignment
operators (=)
are rightassociative.
Not applicable
in Haskell due
to its
functional
nature and
lack of side
effects. The
order of
evaluation is
determined by
data
dependencies
rather than
operator
associativity.
Associativity:
Left to right for
most operators.
Notable
exceptions:
Exponentiation
(**) is rightassociative.
Assignment
operators (=)
are rightassociative
Operands Evaluation Order
Left to right
Left to right
Left to right
Left to right
Left to right
Left to right
operands are
not strictly
evaluated
until their
values are
needed
Left to right
Short Circuit Evaluation
Operators:
and, or
Operators:
&& and ||
Operators: &&
and ||
Operators:
‘and then’ and
‘or else’
Operators:
and, or
Operators:
‘.and.’ , ‘.or.’
Operators:
&& and ||
Operators:
&& and ||
Operator Overloading
+
+
(Addition and
(Addition and
String
Concatenation)
Concatenation
through
*
functions)
(Multiplication
and
*
Repetition)
(Multiplication
and Pointer
/
Dereference)
(Division and
True Division)
/
(Division and
%
Integer
(Modulo and
Division)
String
Formatting)
%
(Modulo and
+=
Format
+
(Addition and +
(Custom
String
+
behavior
(Addition and Concatenation)
based on
String
function
Concatenation) &
(Concatenation definition)
+=
(In-Place
Addition)
for Strings)
&=
(In-Place
Concatenation
for Strings)
+
(Addition for
+
Numbers and
(Addition and
Concatenation
String
Concatenation) for Lists)
*
*
(Multiplication
(Multiplication and Matrix
and Custom
Multiplication)
behavior)
*
(Multiplication
for Numbers
and
Replication for
Lists)
+
(Addition for
Numbers and
Concatenation
for Strings and
Arrays)
*
(Multiplication
and
Repetition for
Strings and
Arrays
(In-Place
Addition and
In-Place
Concatenation)
Specifier in
printf)
+= (In-Place
Addition)
Explicit Type Casting
int(), float(),
str(), etc.
(int), (float),
etc.
Ada allows
explicit type
conversions
(int), (double),
using
etc.
predefined
attributes and
functions.
float, int, etc.
real(), int(),
etc.
fromIntegral,
toInteger, etc.
to_i, to_f,
to_s, etc.
Download