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?

11 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).

FeNaaa said...

travesti
seslichat
seslisohbet
porno
sikiş izle
porno izle
porno
porno izle
porno izle
porno
sikiş izle
omegle
yabancı kızlarla chat
porno

Serdar ( BlackFeel said...

travesti
seslichat
seslisohbet
porno
sikiş izle
porno izle
porno
porno izle
porno izle
porno
sikiş izle
omegle
yabancı kızlarla chat

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.

alax said...

Earnlancer.com is a global outsourcing solution and

freelance jobs website. Here you can find freelance coders,

writers, programmers, designers, marketers and more.The

worlds largest outsourcing marketplace ,it is freelance jobs

website. We have thousands of freelance jobs online for

freelance programmers, web designers, graphic designers.

http://www.earnlancer.com

alax said...

Best Seo Site I Social Bookmarking Post I Sell Directory List I Directory Posting I Blog List I Blog posting I Forum posting I Sell Forum List I PR 01I PR 02 I Add your URL to Google I Add your URL to MSN I Add your URL to Yahoo I Backlinks posting I Keyword Marketing I Facebook wall post I Twitter wall post I Get Real Visitors I USA Visitors I Uk Visitors.http://www.shopseoservice.com