assorted ramblings by Jamis Buck

Never. Ever. Cargo-cult.

7 January 2008 —
2-minute read

I was told today on a mailing list that some people have been justifying their coding decisions by saying things like “but that’s how Jamis does it!”

And I was mortified. Because someday a time will come (and likely already has!) when the things I’ve written will be surpassed by a better way, and I will wilt with embarrassment if anyone uses “that’s how Jamis does it” to justify continuing with the antiquated style.

I’m learning, constantly. Every project I undertake teaches me something new. Every programmer I’ve ever worked with has shown me a better way to do things. “How X does it” (for absolutely any mortal value of X) is a moving target, and if you’re blindly basing your designs on something I (or anyone else) wrote a year or two ago, then you should step cautiously.

Never. Ever. Cargo-cult. If someone writes about something that you find clever, understand why you think it is clever. If someone preaches a better algorithm, understand why the algorithm is better. And if someone asks why you do something a certain way, argue it on it’s own merits, without resorting to an appeal to someone’s (supposed) authority. If you can argue that something is better than something else solely by contrasting it’s pros and cons against the alternative, you’ll be taken much more seriously. And you’ll have a much better chance of recognizing a better way when it is presented to you.

I’ll say it again. Never. Ever. Cargo-cult. Ever.

That said, I’ve been very, very quiet lately, and I apologize. I’ve been rethinking some priorities and experimenting with some new interests. Also, I’ve been trying to finish up (finally) Net::SSH v2 and Net::SFTP v2. Hopefully this year I’ll climb out of the hole I dug for myself last year and have more to blog about again.

Reader Comments

Amen, brother Jamis! If only I had a dime every time a co-worker told me, “No, I don’t know what that line of code does, but it was in the sample code I downloaded…” I’d be simultaeously rich and insane.

Daniel Azuma7 Jan 2008

Haha “any mortal value of X” – now there’s a type system I’d like to see :)

Dr Nic7 Jan 2008

I promise I’m never going to cargo-cult now… because Jamis said not to. ;-)

norman7 Jan 2008

You’re damn right… I like to remind myself that there are always better ways to achieve something.

I for one sure do hope that you will find some time to blog this year.

I guess it has a lot to do with “The Rails Way”. I’ve also seen a lot of talk around town about “code-smell” too. Did you guys coin that?

When you tell the masses that the best way is yours, you shouldn’t be surprised when kids start using your statements to justify their actions. Its teacher student stuff.

The most important lesson that I ever learned about programming is this: nobody knows what’s going on. Its probably a lesson people learn in every evolving profession at some point. Its the same lesson you learned as a child when you found out that your parents never had the answers straight themselves. Business, life, programming, making a fire in a windstorm. Everybody is thrashing around like a fish out of its egg.

Its important as a mentor to teach your students that you are only another thrashing fish.

Programming really is fun. One reason for that is it puts you back in your egg to some extent. Create a system of your own to swim in. Its really beautiful. Its really fun! flip-flop be gone! Swim swim swim!

But the beauty of a fish bowl only reveals itself when you are its sole swimmer. Slapping shit together gets boring for anyone. The folks that are shooting your name around to justify their code are still learning that lesson. Eventually they will learn that the fun starts from a different angle. The fun starts in the code. The fun is in their own head. The fun is in the bowl.

Much respect.
b

b7 Jan 2008

@b, “code smell” originated earlier than the Rails Way, though I couldn’t tell you who started it. And yeah, I’m well aware of the impact the Rails Way site has had on those learning the framework, but if all they got out of it was recipes, then I’m really disappointed. Koz and I both tried hard to say “do it this way BECAUSE…” If people are glossing over the justifications for our recommendations, then I think 80% of the value of that site has been lost. Disappointing, is all.

Jamis7 Jan 2008

The term ‘code smell’ I believe is from Refactoring by Martin Fowler. At least, that’s the oldest book I recall reading using the term. Whether or not he invented it is another thing :)

Ryan A.7 Jan 2008

Cool! I will now cargo-cult your “never ever cargo-cult” rule! And if someone asks why, I will appeal to your authority! :)))

szeryf8 Jan 2008

I have found myself saying “but that’s what X does”, but usually it is when someone suggests what I am doing is completely insane. If I can point to a well-respected member of the community who thinks the same way then it suggests I’m not totally nuts.

Chris Rimmer8 Jan 2008

I think a lot of programmers just forget to ask “why?”, preferring familiarity to experimentation. Copying other approaches is part of avoiding asking why.

Alex Young8 Jan 2008

Yeah Jamis,
I meant nothing negative about the Rails Way. Its consistently one of my favorite reads whenever you guys put new articles out. And you both do a great job of explaining why you make the decisions you do. And thanks for the code-smell clarification.

