Вы находитесь на странице: 1из 9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

135

More NextBlog

sairaju53@gmail.com Dashboard SignOut

Stevey'sBlogRants
R A NDO M W H I NI NG A ND S T U FF.

Thursday,June21,2007

AboutMe
STE VE YE G G E

RichProgrammerFood

KI RKL AN D ,
W ASH I N G TON ,
U N I TE D STATE S
V I EW MY CO MP LET E

TheOliveGarden:it'swherepoorpeoplegotoeatrichpeoplefood.

P R O FI LE

DaveYegge

ThisisanotheroneofthoseblogtopicsI'vebeensittingonforwaytoolong,tryingto

PreviousPosts

findapolitewayofsayingsomethingfundamentallyimpolite.Idon'tseeawaytodoit.

ThatOldMarshmallowMazeSpell

So:youstandagoodchanceofbeingoffendedbythisblogentry.(Hey,justdon'tsayI

ANoogler'sViewofGoogle

didn'twarnya.)

TheNextBigLanguage

I'veturnedoffblogcomments,incidentally,becausecleverevilpeoplehavefiguredout
howtobeatcaptchasusingnonalgorithmicapproaches,andIdon'thavethebandwidth
topolicespammyself.Sorry.

Mysaveexcursion
ThePinocchioProblem
Parabola
Itakeitallback!Sendmeyourmoney!

Idon'twanttogiveyouaheartattack,soI'mgoingtogiveyouthegentleyetinsistent

EgomaniaItself

executivesummaryrightupfront.Ifyoucanmakeitthroughmyexecutivesummary

GoodAgile,BadAgile

withoutasignificantincreaseinheartrate,thenyou'reprobablyOK.Otherwise,you

Blogger'sBlock#4:RubyandJava
andStuff

mightconsiderdrinkingheavilybeforereadingthis,justlikepeopledidintheoldmovies
whentheyneededtheirlegsawedoff.That'swhatI'mdoing,inanycase(drinking,that
is,notsawingmylegoff).
Gentle,yetinsistentexecutivesummary:Ifyoudon'tknowhowcompilerswork,then
youdon'tknowhowcomputerswork.Ifyou'renot100%surewhetheryouknowhow
compilerswork,thenyoudon'tknowhowtheywork.
Youhavetoknowyouknow,youknow.
Infact,CompilerConstructionis,inmyownhumbleandprobablyembarrassinglywrong
opinion,thesecondmostimportantCSclassyoucantakeinanundergraduatecomputer
scienceprogram.
BecauseeverydeepdiveI'veattemptedonthistopicoverthepastyearorsohasfailed
utterlyatconvincingmeafterIsoberedup,I'mgoingtostagethisproductionasa,erm,
stageproduction,withNglorious,er,parts,separatedbyintermissions.Sowithout
furtherado...
Actually,thatsoundslikewaytoomuchwork.SoI'lljustrant.That'swhatyoupaidgood
moneytohearanyway,right?IpromisetomakesomuchfunofotherpeoplethatwhenI
makefunofyou,you'llhardlynotice.
CotsandBeards
Itookcompilersinschool.Yup.Suredid.FromProfessorDavidNotkinattheUniversity
ofWashington,circalate1991orthereabouts.
GuesswhatgradeIgot?Igotazero.Asin,0.0.Thatwasmyfinalgrade,onmy
transcript.That'swhathappensattheUniversityofWashingtonwhenyougetan
Incompleteanddon'ttakethenecessarycorrectiveactions(whichI'veneverfiguredout,
bytheway.)Aftersometimeelapses,itturnsintoazero.
YoucangetanIncompleteinvariousdifferentlegitimateways,includingmyway,which
wastobeanillconsideredbeefwittedmooncalfwhotakesthecoursepastthedropdate
andthendecidesnottofinishitbecausehedoesn'tfeellikeit.IearnedthatIncomplete,I
tellyou.

http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

1/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

