|Pathologically Eclectic Rubbish Lister|
The first cargo cultsby jepri (Parson)
|on Jan 11, 2002 at 18:23 UTC||Need Help??|
One of our illustrious members once had the habit of crying "cargo cult!" whenever he saw someone cut and paste a code snippet into a program. In particular, he was decrying the habit of cutting and pasting bad code. But even cutting and pasting good code is not necessarily a good thing. Here's the origin of the term "cargo cult", and why it's such a bad idea:
This quote is from a book called "Surely you're joking Mr. Feynman", by Richard Feynman. He was one of the few scientists in the world who could pack a lecture hall when he gave public lectures. Worked on the bomb, revolutionised physics and was funny as well.
"I think the educational and psychological studies I mentioned are examples of what I would like to call cargo cult science. In the South Seas there is a cargo cult of people. During the war they saw airplanes land with lots of good materials, and they want the same thing to happen now. So they've arranged to make things like runways, to put fires along the sides of the runways, to make a wooden hut for a man to sit in, with two wooden pieces on his head like headphones and bars of bamboo sticking out like antennas - he's the controller - and they wait for the airplanes to land. They're doing everything right. The form is perfect. It looks exactly the way it looked before. But it doesn't work. No airplanes land. So I call these things cargo cult science, because they follow all the apparent precepts and forms of scientific investigation, but they're missing something essential, because the planes don't land.... "
So now you know why cargo cult programming is bad. Because it's like waving some bamboo sticks to try and summon a cargo plane to fulfill your wishes. Whenever you cut and paste code without knowing what it does, you are like the poor guy on the runway, waving bamboo sticks to try and make the magic happen. You've got the look (you've got the code), but you're lacking something essential.
It probably wouldn't be right to finish without a tip on how to get that essential something - experiment! Feyman was a scientist, and he goes on to explain how science succeeds by constantly testing it's knowledge. So if you have some code that does what you want, without knowing how or why it does what you want, tinker with it.
Cut it out and paste it into a little program called 'test.pl'. Make it print out something different. Change the colours. Add mag wheels. Break it and make it work again. Ask about it in the CB.
Don't just paste it into your own program, because when the people who originally wrote it read your code, they see a little man waving bamboo leaves...