184 karma · joined December 5, 2018
pros:
1- Everything is object. (no more inconsistencies like Java primitives, null and generics)
2- It has very well designed generics and you can access generic type in run time.
3- Good Type inference.
4- Has powerful facilities for asynchronous programming.(eg: async await, coroutines ,...)
5- Not overall bad or complex type system. Compare to Golang or java dart's type system is vastly superior.
some cons:
1- Everything can be null (null is also object).
2- Lack of Union and algebraic data types.
3- Lack of python's like tuple.(eg: (1,'string'))
4- I personally dislike C-style type definition and mandatory semicolon (eg: int foo=23; rather than foo : int=23 )
https://docs.python.org/3/library/typing.html#typing.TYPE_CH...
var a = 9;
function foo() {
console.log(a);
var a = 12;
}
foo();
$node foo.js
undefined
The same goes with ruby.Also comparing languages based on syntax and ecosystem is not very clever idea.
julia> a = 1
1
julia> function foo(x) x+ a end
foo (generic function with 1 method)
julia> foo(2)
3
julia> a = 2
2
julia> foo(2)
4