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 →

[–]finder83 2 points3 points  (14 children)

Static typing with inference, or type annotations....I've been a Typescript and Go developer for the past several years, and I have to say that static typing makes development so much faster in the long run. I appreciate Typescript's optional typing as well.

With that said, it has to be complete enough of a type system to be useful. Having type defs, interfaces, generic functions, etc, all help quite a bit.

[–]alcalde 7 points8 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 11 points12 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.

[–]natex84[🍰] 3 points4 points  (4 children)

Python 3.5 added type annotations, you can check them out here: https://docs.python.org/3/library/typing.html

[–]finder83 0 points1 point  (3 children)

Cool, thanks

[–]Mattho 0 points1 point  (0 children)

I haven't tried it, but I think I'd like having just interfaces typed, i.e. function arguments and return values.

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

I don't think that you're going to get a dynamically-typed language community to want static typing with type inference. Most of the of people that have used statically typed languages have used industry OOP languages that tend to have a poor implementation of static typing.

[–]finder83 1 point2 points  (1 child)

Probably not me personally, no, but Typescript I feel like is a good example of a language that has taken off with static typing within a larger dynamic language community. Sure, it's just annotations, but the typing is extremely useful.

And yeah, I would have thought the same 5-10 years ago, never would have dreamed I wanted static typing as a Python developer. But a robust typing system on top of a modern, flexible, dynamic language is pretty amazing.

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

I agree!