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.

Follow

@wolf480pl @fool um, why wait when you can detect the error at compile time?

· · Web · 1 · 0 · 0

@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)

@wolf480pl @fool [OK, I may have been sloppy in usage there. In my defense I'm 3 shots of rum into a Sunday evening]

@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.

@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!