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 @wolf480pl lots of statically typed languages have type inference

@fool @wolf480pl ocaml is the only one I have experience with that has type inference and strict typing

@RandomDamage @fool
The reason OCaml is still a statically typed language is that it can give you errors at compile time.

A language with strong dynamic typing would instead throw an exception at runtime when you pass a wrong type.

@RandomDamage @fool
In static typing you can detect a type error at compile time.

This is true for OCaml, C, Java, etc.

@wolf480pl @fool right, but with ocaml it checks for type errors even when you have a generic method.

It checks *at compile time* whether a call to a class is type consistent.

Without declaring any of the classes involved in any of the variables.

Because it can (as could any other dynamically typed language that cared to)

@RandomDamage @fool
Yes, it doesn't need the type declarations to check types.

What I've been saying is, if the inferred type is what you want, you don't need the type declaration, but you may still want it as a form of documentation.

It checks them because it can, and because it was designed so that it can.
Not every language could, if it cared to.


@wolf480pl @fool true, but most of the languages that can check require the declaration to check.

OCaml is something of a unicorn in my experience, since it will check at compile time without any declarations anywhere.

· · Web · 1 · 0 · 1

@RandomDamage @fool
Haskell, Zig, and Rust AFAIK don't need type declarations most of the time either.
Also, the modern so called "C++" has grown an `auto` keyword which in many cases can be used for type inference as well...

Scala and Kotlin have type inference to some extent as well, from what I've read.

But yeah, for me too OCaml was the first language where I saw type inference at work.

@wolf480pl @fool I didn't find Scala's type inference as robust as OCaml's, but that's the only one of that set that I have much experience with

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!