Hacker News new | past | comments | ask | show | jobs | submit login
“If Your Only Tool Is a Hammer Then Every Problem Looks Like a Nail” (quoteinvestigator.com)
77 points by drjohnson on May 12, 2014 | hide | past | favorite | 46 comments



In my brain this quote got deeply linked to PHP, more precisely to the preface of an article [1]. And it is funny no matter if you love or hate PHP.

I can’t even say what’s wrong with PHP, because— okay. Imagine you have uh, a toolbox. A set of tools. Looks okay, standard stuff in there.

You pull out a screwdriver, and you see it’s one of those weird tri-headed things. Okay, well, that’s not very useful to you, but you guess it comes in handy sometimes.

You pull out the hammer, but to your dismay, it has the claw part on both sides. Still serviceable though, I mean, you can hit nails with the middle of the head holding it sideways.

You pull out the pliers, but they don’t have those serrated surfaces; it’s flat and smooth. That’s less useful, but it still turns bolts well enough, so whatever.

And on you go. Everything in the box is kind of weird and quirky, but maybe not enough to make it completely worthless. And there’s no clear problem with the set as a whole; it still has all the tools.

Now imagine you meet millions of carpenters using this toolbox who tell you “well hey what’s the problem with these tools? They’re all I’ve ever used and they work fine!” And the carpenters show you the houses they’ve built, where every room is a pentagon and the roof is upside-down. And you knock on the front door and it just collapses inwards and they all yell at you for breaking their door.

That’s what’s wrong with PHP.

[1] http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/


And a PHP developer actually built the hammer [1].

[1] https://www.flickr.com/photos/raindrift/sets/721576294929080...


My favourite of the many variations I've seen on this one: "If all you have is an icepick, every comrade looks like Trotsky."


Hah, that's a good one. My favourite so far has been this one: "If your only tool is C++, all problems look like thumbs."

EDIT: noticed that jfb had used this already, if only in slightly different form.


Tech startups should operate more like public relations firms. They share similar goals — using technology and clever messaging to solve big problems — but modern PR firms such as Edelman and Robert Wood Johnson base their campaigns on research. As a PR person, I wouldn't choose a medium, let alone a specific technology, without proving through stats, focus groups, etc., that it was the best way to solve a problem. Sometimes the best approach was an iPhone app; sometimes it was to meet with other businesses or policymakers in person. The research was continuous, too. If an app failed to resonate with an audience, we were prepared to dump it to pursue other solutions and media.

Now that I'm a programmer, I find myself and many co-workers doing the opposite. (In fact, I'm a huge culprit, so this isn't a holier-than-thou comment.) A specific set of technologies dictates the problem set and the approach. I recently heard about a college class, for instance, that challenged students to solve a business problem using a Raspberry Pi and an Arduino. I won't deny that those are interesting and useful technologies, but once they wielded those hammers, without a single hour of research, every problem probably looked like a nail.


> A specific set of technologies dictates the problem set and the approach. I recently heard about a college class, for instance, that challenged students to solve a business problem using a Raspberry Pi and an Arduino. I won't deny that those are interesting and useful technologies, but once they wielded those hammers, without a single hour of research, every problem probably looked like a nail.

Whilst I agree with your first paragraph, I think you've picked a particularly poor example to illustrate it with here.

The problem the college course is solving is "find an engaging/useful way to teach students about embedded programming & automation". As such, "solving" a notional business problem through personal meetings and a written process whilst leaving all the hardware in its wrapping would/should result in a failing grade.

This formulation is much more "If you're being rewarded on your ability to hammer things, it's largely immaterial whether or not they are nails.", or perhaps a little more favourably:

"Someone who successfully solves problems with hammers will tend towards seeking nail-like problems."


I find that turn of phrase is often used in curiously ironic fashion -- Once a certain type of know-it-all is armed with that expression, they tend to over-apply it to dismiss ideas that fall outside their favour.


What saying do we have for people who insist on using obscure tools and mishmashes of tools when this is going to be a maintenance headache for everyone who comes after?

Or people who only use general-purpose tools for one or two things based on stereotypes they heard somewhere?


If you haven't mastered the nailgun, maybe it's safer for you to use a hammer.


If you've ever been to a habitat for humanity worksite, or just seen a bunch of day laborers at work in Texas, you'll know not to underestimate the power of lots of unskilled labor with primitive tools.

See also the Web.


"If your only tool is a hammer, hit that guy over there with it"


My favorite formulation of this family is: "When C++ is your hammer, everything looks like a thumb" -- which leads neatly into: "C++: an octopus made by nailing extra legs onto a dog". I used to really have a thing about C++, but as I got older, and C++ got better, we've mellowed, and are on speaking terms.


Makes me remind of this: hammer factory factory factory

http://discuss.joelonsoftware.com/?joel.3.219431.12


Classic. Still makes me spit coffee.


If anything, the "everything needs pounding" bit expresses the spirit of the maxim better than "every problem looks like a nail".


If all you have is HN, every nail looks like an excuse to invent a new hammer.


