
What Is Gradual Typing? (2009) - xisukar
https://wphomes.soic.indiana.edu/jsiek/what-is-gradual-typing/
======
ameixaseca
> Bad point. Type checkers only check fairly simple properties of your
> program.

Bad bad point. There are statically-typed languages with fairly complex type
systems. There are even dependently typed languages which check essentially
_any_ property of you values and can be used to prove your program correct.

> Most of the work in making sure that your program is correct [...] goes into
> developing comprehensive tests.

Tests can only show the presence of bugs, never the absence of them. This is
not me speaking, this is Dijkstra.

It is ok to prefer one method over the other, but there's clearly an aura of
opinion on the statements of this article. It would be better for the reader
to explicitly differentiate fact from opinion there.

~~~
coldtea
> _Bad bad point. There are statically-typed languages with fairly complex
> type systems. There are even dependently typed languages which check
> essentially any property of you values and can be used to prove your program
> correct._

An introductory discussion such as this is better kept at languages / type
systems people actually use, not what might be possible, or whatever academic
or niche stuff is out there.

Dependent types are totally academic/enthusiast concern at this point, Haskell
is still very much niche, and only Rust might cut it as having a slightly more
complex type system and being actually used...

So, this would be like correcting a post about modern music for failing to
include "12-tone Nordic heavy metal-afrobeat ragas" that all 3 bands with 200
fans altogether listen to...

~~~
The_rationalist
There is an advanced type system that is becoming more and more mainstream,
it's Typescript. E.g: [https://www.typescriptlang.org/docs/handbook/advanced-
types....](https://www.typescriptlang.org/docs/handbook/advanced-types.html)
(conditional types for example)

Also c++20 with concepts will push the boundaries of what is possible.

But what I'm really looking for and doesn't exist except maybe through
libraries, is runtime Dependant types.

~~~
quazar
What would runtime dependent types be? As I understand, they are a tool for
statically proving properties of some code. What use are they at runtime? For
code that came up as a result of the working system? I believe properties of
generated programs can also be proven statically. For user-provided code? Why
not just run the compiler/interpreter on it?

------
beders
An important point of using dynamic types is not mentioned: The actual
workflow of coders: Compile, run, fail, repeat vs. eval, fail, repeat.

After over 35 years of coding - mostly with statically compiled languages
-doing it REPL-style makes such an enormous difference in my enjoyment of the
profession. I'm not sure I can go back to a compiler.

~~~
gumby
Interesting: I was first exposed to incremental development (in LOGO, Lisp and
Smalltalk) in the 70s and found static languages painful and alien into the
90s, but have mostly flipped my preference.

I had a friend who described incremental programing as "programming by
successive approximation". He wasn't praising it.

~~~
rictic
Depends on the problem you're solving. That's a terrible way to write a
filesystem, but a wonderful way to write a UI widget.

It's hard to reason from first principles how much padding should be between
items in a list, or how fast a spinner should spin.

------
6gvONxR4sf7o
I really hope that in the future gradual typing and dependent types can come
together into an ergonomic to use system where we can let the compiler
check/enforce proofs of correctness, but not require them. There's a ladder of
correctness (simple type checks, unit tests, integration tests, proofs of
different aspects of correctness) and each has a tradeoff vs effort. It would
be really great to be about to be able to move around it without rewriting
much code, but rather by adding more and more annotations as needed for your
use.

------
dang
A thread from 2014:
[https://news.ycombinator.com/item?id=8594079](https://news.ycombinator.com/item?id=8594079)

2009:
[https://news.ycombinator.com/item?id=556794](https://news.ycombinator.com/item?id=556794)

------
specialist
I have some noob questions that I don't know how to ask:

What, if any, is the relationship between type systems and pattern matching?

Does structural typing reduce the need for instanceof style tests?

So if a language uses structure typing, is pattern matching not useful,
applicable?

\--

Thanks for humoring me. I'm mostly a Java programmer, self taught, no CS
background. I've been reading wiki articles about type systems, trying to
figure out what it all means, how to get started. Inference, structural vs
nominal, linear types... But, honestly, my eyes glaze over pretty quickly.

Am planning on powering thru Appel's 2002 book, especially implementing the
type system, but we'll see how far I get.

~~~
aidenn0
Pattern matching can be used in typed and untyped languages.

One reason it's more strongly associated with typed languages is that the type
system can easily check a pattern match to prove various things about it (e.g.
that the set of pattern matches covers all possible inputs).

Note that there is no technical reason an if/then/else construct couldn't be
used instead, but the shape of the data is front and center with a pattern
match.

------
ekvintroj
This is an implementation of something similar on Smalltalk:
[https://www.youtube.com/watch?v=1b3RRE9a8NA](https://www.youtube.com/watch?v=1b3RRE9a8NA)

------
The_rationalist
If I understand correctly, most language supports gradual typing today
(typescript, c++, rust, etc) through "any"

