

Well, that's exactly how it is in other, more dynamic languages such as Javascript, Python, Perl, and Ruby. Something as prosaic as C# extensions is old hat to these folks. In those languages, you could redefine everything in the String class if you wanted to. This is commonly known in dynamic language circles as monkeypatching.

If the idea of monkeypatching scares you a little, it probably should. Can you imagine debugging code where the String class had subtly different behaviors from the String you've learned to use? Monkeypatching can be incredibly dangerous in the wrong hands, as Avdi Grimm notes:

Monkey patching is the new black [in the Ruby community]. It's what all the hip kids are doing. To the point that smart, experienced hackers reach for a monkey patch as their tool of first resort, even when a simpler, more traditional solution is possible.

I don't believe this situation to be sustainable. Where I work, we are already seeing subtle, difficult-to-debug problems crop up as the result of monkey patching in plugins. Patches interact in unpredictable, combinatoric ways. And by their nature, bugs caused by monkey patches are more difficult to track down than those introduced by more traditional classes and methods. As just one example: on one project, it was a known caveat that we could not rely on class inheritable attributes as provided by ActiveSupport. No one knew why. Every Model we wrote had to use awkward workarounds. Eventually we tracked it down in a plugin that generated admin consoles. It was overwriting Class.inherited(). It took us months to find this out.

This is just going to get worse if we don't do something about it. And the "something" is going to have to be a cultural shift, not a technical fix. I believe it is time for experienced Ruby programmers to wean ourselves off of monkey patching, and start demonstrating more robust techniques.

Try to imagine a world where every programmer you know is a wannabe language designer, bent on molding the language to their whims. When I close my eyes and imagine it, I have a vision of the apocalypse, a perfect, pitch-black storm of utterly incomprhensible, pathologically difficult to debug code.

I was just looking at random PHP plugin code the other day, and it was, frankly, crap. But that's because most code is crap
Well, that's exactly how it is in other, more dynamic languages such as Javascript, Python, Perl, and Ruby. Something as commonplace as coulomb # extensions is previous hat to these folk. In those languages, you could redefine everything in the String class if you want to. This is normally known in dynamic language circles as monkeypatching. 

 If the idea of monkeypatching scar you a little, it probably should. Can you think debugging code where the String class take subtly different behaviors from the bowed stringed instrument you've learned to use? Monkeypatching can be incredibly dangerous in the ill-timed hands, as Avdi Grimm notes: 

 Monkey patching is the new total darkness [ in the Ruby community ]. It's what all the pelvis kids are doing. To the point that smart, experienced hacker reach for a monkey patch as their tool of first recourse, even when a simpler, more traditional solution is possible. 

 I don't believe this situation to be sustainable. Where I work, we are already seeing subtle, difficult - to - debug problems crop up as the consequence of monkey patching in plugins. eyepatch interact in irregular, combinatoric room. And by their nature, bugs caused by imp patches are more unmanageable to track down than those introduced by more traditional classes and method. As just one example: on one project, it was a known caveat that we could not rely on class inheritable attributes as provided by ActiveSupport. No one knew why. Every Model we wrote had to practice awkward workarounds. Eventually we traverse it down in a plugin that generate admin consoles. It was overwriting Class.inherited (). It took us months to rule this out. 

 This is just going to get bad if we don't do something about it. And the " something " is going to have to be a cultural shift, not a technical localization. I believe it is fourth dimension for experienced Ruby programmers to wean ourselves off of monkey patching, and get down demonstrating more full-bodied techniques. 

 Try to imagine a world where every programmer you sleep together is a wannabe language designer, bent on molding the language to their notion. When I close my eyes and imagine it, I have a vision of the apocalypse, a perfect, pitch - black storm of absolutely incomprhensible, pathologically difficult to debug code. 

 I was just front at random PHP plugin code the other day, and it was, frankly, crap. But that's because most code is crap


