
Type Systems (2004) [pdf] - tosh
http://lucacardelli.name/Papers/TypeSystems.pdf
======
lisper
> Languages where variables can be given (nontrivial) types are called typed
> languages.

This is a vacuous definition because it doesn't specify what is meant by
"variable" or what it means to be "given a type." This is not nit-picking. It
actually matters in the case of Common Lisp. Consider:

(let ((x 1)) (declare (fixnum x)) ...)

X is clearly a variable, but has it been "given a type"? In CL, type
specifications are _promises to the compiler_ , not specifications of program
semantics. (declare (fixnum x)) means "I, the programmer, promise to write my
code in such a way that the value of X will always be a fixnum, and you the
compiler are free to assume that I will do this correctly in order to make my
code run faster."

On the other hand:

(setf x (make-array 10 :element-type 'fixnum))

In this case the implementation is allowed (though not required) to make an
array that can _only_ hold fixnums. So are the array elements variables? And
have they been "given a type"?

~~~
adrianratnapala
I think we can forgive such stuff at least in the intro. This document is
clearly an introduction to type systems for people who know more about
programming than they do about the underlying maths and logic of type theory.
Good.

Also good is that it starts from what the reader knows informally rather than
trying to build everything rigorously from the ground up.

~~~
catnaroek
> Also good is that it starts from what the reader knows informally rather
> than trying to build everything rigorously from the ground up.

It's certainly pragmatic, but is it good? Maybe I'm biased as a math student,
but I've seen first-hand the horrors that happen when people think they know
something just because they have a vague intuition about the topic's main
ideas.

~~~
adrianratnapala
But whenever I have learned maths in strict lemma-proof form it was on the
second time around. That is, I first had a general sense of the field and
intuition about concepts and some of the results, and then rigorous stuff
makes sense.

From everything I've read about how mathematicians work, I thought that was
normal.

------
equalunique
Is the notation used here standard in type systems research? I'm pretty much
lost before halfway in at the _with_ concept.

------
kruhft
Is Mathematics, as a language, considered typed in general?

~~~
adamnemecek
Most mathematics isn't constructive
([https://en.m.wikipedia.org/wiki/Constructivism_(mathematics)](https://en.m.wikipedia.org/wiki/Constructivism_\(mathematics\)))
so it doesn't really come up I think. E.g. you know how matrices need to have
a certain shape to be multiplied? People don't really talk about what happens
if they don't.

Physics on the other hand very much has types, the unit to type correspondence
is dopetastic.

~~~
AnimalMuppet
ELI5: Why would constructive math be more typed than non-constructive math?

~~~
adamnemecek
Constructive mathematics is based on intuitionistic logic (i.e. classical
logic without law of the excluded middle, meaning you don't have proof by
contradiction, to demonstrate the existence of something you have to
"construct" it). Intuitionistic logic is very close to type theory.

~~~
AnimalMuppet
OK, ELI10: _Why or how_ is intuitionistic logic very close to type theory? Is
it _based on_ type theory? Or is it just _similar_? In either case, how and
why?

~~~
rraval
See [https://codewords.recurse.com/issues/one/type-systems-and-
lo...](https://codewords.recurse.com/issues/one/type-systems-and-logic) for a
pretty elaborate response to this question.

tl;dr: types are propositions and values are proofs of those propositions.
Constructive logic is not concerned with (true xor false), but rather "I can
prove A" or "I can prove not-A". There's also the middle ground of "I don't
know how to prove anything about A".

------
dangerousfood
Why are these academic white papers always in the exact same format? Is there
a formatting guide somewhere I don't know about?

------
erokar
Admittedly, I skimmed through this, but I miss a balanced discussion of the
cost/benefits of static typing. I could see no discussion of the benefits of
dynamically typed languges. Insted arguments for static typing are enumerated
without a single reference.

For a more balanced discussion, see:
[https://www.infoq.com/presentations/dynamic-static-
typing](https://www.infoq.com/presentations/dynamic-static-typing)

~~~
ericssmith
You should try skimming to the end, where there are two pages of references.
Not to mention the fact that Cardelli is a prominent figure in the study of
programming languages.

And I think you'll find that Gilad Bracha is a more informed critic of
reliance on static type checking.

~~~
pjmlp
Yep, he was one of the designers in the Modula-2+ and Modula-3 languages.