Around agile software development, since lean as the "Toyota Way" originated from Japan, a lot of Japan's folklore diffuses into modern agile dev- lingo, such as Kanban, Kata, Dojo, Kaizen. I found another term that I liked:

http://en.wikipedia.org/wiki/Tsujigiri

In my mind this is isomorphic to the metaphor of the hammer. A samurai with a new sword will go out and cut up the first person he sees.

This is a cautionary tale, you might end up hurting somebody. If, for example you get a new katana(e.g. python decorators) you might decorate everything that looks like a function, but you would actually suffer casualties in readability and structure; debugging becomes a mess. Therefore you should also understand when and who needs to be cut up.


Irony is people who always whip out this quote.


Are you implying that if your only proverb is the one about hammers and nails then everything looks like a problem of misapplied technology?


Took me a while to thing about it! True dat :D


My variation: If all you have is a hammer, you'll only look for nails.

Re: OP. I always maintain the source of the quote to be Nietzsche (He was a jackdaw - aren't we all? - so I'm not claiming he's the original source. As if that means much anyway - ideas/memes are like the fashion cycle, being upcycled to 'culture' from the street.

(Its over twenty years since I read any N. so no idea which book but maybe Menschliches, all zu..)



a few years ago, in a discussion about which technologies to use for building an ETL layer, a tech lead for the team which did nearly all of their work in C++, suggested, not surprisingly, C++; in response, a senior dev said: "if the only tool you have is C++ then every problem looks like your thumb" (no intention to disparage any technology or language here)


We've got a dev who is... erm, enthusiastic about using short C programs to solve all their problems.

Which is well and good, until you've got to recompile them on a checkout, or figure out what the hell they're doing, or get bitten by stupid bugs that only live at the low-level.

:(


Those kind of problems you mention aren't isolated to C, though. The exact same, or very similar, problems exist when using scripts written in Perl, Ruby, Python, and other scripting languages.


I disagree - there's an entire class of problems in C that stem from something that isn't in the languages you mentioned: manual memory management.


Yep.

That, and the lack of a sufficiently-abstract concept of strings.

To wit, let's get the length of two strings in Ruby and C.

Ruby:

  ("aha" + "oho").length
C:

  char buffer[1024]; // lol i hope this doesn't overflow
  memset(buffer,0,1024);
  strcat(buffer, "aha");
  strcat(buffer, "oho");
  return strlen(buffer);
And that C version? Still not always safe; consider the case where a string overflows, where somebody else fucks up that memory in the stack by (say) a bad variadic arg invocation or array access out-of-bounds.

Oh, and is that string length including the null terminator (no)? And why do we even care about null terminators unless we're doing low-level memory frobbing?

Anyways, imagine that sort of arcana multiplied across every string operation in your dumb little script. It's awful.


Why not strlen("aha") + strlen("oho")?


Or even:

  strlen("ahaoho")
The C code more closely reflects what the Ruby is doing, but otherwise yes, you're correct. In C++ I could probably get it all done at compile time anyways.


The whole point of the code is to concatenate two C strings at runtime. That's the big problem.


Ugh. Most short programs are all about the string handling, which C is terrible at.

The only real case for a short C utility is if the heart of what you're doing is a single system or library call that isn't so readily accessible in Python, Perl or shell.


My usual quip in retort is: "But not every hammer is used to hit a nail, and not every nail should be hit by a hammer."


I like Rob Heaton's variation on the phrase, which is also true:

"When you have a nail in your eye, everything looks like a nail."


My favorite variation is: “if your only tool is a hammer, then everything looks like a thumb.”


Ford Maddox Ford's novel The Good Soldier once a twice mentions as a blacksmith's saying "By hammer and hand all art doth stand" which is in the same spirit, and suggests to me that variants have been around for a long time.


"Give a man a hammer, then he wants a bell, and the next thing you know, he wants a song to sing, all over this land. Ingrateful SOB."

--danceswithcats on some random website I'm not going to bother finding in my history


This saying explains a lot of the JS build systems, compile-X-to-Y tools, Ruby DSLs, and turn-the-Internet-into-a-Haskell-driven-functionspace articles that get posted to Hacker News.


Is there a corollary to this quote? Something about how you have a problem that can be solved optimally with a drill and adequately with a hammer, so you decide to choose the hammer because you're already pretty decent with one and you've never really used a drill. So even though you're not using the optimal tool, you've gotten the job done and moved on to the next one while you'd still be learning the drill. Is there something like that?



Should we start? "Arm yourself with a quote and every coffee looks like a mic"? "Scalpels don't plant nails easily"? "If we had all those tools, we wouldn't be working here"?


"The best is the enemy of the good."

Dans ses écrits, un sage Italien

Dit que le mieux est l'ennemi du bien.

~~Voltaire

http://en.wikiquote.org/wiki/Perfection


Don't let perfect be the enemy of good.


Good enough is


Just a heads-up: not sure if it's just my own flawed nature, but I almost upvoted the link just because of the clever quote. For me at least, that title is borderline linkbait.


I wouldn't call it linkbait. That quote is precisely the subject of the article.

Also, the author is a careful researcher with a long track record.


Fair enough. Guess I deserved the downvotes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: