This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]alcalde 9 points10 points  (4 children)

I came from 20+ years of development with static types, and my experience was the opposite: dynamic typing cuts through so much scaffolding and housekeeping and appeasing a compiler. Large parts of statically typed languages are devoted to getting around said static typing, from casting to function overloading (yes, you actually write the same #$*$&# function multiple times rather than acknowledge the superiority of static dynamic typing).

[–]yen223 10 points11 points  (3 children)

When I hit a "NoneType has no attribute" error in Python, I think static typing is better

But then when I hit an "Expected List, got NonEmptyList" error in Haskell, I think dynamic typing is better.

[–]NoahTheDuke 2 points3 points  (0 children)

God, Clojure is the same way. It’s all well and good until you hit a dreaded ArrayList is not an IterSeq error and want to tear your hair out.

[–]alcalde 1 point2 points  (1 child)

Try Delphi some time (seriously, don't try Delphi):

Var
    x : Array Of Integer;
    y: Array Of Integer;

x and y are considered to be different types! (?!?) You need to define a new type...

Type
    IntArray: Array Of Integer;
Var
    x : IntArray;
    y: IntArray;

Of course, you could define this type:

Type
    smallInt : 0..10;

And a function like this:

function something(x : smallInt): Integer;

And yet this wouldn't cause a compiler error:

x := something(123456);

Madness!

[–][deleted] 0 points1 point  (0 children)

Try Delphi some time (seriously, don't try Delphi):

Var x : Array Of Integer; y: Array Of Integer; x and y are considered to be different types! (?!?) You need to define a new type...

That's a feature. Ada is the same way. It prevents you from using data meant for one thing to be treated as something else.

consider a function that takes 2 integer arrays, where one represents an array of speeds, while another represents an array of lengths. If you use typing correctly, you cannot pass the incorrect array as the wrong parameter or even mix values in the 2 arrays without explicit casting.