ItookCompilersagainafewyearslater.Iwasincollegeforalongtime,becauseIgot
hiredonasafulltimeemployeebyGeoworksaboutayearbeforeIgraduated(among
otherreasons),anditwoundupextendingmygraduationforseveralyears.
Don'tdothat,bytheway.It'sreallyhardtofinishwhenyou'reworkingfulltime.Get
yourdegree,thengotowork.Allthemoresoifyou'reaPh.D.candidatewithinanyreach
offinishing.Youdon'twanttobejustanotherABDfortherestofyourlife.Evenifyou're
notsad,perse,we'llbesadforyou.
IgotadecentgradeinCompilersthesecondtimearound.Iactuallyunderstoodcompilers
atareasonablysuperficiallevelthefirsttime,andnottoobadlythesecondtime.WhatI
failedtograspformanymoreyears,andI'mtellingyouthistosaveyouthatpain,iswhy
compilersactuallymatterinthefirstplace.
Here'swhatIthoughtwhenItookitbackin1991.Seeifitsoundsfamiliar.Ithought:a
compilerisatoolthattakesmyprogram,afterwhiningaboutitalot,andturnsitinto
computerspeak.Ifyouwanttowriteprograms,thenacompilerisjustoneofthose
thingsyouneed.Youneedacomputer,akeyboard,anaccountmaybe,acompiler,an
editor,optionallyadebugger,andyou'regoodtogo.YouknowhowtoProgram.You'rea
Programmer.NowyoujustneedtolearnAPIsandstuff.
WheneverIgaveevenamoment'sthoughttowhetherIneededtolearncompilers,I'd
think:Iwouldneedtoknowhowcompilersworkinoneoftwoscenarios.Thefirst
scenarioisthatIgoworkatMicrosoftandsomehowwindupintheVisualC++group.
ThenI'dneedtoknowhowcompilerswork.Thesecondscenarioisthattheurge
suddenlycomesuponmetogrowalongbeardandstopshoweringandmakea
pilgrimagetoMITwhereIbegRichardStallmantoletmeliveinacotinsomehallway
andworkonGCCwithhimlikesomesortofJesuitvagabond.
Bothscenariosseemedprettyunlikelytomeatthetime,althoughifpushcametoshove,a
cotandbearddidn'tseemallthatbadcomparedtoworkingatMicrosoft.
Bytheway,mybrotherDavewasatapartyonce,longago,thathadmorethanitsfair
shareofMicrosoftpeople,andapparentlytherewassomewindbagtherebraggingloudly
(thisisaparty,mindyou)thathehad15oftheworld'sbestcompilerwritersworkingfor
himintheVisualC++group.ItoldDave:"wow,Ididn'trealizeRichardStallmanworked
atMicrosoft",andDavewasbummedthathehadn'tthoughtofthatparticularriposteat
thetime.Soitgoes.
ThesadpartaboutthatstoryisthatI'vefoundmyselfoccasionallywantingtobragthatI
workwithsomeofthebestcompilerwritersintheworldatGoogle.Please,Ibegyou:if
youeverfindmeatapartybraggingaboutthecompilerwritersIworkwith,havepityon
usallandshootmedeadonthespot.Hell,bashmeovertheheadwithalampifyouhave
to.
Anyway,nowyouknowwhatIthoughtofcompilersin1991.WhyIeventooktheclassis
beyondme.ButIdidn'tfinish.AndthesecondtimearoundwhichIonlydidbecauseI
feltbadaboutthefirsttimearound:notfromthezero,butfromhavingletDavidNotkin
downIonlytookthetimetounderstandthematerialwellenoughtofinishthecourse
withadecentgrade.
Iwasbynomeansatypical.Ifyou'reaCSstudentandyoulovecompilers(which,
anecdotally,oftenmeansyou'reinthetop5%ofcomputersciencestudentsinyourclass
worldwide),thenIsaluteyou.IbetI'mwaybetteratNethackthanyouare.Therealityis
thatmostprogrammersarejustlikeIwas,andIcan'treallyfault'emforthat.
BeforeIleavethissordidstoryforever,Ifeelobligedtopointoutthatit'spartly
academia'sfault.Exceptfortypesystemsresearch,whichisbeingtreatedwith
approximatelythesamescholarlycautionandrestraintasArthur'sGrailQuest,
compilershavebeenoutoffavorinacademiaforalongtime.Soschoolsdon'tdoagood
jobatmarketingcompilers,andgivingthemduecreditasacriticaltopicintheirown
right.It'sasadfactthatmostschoolsdon'trequireyoutotakecompilersinorderto
graduatewithaComputerSciencedegree.
Sigh.
HowWouldYouSolve...
You'reaprogrammer,right?OK,I'llproposesomeprogrammingsituationsforyou,and
youtellmehowyou'dsolvethem.
http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

2/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

