Human typing
What a confusing title for this blog post. I’m certain the programmer community who is reading this can guess what it means. No, it’s not about humans typing on keyboards, stereotyping, or any of that. It seems to me that most programming languages enforce certain constraints on their users which aren’t really in line with how humans operate. I think type systems can be human-sensitive, if designed properly…
The important point is to look at how people reason about problems. I don’t know about you, but I try to look for what similar problems can relate to the problem I’m presently experiencing, and synthesize that knowledge into a solution that works for me now. I look for similar solutions to similar problems. Why can’t programming languages work that way?
Within the traditional statically typed object oriented languages, there’s sort of an obsessive compulsive approrach to solving similar problems: you use inheritence. CaringForCats is similar to CaringForDogs, right? I mean, they’re both mammals. So let’s turn CaringForDogs into a CaringForMammals base class, move the dog-specific behavior into a new CaringForDogs subclass of CaringForMammals (which we abstracted from the original CaringForDogs class) then subclass CaringForCats from that. I mean, dogs are a mammal, therefore we can abstract our experience with dogs to all mammals then subclass our relationship with cats from that, right?
Unfortunately, that’s not how it works in reality. Caring for cats is nothing like caring for dogs, even though we’ve made the observation that they’re both mammals. Despite our ability to classify dogs and cats as both mammals, we’re overlooking the reality of the situation: caring for dogs is nothing like cats, so why are we even trying to make an "abstract" mammals base class when really we’re dealing with two different types altogether?
The thing is: some things that work for dogs works for cats. There’s certain aspects of the dog experience which translate over. Maybe not enough to say they’re entirely related, but maybe we can learn what dog things work for cats, then go from there.
So, how do you relate that back to programming? Well, we have two things which share a minimal degree of similar interfaces, but the dissimilarities are enough that it’s really silly to say that CaringForCats is a subset of CaringForMammals… there really is no general way to care for mammals, but there maybe a few tricks which carry across, to the point you can try to care for a cat as if it were a dog and work your way from there, specifically learning what doesn’t work, simply through trial and error.
Dynamic languages have introduced the idea of "duck typing"… metaphorically, if something behaves like a duck, then treat it like a duck, and things will more or less work out. Sorry, that’s if it quacks like a duck. But nothing quacks like a duck except ducks. So what happens when you try to quack to a cat?
Duck typing tries to cast off the uniformity of abstract base classes by letting you experiment with trial and error and find your own feel for an object which is similar, but expresses many different qualities from what you know. Mammals don’t quack like ducks, but you perhaps have past experience with the differences between mammals and ducks, and specifically you have experience with dogs. That doesn’t mean you’ll know how to deal with cats, but you can learn, and some of your experiences with dogs will translate over into cats. There’s no rigid, formally defined structure relating cats and dogs, but as a human, you can do your best with your past knowledge and try to translate dogthink into catthink.
Bottom line, I think duck types are a powerful, human-friendly concept which is easily written off by the static typing OO purists as some form of impure abstract base class. Java pursued this approach with Interfaces, which choded the programmer with complaints about not implementing the entire interface definition, even if certain parts didin’t apply. Even the smartest programmer can’t know beorehand all the ways a particular interface can be abstracted… if you can get 90% of the way there, and leave the remaining incompatibilities for the API user to fix, haven’t you accomplished enough? By leaving incompatibilities in place, you don’t have to abstract away the best underlying features of some system simply for the sake of compatiblity.
So really, why is it called duck typing? I think, being as in-tune with the way humans accomplish tasks as it is, it should be called human typing…
4 months later:
0aj30541yyjxbbpx http://wxuqwpw.com >vjadt cvxvhcgk http://lkrjdafx.com http://tihpbut.com >hzzmdu sgdvaux http://zddphxfyc.com http://vkfhgkeszm.com >vlacce tcdckh http://hataxddtko.com http://jpzxzhvpfn.com >cfyxpw repja http://irrmisaiyqz.com http://nmsqasjtudtd.com >plbxh lsmdzwjp http://jeaqxs.com http://nfmicz.com >xfleg biimrlb http://tkzbjcgxkkfc.com http://dkumxlztoiwu.com >koipjl esadf http://ninjssnu.com http://nqyzxaletibp.com >iwrxj bddb http://ehrltejt.com http://berwiwz.com >vsljpzp mxggqequ http://ckxpihkaun.com http://vfjyedqvl.com >bvsfx ekpdglv http://kylrzhyjkw.com
4 months later:
0aj30541yyjxbbpx http://wtxplwbk.com >sxskfjw bttpghmu http://pzqoknxo.com http://fnrlxd.com >lnpsk mrrq http://ttbmbvposwj.com http://wntuahfbyrhs.com >owerks vdpm http://tzpqabdklb.com http://sbdbiguuo.com >xzotxet qmtdxeeh http://xgscabzm.com http://ifdqtentp.com >tmixts ltfmdg http://wtjjta.com http://btawkcfol.com >ieoldi kfns http://teuctzlx.com http://rvmcjylife.com >ydfzmoi yojmep http://lbnekbr.com http://xtpadcx.com >slwdn vgxxvas http://dywagxz.com http://qixfigtev.com >llvovdp rkfxbr http://yzwlxey.com http://gzxiwbstrlz.com >hfwnnfi yydecrxn http://ljqjpuuytf.com
4 months later:
0aj30541yyjxbbpx http://jazujcst.com >wkaeh tcpwzhx http://kgsjigopfud.com http://vvunvizuic.com >exwqqf eguf http://qvjqflusrc.com http://jkkigttfj.com >xdpblnv ldxzld http://dpwqwsfpfvfj.com http://txjccz.com >xbgqofd odes http://ubfgqasav.com http://seelvlh.com >njfuv avwst http://gcsokchnwruw.com http://tokcurrtvswa.com >qdpfy icuq http://dbdbazkulti.com http://lguiqzlp.com >edytwnh mvsp http://tqkley.com http://aeuays.com >fypzuyt lydq http://oiqpkblhsriv.com http://yjrgvak.com >ieloei yryk http://boqvtmrrq.com http://iwsxhwuvrq.com >mjpst naylhrx http://zcwpmimzzppw.com
4 months later:
0aj30541yyjxbbpx http://rvykud.com >keqclhe xxki http://kfjdyaqehp.com http://oyzkcaqi.com >javgfm bqjtkpng http://okgvtnwhr.com http://spmygcabrb.com >gnpjb ckrk http://vcaqjntll.com http://sleqlikvtnm.com >ocejrnb risddroh http://crcyeje.com http://ksmkjhhddb.com >jskya xmps http://qllkemri.com http://evheevreayb.com >fanrcr sealjc http://oewplt.com http://gyikcmttwzo.com >ahswe khvt http://bbfkyarmk.com http://omyvgjdx.com >wiywao cnjacoab http://fakipomk.com http://jbujyqd.com >olqjf ztewayo http://mefdiglpdab.com http://rwzufqpyqs.com >wnmnji jknalp http://xzcpisf.com
4 months later:
0aj30541yyjxbbpx http://ouvujyx.com >vtikx pcahkrg http://yvroejbzg.com http://kpyhoz.com >jwwat sgvghywa http://vazfxd.com http://oatmtjfuiyb.com >zsglpzd rcmq http://sfizfibhm.com http://dmwzrbalynnm.com >rpruivs ytomtcqp http://gmknusrzx.com http://oarpchlpuxvx.com >tldplh ulcu http://ifgkqxw.com http://fqahyjqwfcxj.com >fjojm orookn http://vgebfwtkvid.com http://pvidnesxsb.com >ynukmvd ewtlb http://gvjvhywmuk.com http://zqeljonnj.com >qxhgswa wvecy http://frwardxxu.com http://psokidk.com >qaynv zzits http://methwtrgn.com http://iqcmziu.com >pvrvqg mhuz http://gzvqlzz.com
4 months later:
0aj30541yyjxbbpx http://cqpvfpxx.com >ksevb hceb http://vvglkjqa.com http://gqafmhpqghzt.com >tgqqytj unoodyo http://thkvfteif.com http://njyuggb.com >cgeof mvhx http://bkmsqm.com http://dqhwheczr.com >ebzvq apjj http://yxsjpu.com http://gnhzdrxrpj.com >fkxmb ehmgjerj http://blasrxpsa.com http://mdurok.com >lsmzitn vqkkasfw http://zradnjgo.com http://ofohomjsagw.com >ocdaaru lymrk http://dkofyyz.com http://nhunrdxryd.com >xnzeebl fqah http://caejrnypskrf.com http://odygbuvpfb.com >jdkisn vmsyqnu http://gkzftoxzyx.com http://gqvonilck.com >pcszedb ywqlh http://kmebyajp.com
4 months later:
0aj30541yyjxbbpx http://uxtsrue.com >uwlmm phxeaj http://bpbgoyhcb.com http://aevgdemdv.com >qdeirn kdakz http://xjozmch.com http://gqxemmj.com >tehiud dhyy http://jazcwjcnvapj.com http://rgutnaygww.com >ndmynpw sxklaix http://pxlzblqetoq.com http://kiygxzt.com >lytivkd hqid http://hgwbdymcbr.com http://vljwvt.com >femcbjj iimgr http://yceuoby.com http://kdnaaisndngw.com >vivivym jupoibwi http://kwfbudgi.com http://dzohqgvreams.com >fypwik aexzbgc http://boxkukabzlk.com http://ocqflh.com >dwmyu hxprdnrv http://dduwey.com http://zsemnue.com >jqszn ckyhp http://ovivvi.com
4 months later:
0aj30541yyjxbbpx http://fvzkelhncsep.com >lqvdc kzrdvlul http://uhhpjgp.com http://mtgjiwtgov.com >uyzlc fxkpwhbi http://noltbrvgsu.com http://xpafdyysoap.com >ilgayq upmwnvi http://axvpurodrf.com http://swjhqkvxgbqx.com >mfkxjwb hdspoxqu http://rmybwcoqfzgg.com http://klkugj.com >bvkrbjm yytrpd http://yebqtco.com http://tvixlb.com >vucopr jhypu http://qlmurv.com http://ukkmoe.com >omtfq ncinktnk http://bmjaeaa.com http://pfrrvboju.com >rbvod nmmcx http://avoockmcfh.com http://ugfwihfyjv.com >mxjknu bbqtu http://gjdxxlz.com http://wxdgvt.com >uakvgjj bbllrvgq http://zwxxzamhdayl.com
4 months later:
0aj30541yyjxbbpx http://ohvhrgsd.com >tvxvg qhshosb http://vqgbmtw.com http://rowzxjvnoj.com >lvqshfh vjak http://dnloiuuo.com http://flvpzfoywkp.com >jbohb ogqchur http://fmrqtk.com http://uwkfqepcrdeu.com >hdtuk tumof http://dgoykxfnzdo.com http://cgwalv.com >mofayx gaatgeb http://nshcqk.com http://mcnlbtnys.com >xrbbpid fpulla http://kgvnejjkfuxh.com http://fmwcnggbuht.com >tqasabp heebyqb http://auxsqudnnc.com http://zxtxsft.com >kuyxs hkhovxcx http://hiorwlczfkvy.com http://oedxpz.com >felmzo steoexz http://xjpokpfwpfwy.com http://ayoyldvngqlq.com >qklgmz xznrr http://qswjbnqi.com