static typing is better but I'm not gonna tell anyone they're wrong for choosing dynamic typing. if they appreciated being told when they're making a mistake they wouldn't be using a dynamically typed language in the first place

@fool The only possible exception I've seen is ocaml, but it uses strict dynamic typing unlike every other language I've seen.

@wolf480pl @fool you don't declare the type, it detects it.

So you can declare a method to take a generic type and it will type check it against each call to that method.

@RandomDamage @fool
Yes, this is static typing with type inference and generics.

Also, while I don't have to specify types in OCaml (and Haskell and the like) I usually do it as a form of documentation.

@wolf480pl @fool sometimes (a lot of times in my experience) you want a method that acts against a lot of different types consistently, *and* you want type checking as part of that

@RandomDamage @fool
Yes, hence generics.
And if I want it generic I do specify type a type parameter.

eg, if I want it to be generic:

first : 'a list -> 'a

vs if I don't want it:

first: int list -> int


@RandomDamage @fool
(I forgot `val` before each line, shows that it was a long time since I last used OCaml)

· · Web · 0 · 0 · 0
Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!