Live data from Hacker News

A Primer on Type Systems

cs.uaf.edu

31–35 of 35 posts

Re: A Primer on Type Systems

#32
post #2

> There does not seem to be any equivalent of the notion of soundness in the world of dynamic typing. However, we can still talk about whether a dynamic type system strictly enforces type safety. My understanding is that there are well understood definitions of soundness for dynamically typed languages. The soundness theorem will generally be weaker ("your program will evaluate to a value or abort on a type confusion…

It actually is significantly "weaker". You make the wrong analogy when you say the dynamically typed case maps to a statically typed one with an exception (which presumably is a value in your language).

The correct analogy is to a segfault, meaning the program exited abnormally because it's inconsistent in an important way. It's the reason statically typed languages are faster than dynamically languages: expressions have a fixed meaning than enables optimisation guarantees you can depend on.

Re: A Primer on Type Systems

#33
post #18

Earlier quoted context omitted.

Snigl [0] has statically typed function signatures, struct fields, bindings etc; but values still carry their type. It also traces code before running it to eliminate as many type checks as possible. The categories aren't very helpful from my perspective, same goes for compiler vs. interpreter. All it leads to is endless arguing about definitions and discouraging of novel approaches. [0] https://gitlab.com/sifoo/snig…

I agree, and I don't think this is a bad trend, once upon a time I think static vs. dynamic was a clear distinction, that distinction is being worn down as we learn more about the value and costs of those approaches - and as that happens we're compromising the approaches to gain more of the value. In PHP the (mostly ) JIT interpretation exposed a weakness where infrequently executed pieces of code were harder to have…

> I agree, and I don't think this is a bad trend, once upon a time I think static vs. dynamic was a clear distinction

I think there's still a very clear distinction, but there's often value in having access to both in one language. The dynamic typing features can often make up for limitations of your type system, for instance.

Re: A Primer on Type Systems

#34
C++ templates are not typed structually. The compiler does not assign types to them at all. Rather they are treated as macros and the type assignment and checking happens during the expansion. For example, one can write a template that has no valid expansion, but as long as nobody uses it, the compiler accepts it.

In sense templates are similar to dynamic languages. Except in C++ it is the compiler, not runtime, that evaluates the templates.

Post reply on HN