Friday, May 22, 2009

What's the purpose of types?

Do programmers always grok the purpose of types (nominal or structural)?

What if I didn't use the word 'type'?

What if I used the word 'pattern'? Or 'constraint'? Or 'rule'?

What if I used the word 'allocator'? Or 'constructor'? 

What does it mean to you?

7 comments:

Denis said...

In my opinion, the purpose of types is to help our brain to cope with abtract concepts. They are ergonomic tricks that help us (developpers) classify and manipulate the raw programming material. The closest they are to real-world objects (think OOP), the easiest the learning curve.

This implies that if you are building languages for machines (e.g. for CPUs, for VMs), types may be forgotten. No ?

Justin said...

Prior to exposure to Haskell I would have said much the same as Denis. Now I see types as not only providing safety (I am prevented from certain dangerous habits, like dereferencing a null pointer w/o REALLY wanting to), but also as able to describe data. For example, types can be used to describe the structure of a database table, and used to verify any queries against that table.

Your use of "pattern"/"constraint" and "rule" have that same meaning.

I have also seen types used to describe how resources are used (or when they are used). Your use of "allocator"/"constructor" connects with that meaning.

My understanding of "nominal" vs. "structural" is that types have name equality vs. "shape" equality. Again, after using Haskell, I find C#'s (pre 3.5) lack of "structural" typing really painful. Especially with anonymous delegates of IEnumerable, you really want tuples (i.e. anonymous types) and that means you want structural equality. The rest of the time, though, nominal typing seems to be much simpler.

Don Stewart said...

Types are proofs.

http://en.wikipedia.org/wiki/Curry-Howard_isomorphism

Pinky said...

The interesting thing about nominal is that values maintain a relationship to their type, and that you can build up relationships between nominal types (e.g., inheritance).

Pinky said...

The interesting thing about nominal is that values maintain a relationship to their type, and that you can build up relationships between nominal types (e.g., inheritance).

sesliyes said...

thanks for sharing perfect site ı am coming everday here
sesliserbest
sevgiadresi
seslidünya
thanks for sharing perfect site ı am coming everday here
sesli chat
sesliyes
seslimazi
konya chat
seslimazi
hollanda chat

peri oyunları said...

bu sitede porno izlerken 31 çekebilirsiniz, türk kızlarının webcam sex filmleride burada, dilerseniz grup sex filmleride burada. çıtır liseli porno videosu izleyin. en kral türbanlı porno izleme yeri ve hergün güncellenen porno arşivi bu sitede. erotik shop ve geciktirici siparişi.