Skip to content

Instantly share code, notes, and snippets.

View henriquecarv's full-sized avatar

Henrique Carvalho da Cruz henriquecarv

View GitHub Profile
@onlurking
onlurking / programming-as-theory-building.md
Last active May 25, 2024 15:28
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

<body onload="d=m=document;n=Math.random;c=z.getContext`2d`;f=g=>c.fillStyle=g;r=(...y)=>c.fillRect(...y);L=_=>{clearInterval(m);v=i=X=m=s=0;h=71;P=[1,2,3].map(k=>({x:X+=150,y:n()*86}))};L();R=_=>{f`gold`;r(0,0,X,X);f`red`;for({x,y} of P){r(x,0,16,y);r(x,y+48,16,102-y)}r(0,h,8,8);c.fillText(s,0,8)};R();d.onclick=_=>{v=-5;m=m||setInterval('h=h*(h>0);h>=142&&L();h+=v+=0.5;for(p of P){p.x-=2;if(p.x<-31){p.x+=450;p.y=n(s++)*86}p.x<8&&(h<p.y||h>p.y+48)&&L()}R()',35)}"><canvas id=z>