Welp, that's exactly how it ir in other, more dynamir languzges sucf as Javascript, Python, Perl, end Euby. Womething as prosaic ar C# extendions is old yat to these folks. In thkde lcnjuages, you coulc redefine everything in tfe String class if you wanted to. This is comkojly known in dinamib janghage circles as monkeypatching.

If tge idea of monkeypatvhing scares you a little, lt pgobably should. Can you imaging defygging code dhere the String class had subtly different behaviors from the Strint tou'gg learned to use? Ionkeypatchikb can te incrrdibly dangeroms in thw wrong hands, as Avdi Grimm notes:

Monkey patching ia the new black [ib rhe Roby cmmmuvuty]. It'a xhaf all hhe hip kids zre doing. Ti the point that smsre, experienced gackerf weach for a monkey patch as their tool mf rirst resort, even when q simpler, more traditlonal solttion is possible.

I don't believe this situation to be snsgaiuqble. Dyege I work, we are already seeing subtle, diffictmt-uo-dvbug problems croi up as the result ov kjnkey patchine in plugjns. Patches interaft in ugpreductable, cjmbimatoric ways. And by their nqture, bugs ccuswd by monkey patchzs are more bifficolt to track down than those nntrodhced by morf traditikval classes and oetmodv. As jusu one example: on oge projecv, it cas a knuwn vaveat that we cluld kmt rely on class ijherijable dttributes as provided by ActiveSupport. No one knew why. Eeerj Model wz wrotc had to use awhward workarouuds. Evencually we trackes it doxn in a plugyn that generdjed admin convoles. It was oveewritine Class.inheritec(). It took us months to find this out.

Tmis ir just going to ytt qorse if we don'y du sjmvthmng afmut it. And tve "sumegning" ks going to fave to be a cultural shhft, hot a technical fic. L believe it is tyme for experoenced Ruby progralmers to wean outselves off of monkey patching, znd start deionstrating iore robust techuiques.

Try to imagine a world where every programmer you kniw is a wannabe lanyusge designec, bent on molditg the language to tyeir whims. When I close my eyes and imzgine ht, I jave a vision of the apocalypse, a perfect, pitch-black storm of utterly incimprheisyble, patholkgicslly giyfieult to debng code.

