
“If Your Only Tool Is a Hammer Then Every Problem Looks Like a Nail” - drjohnson
http://quoteinvestigator.com/2014/05/08/hammer-nail/
======
danbruc
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/](http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/)

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

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

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

~~~
bostik
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.

------
hawkharris
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.

~~~
shabble
> _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."

------
patcon
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.

------
pekk
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?

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

~~~
angersock
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.

------
jfb
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.

------
tszming
Makes me remind of this: hammer factory factory factory

[http://discuss.joelonsoftware.com/?joel.3.219431.12](http://discuss.joelonsoftware.com/?joel.3.219431.12)

~~~
dredmorbius
Classic. Still makes me spit coffee.

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

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

------
cessor
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](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.

------
stretchwithme
Irony is people who always whip out this quote.

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

------
lurcio
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..)

------
shill
[http://en.wikipedia.org/wiki/Law_of_the_instrument](http://en.wikipedia.org/wiki/Law_of_the_instrument)

------
doug1001
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)

~~~
angersock
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.

:(

~~~
Pacabel
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.

~~~
jiaweihli
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.

~~~
angersock
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.

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

~~~
angersock
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.

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

------
jasonlotito
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."

------
karlb
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."

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

------
cafard
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.

------
MaysonL
"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

------
skywhopper
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.

------
benihana
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?

~~~
angersock
Perhaps the canonical essay:

[http://www.jwz.org/doc/worse-is-better.html](http://www.jwz.org/doc/worse-is-
better.html)

------
brandonhsiao
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.

~~~
dang
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.

~~~
brandonhsiao
Fair enough. Guess I deserved the downvotes.