This kind of thing is just bound to pop up though.

One thing to keep in mind is that most of the folks reading your articles will probably never write a word about them online. The cargo-culters might be disheartening you but I wouldn’t guess they are any kind of representation of your overall readership. Its one of those situations where the ones who might not be getting everything they could out of the articles (most likely because they just dont have enough experience yet) are the ones with reason to refer to them (or you) elsewhere.

And when folks are using the reasoning behind practices you’ve taught them to defend their ideas, well, you probably arent mentioned.

I dont know. I wouldn’t worry too much about it. Call me a helpless optimist but I cant help but think most of your readers are thoughtful, competent, programmers who thoroughly enjoy reading and learning from your work and your articles… but probably dont make much fuss about it elsewhere.

Man, your articles both here and there have been such a great learning tool for me. Ive been reading them for YEARS. Ive never once referred to them anywhere online though. I bet there are thousands like me. And if thats true, I hope there is nothing to be disappointed about.

b

b8 Jan 2008

@Chris Rimmer, I would say that in that case (where someone thinks you are completely insane for doing something a particular way), the “but that’s what X does” argument is especially pointless. That is precisely when you want to be able to argue a case on its own merits. Please, please consider avoiding the appeal-to-authority argument in the future. :)

Jamis8 Jan 2008

@b, thanks for the kind words!

Jamis8 Jan 2008

I argue it’s background stress that biases people away from considering each case in full and towards “heuristics” (as the stress researchers call cargo cult behaviours).

Wouldn’t “never-ever-cargocult” because Jamis said so be a form of cargo cult?

steve8 Jan 2008

While I think that, in general your advice is very good, I cannot agree with its absolute nature. There are exceptions to just about every rule, and often there are times when just copying a great programmer, or cut/pasting some code is simply good enough. “Great” is often the enemy of “good”, and “perfect” is almost always the enemy of “finished”. Indeed, “coding from scratch” or “doing things your own way” is often the surest path towards new and exciting bugs!

Recently I needed to parse a CSV file in JavaScript. I happened to find a nice regex to use with the split() function, so as to properly handle quoted phrases. I cut and paste it into my code, did some testing, and promptly forgot about it. Quite frankly I don’t care how it works, or why it works, only that it does. If it breaks, then I can spend my time figuring out the nuances of their expression, but not before.

If I were doing this for my day job (defense contracting) this would be unacceptable. But, for a simple mashup webapp, the increase in reliability I gain from spending an hour trying to figure out something that works perfectly fine is not worth as much as the useful improvements I could make to the user experience in that same hour.

So while I do think in general too few programmers actually know what they are doing, sometimes that’s really not a problem. I once successfully parallelized a Fortran 77 MHD code to run on 96 processors (instead of one), all without the faintest clue as to how the post-doctorate level PDE solver actually functioned. The same goes for “best practices” – if empirical analysis shows that they are suitable for the problem at hand, the details of why may be irrelevant. I would sooner trust the judgement of those with 20 years of programming experience to my own unless I have direct empirical evidence stating otherwise.

So if one desires to behave as a rational agent, and believes in some kind of statistical reasoning like Bayesian or Demptster-Shafer evidence combination, it simply becomes a matter of trust, empirical evidence, and, in the end, whatever gets the job done. Programming (like all of engineering) is an exercise in finite resource allocation (cost/benefit/risk analysis), and the most precious resource of all is often time.

@Justin, you make some good points, but I’m not talking about one-liners here. I’m talking about higher-level things, application design or algorithm selection. And I’m not saying people should “code from scratch”—that’s what libraries are for! Learn from others, use libraries, borrow code liberally, etc.

But if you select a library and someone asks why you chose it, don’t just shrug! Give them a real answer: “because Jamis tested a bunch of them and said it was the fastest” is acceptable. “Because Jamis uses it” is not. All I’m advocating is understanding the forces behind your decisions.

Jamis8 Jan 2008

Hi Jamis. I see you’ve moved on a lot from the Lux days!

Darren8 Jan 2008

Darren! It has been a long time. Drop me a line sometime, jamis at jamisbuck org!

Jamis8 Jan 2008

Nice post. Cargo-culting is all too common, in all walks of life – the sooner more people realize it the better it’ll be for the world as a whole …

Keep programming and writing :)

Cheers,
Vasudev
Dancing Bison Enterprises
www.dancingbison.com

Vasudev Ram8 Jan 2008

Not to nitpick, but cargo cult is not about blind adherence to authority. Cargo cult is about superstition: repeating the rituals that seem to work with no knowledge about why they work. You got the “no knowledge about why” part right, but it’s a “but it used to work when I did it like this” rather than “but that’s what X does/told me to do”. Now am I splitting hairs?