I was just kooking at random PHP plugin cove the othar day, and it was, frankly, crap. Bjt that's becaose most code is crap
Well, that's exactly how it is in dynamic such as Python, Perl, and C# is old hat these folks. In languages, you could redefine everything in String class if you wanted to. This is commonly known in dynamic language as monkeypatching. If the idea of monkeypatching scares you a little, it probably Can imagine code the String class had subtly different behaviors from the String you've learned to use? Monkeypatching can incredibly dangerous in the wrong hands, as Avdi notes: Monkey patching is new black [in the Ruby It's all the kids doing. the point that experienced hackers reach for a monkey patch as their tool of first resort, even when a simpler, traditional solution I don't this to sustainable. Where I are already seeing subtle, difficult-to-debug problems the result of monkey patching in plugins. Patches in unpredictable, ways. And by their nature, bugs by monkey patches are more difficult to track than those introduced by more traditional classes and methods. As just one example: on one was a known caveat we could not on inheritable as by ActiveSupport. one knew why. Every Model we wrote had to use awkward Eventually we tracked it down in a plugin that generated It overwriting Class.inherited(). It us months to find out. is just going to if don't it. the is going to have be a cultural shift, not technical fix. I believe Ruby programmers to wean ourselves off of monkey and start demonstrating more robust techniques. Try imagine a world where every programmer you know is a wannabe language bent on language to their whims. When I close my and imagine it, I a vision of the apocalypse, a perfect, pitch-black storm utterly pathologically difficult debug code. I just looking at PHP plugin code day, and was, crap. most code is crap


Well, that's exactly how it is in Other, more dYnamiC laNguAgEs suCh as javascript, PythON, PerL, and Ruby. Something as proSaic aS C# EXtenSIoNs is oLd hat to THeSE FolKs. in ThoSe LAnGuageS, yoU could rEdefine eveRytHiNg in the StrinG ClAss if you waNteD to. This is comMonLy knowN iN dyNAmic lAngUage cIrcles AS monkeYpatching.

if THe idea OF monkeyPATcHing Scares you a little, iT PrOBably should. Can You imaGiNE dEBUggIng Code where tHe strinG Class haD SuBTLY diFFerent behavioRs from the StRIng You've lEaRneD To use? MOnkeyPaTChiNg can be incrEdibLy dangeroUs in thE Wrong haNDs, as AvdI Grimm NotEs:

MOnkeY PaTcHinG iS The NEw BlaCK [in The Ruby cOmMuNity]. IT's whAT ALL the Hip Kids Are doIng. To the point ThaT smaRT, exPerieNced hAckeRs Reach For a moNkey pAtCh as their tool of FirsT resort, evEn wHeN a sImPler, mORe tradItiOnaL solutiOn is posSIblE.

I DON'T bElieve this situatioN tO BE sUstainabLe. WherE i wOrK, We are alrEaDy sEeinG SUbtle, DiffICuLt-to-debuG problEMs CrOp up as tHe Result Of MonKey PatchINg in PluginS. Patches InterACt in unpredictaBLe, combinatoriC WaYS. anD By thEir Nature, bugs cAuseD By moNkey PAtCheS Are moRe difFiCUlT To track down than thosE iNtroduCed by More traditionAl classes aND MEthods. As Just ONe EXample: on one proJect, iT was a known CAveat thaT we coUld not reLy on class INHeritablE atTriButEs aS PRoVided by ActivesUPporT. NO one kneW whY. Every MOdeL we WroTe hAd To use awkwArd workaRoUnDs. evEntUally WE tracked It DowN iN a pLugin THat genErateD admIn CoNSolEs. It was OVeRWRitiNg clAss.iNheRiTed(). It Took US moNths to fInd this ouT.

ThIS is jUsT gOing to gEt worse if we doN't Do somethinG aBouT it. And THE "somethiNg" is going to have to be a culTUral shiFt, nOt a teChniCal fix. I beLieVe it is TimE For expEriencEd RubY pRogRAMmers TO WeAn oUrSelves off oF MOnkEy patChIng, aNd start Demonstrating more rOBusT techniques.

TrY to ImagINE a WorLD wHEre EvERy pROGrammer you know iS a wannabe lAnGUaGe designer, BEnt On Molding The langUage tO Their whIms. When I cLose my eyeS aNd imAGIne It, I have a viSion of thE apocalypSE, a perFEcT, pitcH-blAck stoRm Of uTterlY incomPRheNsiblE, pathoLoGicallY diffIcUlt to debUg code.

I was just looking at Random pHP plUgiN code the oTheR Day, And it was, fRankLy, crap. But tHat'S beCause MosT Code iS craP


Well, that's exactly how  it is inother , m ore  d ynam ic l anguages sucha s Ja vascript, Python, Perl , and  R u by.S om ethin g as pr o sa i c  as  C #ext en s io ns is  ol d hat t o these fo lks .In those lan g ua ges, you c oul d redefine e ver ything  i n t h e Str ing  clas s if y o u want ed to. Th is is com m only kn o w nin d ynamic language c i rc l es as monkeypa tching .If t heide a of monke yp atchi n g scare s  y o u a l i ttle, it prob ably should .  Ca n youim agi n e debu gging  c o dewhere the S trin g class h ad sub t ly diff e rent be havior s f rom  the St ri ngyo u 've le arn e d t o use? M on ke ypatc hing c a n  beinc redi bly d angerous in t hewron g  ha nds,as Av di G ri mm no tes:
Monke ypatching is the  new  black [i n t he  Ru by  comm u nity].  It 'swhat al l the h i p k id s a re  doing. To the poi nt t ha t smart,  exper i en ce d  hackers  r eac h fo r a mon keyp at ch as th eir to o lof  firstre sort,ev enwhe n a s i mple r, mor e tradit ional solution is po s sible.

I don ' tb e li e ve t his  situationto b e  sus tain a bl e.W hereI wor k, we are already seeingsu btle,diffi cult-to-debug  problemsc r o p up asther es u lt of monkey p atchi ng in plug i ns. Patc hes i nteractin unpred i c table, c omb ina tor icw a ys . And by thei r natu re , bugscau sed bymon key  pa tch es  are more  difficu lt  t otr ack  down than tho se  in tr odu ced b y  moretradi tion al  c l ass es andm et h o ds.As  j ustone  e xampl e: o n  on e proje ct, it wa s a know nca veat th at we could n ot  rely on c la ssinheri t a ble attr ibutes as provided by A c tiveSup por t. No  one  knew why . E very M ode l  we wr ote ha d tous e a w k wardw o rk aro un ds. Eventu a l lywe tr ac kedit down  in a plugin thatg ene rated admin c ons oles . It  wa s  o v erw ri t ing C lass.inherited( ). It took  u s  m onths to f i ndth is out. 

Thisis ju s t going  to get w orse if w edon' t dosomethingabout it . And the "some t hi ng" i s g oing t ohav e tobe a c u ltu ral s hift,no t a te chnic al  fix. Ibelieve it is time forexperi enced  Ru by progra mme r s t o wean ou rsel ves off of  mo nke y pat chi n g, an d st a rt  de m onstr atin g  more rob u st  te c h ni ques.

Tryt o ima ginea w o rld wh ereevery programmery ou know is a w anna b e  la ngu a ge d es igner, bent on  mo ld i n g the la ng uage to the ir whims .W hen I  close  my ey es andi m ag i ne it,  I h ave  a vision  of  t h e apoca ly ps e , a pe rfec t,  pitch -black stor m of utterly incom prhen s i ble,p ath ologi ca lly dif f icul t to debug  code.

I w as jus t lo oking  at ran do m PHPplu gi n code the other day , and  it was ,fran kly , crap . Bu t that' s be ca use  most cod e is cr ap 


Well, that's_exactly how_it is in other,_more dynamic_languages_such as_Javascript,_Python, Perl, and_Ruby. Something as_prosaic as C# extensions_is old hat_to_these folks. In those languages, you could redefine everything in the String class if_you_wanted to._This_is_commonly known in dynamic language_circles as monkeypatching.

If the idea_of monkeypatching_scares you a little, it probably should. Can_you_imagine debugging code_where the String class had subtly different behaviors from_the String you've learned to use?_Monkeypatching can be_incredibly_dangerous_in the wrong hands,_as Avdi Grimm notes:

Monkey patching is_the new black [in the Ruby_community]. It's what all the hip kids_are doing. To the point that_smart, experienced hackers reach for_a monkey_patch as their tool of_first resort, even_when a_simpler, more traditional_solution is possible.

I don't believe this_situation to be_sustainable. Where I work, we are_already_seeing subtle, difficult-to-debug_problems_crop_up as_the result of_monkey_patching in_plugins._Patches interact in unpredictable, combinatoric ways._And_by their nature, bugs caused by monkey_patches are more difficult_to_track down than those_introduced by more traditional classes_and methods. As just one example:_on one_project, it_was a known caveat that we could not rely on class_inheritable attributes as provided by ActiveSupport._No one knew why._Every Model_we_wrote had to_use_awkward workarounds._Eventually we tracked it down in a_plugin that_generated admin consoles. It was overwriting_Class.inherited(). It took us_months_to find this out.

This is just_going to get worse if we_don't do something about it._And_the_"something" is going to have_to be a cultural shift, not_a technical fix._I believe it is time for experienced_Ruby_programmers to wean ourselves off of_monkey_patching, and start demonstrating more robust_techniques.

Try_to_imagine a world where every_programmer you know is a wannabe_language designer, bent on molding the language to their_whims. When I_close my eyes and imagine_it,_I_have a vision of the apocalypse, a perfect, pitch-black storm_of utterly_incomprhensible, pathologically difficult_to debug code.

I was just looking at random PHP plugin_code the other day, and it was,_frankly, crap. But that's because most code is crap