The Animals of the Web
Published by: Tim Bakkum,
Originally invented in 1989 by Tim Berners Lee, the Web gets its name from the idea of web pages linked together by hyperlinks, creating a "web" in the process. The metaphorical meaning of the word web, referring to nature where a spider weaves together a web by connecting numerous silk threads. This powerful image is also taken over by other languages, such as French, where we see the word "toile" that is also used for a spider's web is use to designate the World Wide Web. As a result, Internet bots that crawl the web (for indexing for search engines for example) are unsurprisingly referred to as spiders.
In this article, we will have a look at some of the other metaphorical creatures lurk the web.
The first actual animal
Probably the most well known animal of the web, and the most dreaded by developers: the bug. You may think that the use of the word bug to mean a fault or error in the code comes from the verb "to bug" which means "to bother, annoy". However, the term bug was popularised before the web even existed, by computer pioneer Grace Hopper in 1947. There were already accounts before that date of the term being used in mechanical engineering, but when an actual actual moth got trapped in a relay of a computer system, Hopper's colleagues, aware of the term, noted in their logs "First actual case of bug being found." They literally debugged the machine and kept the moth next to the note.
More debugging
Speaking of debugging, every developer will be stuck on a bug at some time that he/she just can't seem to solve. After having tried everything you can think of, you go and consult a colleague. And as if by magic, the solution becomes apparent to you just by the action of explaining your problem and what the code is supposed to do. This is what is commonly referred to as "rubber duck debugging". Without your colleague ever needing to say a word, you might have well explained it to an inanimate object: a rubber duck. Andrew Hunt and David Thomas Coined the term in their book The Pragmatic Programmer by, where a programmer would carry around a rubber duck to debug their code by explaining it to the duck. The idea is that by explaining a problem to somebody else, you are tapping into a deeper level of understanding, as you are essential teaching somebody, instead of just learning yourself.
Quack overflow
Stack overflow introduced a rubber duck chatbot feature on their website in reference to rubber duck debugging as an April Fools' Day joke. The user could use their microphone to submit their problem to the duck, with the duck always replying "Quack", followed by "Whenever you're stuck, rubber ducking is a powerful method for solving even the most difficult problems. Insights are often found by simple describing the problem aloud."
If it walks like a duck...
Recently, when submitting an issue to a library indicating that a feature was not working as documented, the author replied that it would be corrected soon, but that in the meantime I could "duck-punch" in the feature. This violent metaphor comes from the Duck test principle, a type of abductive reasoning, and usually expressed as followed:
If it looks like a duck, swims like a duck, and quacks like a duck, then it probably is a duck.
So where does the punching come in? If your "duck" doesn't give you the noise that you want, "you've got to just punch that duck until it returns what you expect" .
Applied to programming, duck punching entails changing the code in a non-destructive way to get the outcome that you want. In my case, the plugin author suggested the following:
- copy existing prototype method
- overwrite existing prototype method
- add previous method + desired behaviour
By enhancing the method in my own file (where I load the JavaScript library as external script), I did not have to touch the source code from the npm module.
Duck-punching is a synonym of another animal metaphor: Monkey Patching. The term seemingly originates from guerilla patching, (guerilla referring to the 'sneaky' nature of the change) which became gorilla patching because they sound almost the same. Later this allegedly became monkey as it sounds less intimidating.
In the second part of this series, we will have a look at some more web animals, including several pandas, birds, bears and the indispensable cats.