Is julia strongly checked(typed)?

Is julia a strongly checked language, which means the type system prevent the untrapped error as more as possible?
For example, C/C++ do allow pointer arithmetic operations, so they are not.
If it is, what julia did to make it possible.

1 Like

No, Julia is a dynamic language.

1 Like

That’s largely unrelated. For comparison, Lisp is a strongly typed, dynamic language, while C is a more weakly typed static language.

Yes, Julia is a strongly typed language: it does not allow pointer arithmetic or type punning. (I’m too lazy to find a real reference, so I’ll just use Strong and weak typing - Wikipedia)

1 Like

Well,

Note that some of these definitions are contradictory, others are merely conceptually independent, and still others are special cases (with additional constraints) of other, more “liberal” (less strong) definitions. Because of the wide divergence among these definitions, it is possible to defend claims about most programming languages that they are either strongly or weakly typed.

But ok.

3 Likes

Educate me why this is not type punning

julia> f(x::Vector{Int}) = x
f (generic function with 1 method)

julia> v = rand(Int, 3, 1); # Matrix

julia> f(vec(v))
3-element Array{Int64,1}:
  4008100996524184079
 -3279737924264939174
  1302702468106043500

Ah, no need to put Julia in a Core.Box.

7 Likes

:+1:

Thanks.
But i don’t think they proved julia is strongly typed. In my limited knowledge, there are serval way to distinguish it

  • implicit type conversions allowed
  • pointer arithmetic
  • untagged unions(type punning?)
  • type of variable can be changed

If a language has above features, it should be weakly typed.

1 Like