Situation1:you'redoingabunchofJavaprogramming,andyourcompanyhasexplicit
andnonnegotiableguidelinesastohowtoformatyourJavacode,downtoeverylast
imaginabledetail.Howdoyouconfigureyoureditortoautoformatyourcodeaccording
tothestyleguide?
Situation2:yourcompanydoesalotofAjaxstuff,andyourJavaScriptcodebaseis
growingalmostasfastasyourothercode.Youdecidetostartusingjsdoc,ajavadoc
pseudocloneforJavaScript,todocumentyourfunctionsinawaythatpermitsautomated
docextraction.YoudiscoverthatjsdocisamiserablesodofaPerlscriptthatsegfaultson
about50%ofyourcodebase,andbearwithmehereyou'vevowednevertowrite
anotherlineofPerl,because,well,it'sPerl.Pickyourfavoritereason.Howdoyouwrite
yourownjsdocextractor,bearinginmindthatitwillneedtodoatleastacursoryparseof
theJavaScriptcodeitself?
Situation3:yourcompanyhasamassiveC++codebase,theresultofmanyyearsofhard
workbydozens,ifnothundreds,ofengineers.Youdiscoverthatthecodeneedstobe
refactoredinanontrivialway,e.g.toupgradefrom32bitto64bit,ortochangetheway
youdoyourdatabasetransactions,or(Godhelpyou)becauseyou'reupgradingyourC++
compilerandthesyntaxandsemanticshaveallchangedagain.You'retaskedwithfixing
it.Whatdoyoudo?
Situation4:someoneatyourcompanywritesabitchin'newwebbasedcodereviewtool.
Everyoneswitchestoit.Yourealize,afterusingitforawhile,thatyoumisshavingit
syntaxhighlightthesourcecodeforyou.Youdon'thavemuchtime,butyoumightbe
abletoaffordaweekorso,parttime,tomakeithappen.Howdoyoudoit?(Let'ssay
yourcompanyusesfivetoeightlanguagesfor99%oftheircode.)
Situation5:anunexpectedandslightlybizarrenewrequirementarisesonyourcurrent
project:youneedtobeabletouseanewkindofhardwarerouter.MaybeallyourWeb2.0
stuffisscrewingupyourborderroutersornetworkbandwidthmonitors,whoknows.All
youknowisthesysopsandnetworkengineersaretellingyouthatyouneedtotalkto
thesenewroutersdirectly.TheroutershaveIPaddresses,atelnetinterface,anda
proprietarycommandlanguage.Yousendcommands,andtheysendresponses.Each
commandhasitsownsyntaxforitsarguments,andyouneedtoparsetheresponses
(whichhavenodocumentedformat,butyoucanreverseengineerit)tolookforcertain
patterns,inordertosetthemintherightstateforyourwackyuploadsordownloads.
Whattooldoyouuse?
Situation6:yourcompany'sprojectsarestartingtoslip.Theengineersareallsmart,and
theyareallusingthelatestandgreateststateoftheartAgileObjectOrientedSoftware
EngineeringPrinciplesandprogramminglanguages.Theyareutterlyblameless.
However,forsomereasonyourcodebaseisgettingsocomplexthatprojectestimatesare
goingwildlyawry.Simpletasksseemtotakeforever.Theengineersbegintalkingabouta
redesign.ThisistheNthsuchredesigntheyhavegonethroughinthepastfiveyears,but
thisisgoingtobethebigonethatfixeseverything.Whatcolorslipsofpaperdoyougive
them?Woah,ahem,sorry,Imeanhowdoyouensuretheirsuccessthistimearound?
Situation7:youhaveasmall,lightweightstartupcompanyfilledwithcoolyoungpeople
withlongbluetintedhairandnoseringsandtonguerivetsandhipblackclothesand
iphonesandwhateverthehellelseyoungpeoplehavethesedays.YouuseRubyonRails
foryoursite,anditscalesjustfineforyournumberofvisitors.(You'veneverbotheredto
measurewhetheryournumberofvisitorsisafunctionofyoursite'slatency,becauseit's
neveroccurredtoyoutowonder.)YoureadaboutthelatesthorriblegodawfulRails
securityvulnerability,underwhichuserscanmakearbitrarySECfilingsonbehalfofyour
companybysendingproperlyformattedGETrequeststoyourpublicsite.Youdownload
thenewversionandreadtheunittestcodetofigureoutwhattheactualvulnerabilityis,
sincetheydidn'tsay,andyoudeterminethatyouneedtomakeasetofnontrivialcode
changestoremoveaparticular(andmysteriouslynongreppable)idiomfromyourcode
base,replacingitbymechanicaltransformationtoadifferentidiom.Howdoyoudoit?
Situation8:somedrunkenbloggerpresentsyouwithsevenweirdsituationsandasksyou
tospeculateaboutwhattheyhaveincommon.Doyoualreadyknowtheanswer?
Herearetheanswers.What,youthoughtthesewererhetorical?
Scenario#1:youlobbyyourcompanytochangethestyleguidetomatchwhateverEclipse
doesbydefault.
Scenario#2:youposttothejsdocmailinglistandaskifanyoneelsehashadthis
http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

3/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

problem.Severalpeoplesaytheyhave,andtheissueprettymuchdiesrightthenand
there.
Scenario#3:Youquit.Duh.Youknewthatwastheanswerbeforeyoureachedthefirst
comma.
Scenario#4:Toughitout.Colorsareforweenies.OrmaybeyouwireupGNUSource
Highlight,whichcoverslanguagesallthewayfromFortrantoAda,andyoulivewiththe
brokenhighlightingitprovides.
Scenario#5:Perl.It'saswissarmyknife.Youcanuseittosidestepthisproblemwith
honor,bydisembowelingyourself.
Scenario#6:Pink.
Scenario#7:Fixitbyhand.Hell,youonlyhaveabout10klinesofcodeforyourwhole
site.It'sRails,fercryin'outloud.Thiswasatrickquestion.
Scenario#8:Yes.Youskimuntiltheendoftheblog,justtofindoutwhatthefirstmost
importantCSclassis.Stevey'swellknownforshaggydogjokeslikethis.
Andthereyouhaveit.You'renowequippedtodealwithjustabouteveryprogramming
situationyoucouldcomeacross.Soyouobviouslydon'tneedtoknowcompilers.
HowCompilersWork
Herearesomereallifeanswersfromreallifecandidates,withreallifePh.D.sin
ComputerScience,whenaskedhowcompilerswork.
RealCandidate#1:"Oh!They,ah,um,scanyourprogramonelineatatimeandconvert
eachlinetoassemblylanguage."
RealCandidate#2:"Compilerscheckerrorsinyourprogramand,ah,tellyouifyouhad
badsyntax.That'sallIremember."
RealCandidate#3:"I...<3minutepause>...Idon'tknow."
RealCandidate#4:"Theypreprocessyourprogramandconvert#DEFINEstatementsinto
code,andthen,um,emitmachinecode."
That'sprettymuchallthedetailyou'llevergetoutof75%ofallinterviewcandidates,
because,hey,theydon'twanttoworkinahallwayatMIT.Canyoublamethem?
Onlyabout3%to5%ofallinterviewcandidates(andthat'sbeingoptimistic)cantellyou
anydetailsabouthowacompilerworks.Therestwilldosomehandwavingaboutlexand
yaccandcodegeneration,maybe.
Itoldyouyourheartratewouldgoup.Didn'tI?
Takeadeepbreath.
WhyCompilersMatter,Part1
ThefirstreasonCompilerConstructionissuchanimportantCScourseisthatitbrings
together,inaveryconcreteway,almosteverythingyoulearnedbeforeyoutookthe
course.
Youcan'tfullyunderstandhowcompilersworkwithoutknowingmachinearchitecture,
becausecompilersemitmachinecode.It'smorethanjustinstructionscompilersneedto
understandhowtheunderlyingmachineactuallyoperatesinordertotranslateyour
sourcecodeefficiently.
Incidentally,"machines"arejustaboutanythingthatcandocomputations.Perlisa
machine.YourOSisamachine.Emacsisamachine.Ifyoucouldproveyourwashing
machineisTuringcomplete,thenyoucouldwriteacompilerthatexecutesCcodeonit.
Butyouknewthatalready.
Youcan'tunderstandhowmoderncompilersworkwithoutknowinghowOperating
Systemswork,becausenoselfrespectingmachinethesedaysrunswithoutanoperating
http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

4/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

system.TheOSinterfaceformspartofthetargetmachine.Sure,youcanfindpeople
workingonfivetotenyearmainframeprojectsthatultimatelyrunnofasterthanaPC
fromCostco,andtheymaydispensewiththeoperatingsystemduetotimeconstraints,
plusthefactthattheyhaveaworldwidemarketofonecustomer.Butformostofus,the
OSispartofthemachine.
Youwon'tunderstandhowcompilersworkunlessyou'vetakenatheoryofcomputation
course.Thetheoryofcomputationreadslikepartoneofchapter1ofacompilersbook.
Youneedallofit.
You'llhavedifficultykeepingthephases(andeventheinputsandoutputs)ofacompiler
straightinyourheadunlessyou'vetakenaprogramminglanguagescourse.Youhaveto
knowwhatthecapabilitiesofprogramminglanguagesare,oratleasthaveaninkling,
beforeyoucanwriteaprogramthatimplementsthem.Andunlessyouknowmorethan
onelanguagewell,itwon'tmakemuchsensetowriteaprograminlanguageAthat
convertslanguageBtolanguageC.
You'reactuallysurroundedbycompilationproblems.Yourunintothemalmosteveryday.
ThesevenscenariosIoutlinedabovearethetipoftheiceberg.(Theeighthoneistherest
oftheiceberg,butnoskimming!)
Compilerstakeastreamofsymbols,figureouttheirstructureaccordingtosomedomain
specificpredefinedrules,andtransformthemintoanothersymbolstream.
Soundsprettygeneral,doesn'tit?Well,yeah.
Couldanimagebeconsideredasymbolstream?Sure.Streameachrowofpixels.Each
pixelisanumber.Anumberisasymbol.Youcantransformimageswithcompilers.
CouldEnglishbeconsideredasymbolstream?Sure.Therulesareprettydamncomplex,
butyes,naturallanguageprocessing(atleastthedeterministickindthatdoesn'twork
andhasbeensupplantedbystochasticmethods)canbeconsideredafancykindof
compilation.
Whataboutordinarycode?Imean,wedon'talldealwithimageprocessing,ornatural
languageprocessing.Whatabouttherestofus?Wejustwritecode,sodocompilers
reallymatter?
Well,doyouever,EVERneedtowritecodethatdealswithyourowncodebase?Whatif
youneedtowriteasyntaxhighlighter?Whatifyourprogramminglanguageaddssome
newfeaturesandyoureditordoesn'tsupportthemyet?Doyoujustsitaroundandwaitfor
"someone"tofixyoureditor?Whatifittakesyears?Doesn'titseemlikeyou,asthe
perfectlygoodprogrammerthatyouare,oughttobeabletofixitfasterthanthat?
Doyoueverneedtoprocessyourcodebaselookingforcertainidioms?Doyoueverneed
towriteyourowndocextractor?
Haveyoueverworkedoncodebasesthathavegrowninexplicablyhuge,despiteallyour
besteffortstomakethemmodularandobjectoriented?Ofcourseyouhave.What'sthe
solution?
YoueitherlearncompilersandstartwritingyourownDSLs,oryourgetyourselfabetter
language.
IrecommendNBL,bytheway.It'smypersonalfavorite:thelocalmaximuminatensor
fieldofevil,thehighestgroundinthevicinityofHellitself.I'mnotgoingtotellyouwhat
NBLis,yet,though.Patience!I'monlyhalfdonewithmyEmacsmodeforit.
Ifyoudon'ttakecompilers...
Onereasonmanyprogrammersdon'ttakecompilersisthatthey'veheardit'sreally,really
hard.It'softenthe"capstone"courseofaCSprogram(OSoftenbeingtheotherone),
whichmeansit'sasortof"optionalriteofpassage"thatmakesyouaRealProgrammer
andputshaironyourchest,regardlessofgenderorchesthairpreference.
Ifyou'retryingtoplanoutaschedulethatgetsyoutograduationbeforethemoneyruns
out,andhopefullywithaGPAthatdoesn'tcauseprospectiveemployerstosummonthe
guarddogsonyou,thenwhenyouhearthephrase"optionalriteofpassage",whocan
blameyouifyoulookforalternatives?

http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

5/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

I'mnotsayingotherCScoursesaren'timportant,incidentally.OperatingSystems,
MachineLearning,DistributedComputingandAlgorithmDesignareallarguablyjustas
importantasCompilerConstruction.Exceptthatyoucantakethemallandstillnotknow
howcomputerswork,whichtomemeansthatCompilersreallyneedstobeamandatory
300levelcourse.Butithassomanyprerequisitesthatyoucan'trealisticallymakethat
happenatmostschools.
DesigninganeffectiveundergradCSdegreeishard.It'snowondersomanyivyleague
schoolshavemoreorlessgivenupandturnedintoJavaCertificationshops.
Ifyou'reaconscientiousCSstudent,you'llatleasttakeOSandAI.Youmaycomeout
withoutknowingexactlyhowcompilerswork,whichisunfortunate,buttherewillbe
manyproblemdomainsinwhichyoucandeliveratleastasmuchvalueasalltheother
peoplejustlikeyou.That'ssomethingtofeelgoodabout,oratleastasgoodaseveryone
elsefeelsatanyrate.
Goteam.
Mostprogrammersthesedays,sadly,justwantthedegree.Theydon'tcarewhatthey
learn.Theywantadegreesotheycangetajobsotheycanpaythebills.
Mostprogrammersgravitatetowardsasetofcoursesthatcanbestbedescribedasthe
olivegardenofcomputerscience:theplaceswheredumbprogrammersgotolearnsmart
programmerstuff.
Ihesitatetonamethesecoursesexplicitly.Iwouldn'tbeagileenoughtododgethegame
ofgraphicbloodshedaimedatmebyanimated,projectmanaging,objectoriented
engineersusingJavaandWeb2.0technologiestoroastmeviauserinterfacesdesigned
rationallythroughteamworkandmodernsoftwaremethodologies.I'dbecomeacase
studyintheethicsofsoftwareanditsimpactonourculture.
Butyoucanprobablyimaginewhatsomeofthecoursesare.
Ifyoudon'ttakecompilersthenyouruntheriskofforeverbeingontheprogrammerB
list:thekindofeageryoungarchitectwhobecomesasaturnineoldarchitectwhospends
acareerbuildinglargesystemsandbeingdamnedproudofit.
LargeSystemsSuck
Thisruleis100%transitive.Ifyoubuildone,yousuck.
CompilerCamps
Itturnsoutthatmanycompiler"experts"don'tknowcompilersallthatwell,because
compilerscanlogicallybethoughtofasthreeseparatephasessoseparate,infact,that
theyconstituteentirelydifferentandmostlynonoverlappingresearchdomains.
Thefirstbigphaseofthecompilationpipelineisparsing.Youneedtotakeyourinputand
turnitintoatree.Soyougothroughpreprocessing,lexicalanalysis(akatokenization),
andthensyntaxanalysisandIRgeneration.Lexicalanalysisisusuallydonewith
regexps.Syntaxanalysisisusuallydonewithgrammars.Youcanuserecursivedescent
(mostcommon),oraparsergenerator(commonforsmallerlanguages),orwithfancier
algorithmsthatarecorrespondinglyslowertoexecute.Buttheoutputofthispipeline
stageisusuallyaparsetreeofsomesort.
Youcangetahellofalotfartherasaprofessionalprogrammerjustbyknowingthat
much.Evenifyouhavenoideahowtherestofthecompilationworks,youcanmake
practicaluseoftoolsoralgorithmsthatproduceaparsetree.Infact,parsingalonecan
helpyousolveSituations#1through#4above.
Ifyoudon'tknowhowparsingworks,you'lldoitbadlywithregularexpressions,orifyou
don'tknowthose,thenwithhandrolledstatemachinesthatarethousandsoflinesof
incomprehensiblecodethatdoesn'tactuallywork.
Really.
InfactIusedtoaskcandidates,asastandardinterviewquestion,howthey'dfindphone
numbersinatreeofHTMLfiles,andmanyofthem(upto30%)chosetowrite2500line
C++programsastheiranswer.

http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

6/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

Atsomepoint,candidatesstartedtellingmethey'dreadthatoneinmyblog,whichwas
prettyweird,allthingsconsidered.NowIdon'taskitanymore.
Iaskvariantsofitoccasionally,anditstillgetsthem:youeitherrecognizeitasaneasy
problemoryougetouttheswissarmyknifeandstartlookingforasecondtobeheadyou
beforethepaincausesyoutodishonoryourfamily.
C++doesthatsurprisinglyoften.
ThenextbigphaseisTypeChecking.Thisisagroupofzealousacademics(andtheir
groupiesand/orgradstudents)whobelievethattheycanwriteprogramsthataresmart
enoughtofigureoutwhatyourprogramistryingtodo,andtellyouwhenyou'rewrong.
Theydon'tthinkofthemselvesasAIpeople,though,oddlyenough,becauseAIhas
(wisely)movedbeyonddeterministicapproaches.
Thiscamphasfiguredoutmoreorlessthepracticallimitofwhattheycancheck
deterministically,andtheyhavedeclaredthatthisistheboundaryofcomputationitself,
beyondthebordersofwhichyouarecrossingtheoutskirtsofcivilizationintokillorbe
killedterritory,alsooccasionallyknownasTheAwfulPlaceWherePeopleMakeMoney
WithSoftware.
Youshouldhearthemwhenthey'redrunkatraveparties.
AgoodfriendofminewithaPh.D.inlanguagestoldmerecentlythatit's"verypainful"to
experiencetherealizationthatallthoseyearsofslavingoverbeautifulmathematical
purityhavemoreorlesszerobearingontherealworld.
Theproblemwell,oneproblemistheunderlyingpremise,whichisapparentlythat
withouttheHindleyMilnertypesystem,orfailingthat,somecrapasstypesystemlike
Java's,youwillneverbeabletowriteworkingcodeit'llcollapseunderitsownweight:a
vast,typelesstrapfortheunwaryadventurer.
Theydon'tgetoutmuch,apparently.
Anotherproblemisthattheybelieveanytype"error",nomatterhowinsignificantit
mightbetotheoperationofyourpersonalprogramatthisparticularmoment,shouldbe
treatedasanewsitemworthyoftheWallStreetJournalfrontpage.Everyoneshould
throwdowntheirploughsharesandstopworkinguntilit'sfixed.Theconceptofatype
"warning"neverentersthediscussion.
Rememberwhenfuzzylogiccamealong?Oh,oh,waitrememberwhenvonNeumann
andStanUlamintroducedtheMonteCarlomethod?Oh,right,Ikeepforgetting:youwere
borninnineteenninetysomething,andyou'renineteen,andI'mninetysomething.
Well,somedaytheywillrealizethatstrictdeterminismhasalways,alwaysfailed,inevery
dimensionalitycurseddomaintowhichit'severbeenapplied,andit'salwaysreplacedby
probablisticmethods.
Callit"optionalstatictypes",asanembryonicversionofthegloriousfuture.NBL,
anyone?
Thethirdcamp,whotendstobethemostisolated,isthecodegenerationcamp.Code
generationisprettystraightforward,assumingyouknowenoughrecursiontorealizeyour
grandparentsweren'tAdamandEve.SoI'mreallytalkingaboutOptimization,whichis
theartofgeneratingcodethatisjustbarelycorrectenoughthatmostofyourcustomers
won'tnoticeproblems.Wait,sorry,that'sAmazonization.Optimizationistheartof
producingcorrectcodethatisequivalenttothenaive,expensivecodewrittenbyyour
presumablynaive,expensiveprogrammers.
I'dcallcompileroptimizationanendlesschasmofeternaldarkness,exceptthatit'spretty
fun.Soit'sanendlesschasmoffuneternaldarkness,Iguess.Butyoucantakeitto
extremesyou'dneverguesswerepossible,andit'safertile,openresearchfield,andwhen
they"finish",they'llbeinthesameplacetheTypeCheckingcampwantstobe,namelyAI
experts.
BywhichImeanMachineLearning,sincetheterm"AI"smacksofnotjustdeterminism,
butalsoadistinctlackofVCfunding.
Inanycase,thethreecampsdon'treallyminglemuch,andallofthemhaveavalidclaim
atcallingthemselves"compilerexperts"atraves.
http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

7/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

TheDarkSideofCompilers
OneofthereasonsittookmesolongtowritethisridiculousblogentryisthatIwantedto
gowriteacompilerformyselfbeforeIspoutedoffaboutthem.
Done!
Well,sortof.Actually,"notdone"wouldbemoreaccurate,sincethat,asI'vefound,isthe
steadystateforcompilerseverywhere.
Withoutgivinganydetailsaway,asthatwouldbepremature,Itookastabatwritingan
interpreterforausefullanguage,usinganotherusefullanguage,withtheoutputbeing
usefulbytecodeforausefulplatform.
Itwasfun.Itwentprettyfast.Ilearnedalot,eventhoughI'dtakencompilerstwicein
school15yearsago,andeventhoughI'vegraduallytaughtmyselfaboutcompilersand
programminglanguagesoverthepast5yearsorso.
Istilllearnedalotjustbydoingit.
Unfortunately,writingacompilercreatesalivingthing.Ididn'trealizethisgoingintoit.
Iwasn'taskingforababy.Itwasacompletesurprisetome,after20oddyearsofindustry
experience,thatevenwritingasimpleinterpreterwouldproducealifetimeofwork.
Gofigure.
Icreditthephrase"alifetimeofwork"toBobJervis,afriendofminewhohappenstobe
theoriginalauthorofTurboC(withwhichImyselflearnedtoprogram),andadamn
good,evenworldclasscompilerwriter.
Hegaveatechtalkrecently(GoogledoesthataLOT)inwhichhepointedoutthateven
justthesetoffeaturestheaudiencehadaskedforwasalifetimeofwork.
Thisphrasingresonateddeeplywithme.Itwassimilartomyrealizationabout18
monthsbackthatIonlyhaveasmallfinitenumberof5yearprojectsleft,andIhaveto
startchoosingthemverycarefully.Afterwritingmyown"productioninterpreter",I
realizedthattheworkremainingwasunbounded.
Imeanit.Unbounded.
Sofromoneperspective,IsupposeIshouldjustreleasewhatI'vegotandstartmarketing
it,sootherpeoplewilljumponboardandstarthelpingout.Ontheotherhand,Istarted
thisparticularsideprojectnottocreatealifetimeofworkformyself(farfromit),butto
makesureIknewenoughaboutcompilerstobeabletorantsemiintelligentlyabout
them,afterafewglassesofwine,toaquartermillionreaders.
SoI'datleastbetterfinishthebytecompilerfirst.
I'llgetthere.It'llbeneat.I'veonlydescribedthiscrazylittlesideprojecttoahandfulof
people,andtheyreactedprettyuniformlybyyelling"WTF????"Youknow,thekindof
shoutyou'dyelloutifyoudiscoveredthemostsanepersonyouknewintheentireworld
tryingtostuffalitstickofdynamiteintotheirmouth.
That'scompilersforya.Youcanhardlyattemptonewithouttryingtochangetheworldin
theprocess.
That'swhyyouneedtolearnhowtheywork.That'swhyyou,yesyoupersonally,needto
writeone.
It'snotashardasyouthink,exceptforthefactthatitwillturnintoalifetimeofwork.It's
OK.Youcanwalkawayfromit,ifyouwantto.Youprobablywon'twantto.Youmaybe
forcedto,duetotimeconstraints,butyou'llstillbeafarbetterprogrammerfortheeffort.
You'llbeabletofixthatdangsyntaxhighlighting.
You'llbeabletowritethatdocextractor.
You'llbeabletofixthebrokenindentationinEclipse.

http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

8/9

8/10/2015

Stevey'sBlogRants:RichProgrammerFood

Youwon'thavetowaitforyourtoolstocatchup.
Youmightevenstopbraggingabouthowsmartyourtoolsare,howamazingitisthat
theycanunderstandyourcodewhich,ifImaysayso,isn'tsomethingI'dgo
broadcastingquitesoloudly,butmaybeit'sjustme.
You'llbeabletojumpinandhelpfixallthoseproblemswithyourfavoritelanguage.
Don'teventrytotellmeyourfavoritelanguagedoesn'thaveproblems.
You'llbeabletovotewithconfidenceagainstthetiredmajoritywhensomeofthe
smartestpeopleintheworld(like,oh,say,JamesGoslingandGuySteele)trytointroduce
nonbrokenclosuresandrealextensibilitytotheJavacommunity.ThosepoorJava
Communityschmucks.Ipitythemall.ReallyIdo.
Heck,youmightevenstarteatingrichprogrammerfood.Writingcompilersisonlythe
beginningIneverclaimeditwastheendoftheroad.You'llfinallybeabletomovepast
yourlittleserviceAPIsandJavaScriptwidgets,andstarthelpingtowritetheprogram
thatcurescancer,orallvirusesworldwide,oroldageanddying.Oreven(I'mreally
goingoutonalimbhere)thedelusionofStaticTypingasadeterministicpanacea.
Ifnothingelse,you'llfinallyreallylearnwhateverprogramminglanguageyou'rewriting
acompilerfor.There'snootherway.Sorry!
Andwiththat,IsupposeIshouldwrapup.I'mheadingtoFooCampinthemorning,and
Ihavenoideawhattoexpect,butIhaveaprettygoodguessthattherewon'tbemuch
discussionofcompilers,excepthopefullyfromGVRvisavisPython3000.Thatmightbe
cool.
Ifyoudon'tknowcompilers,don'tsweatit.Istillthinkyou'reagoodprogrammer.Butit's
goodtohavestretchgoals!
ButWhat'sTheMostImportantCSCourse?
Typing101.Duh.
Hietheehence.
P O S T ED B Y S T EV E Y EG G E A T 11: 51 P M

<<Home

http://steveyegge.blogspot.no/2007/06/richprogrammerfood.html

9/9

Вам также может понравиться