
Programming Is Hard, Let's Go Shopping - michaelfairley
http://www.codinghorror.com/blog/2008/10/programming-is-hard-lets-go-shopping.html
======
saurik
This isn't even about libraries, this is about approaching the right problem:
if you, for example, allow only strict XML-compliant HTML, you can build an
XML parser that ignores namespaces (which is sufficient for simplified HTML;
once you accept namespaces and other parts of XML life gets much harder), from
scratch if it makes you feel more manly, in a day... you then have _solved_
the problem.

If you want to let users get a little sloppier, that is itself easy to handle.
You can even build a crappy HTML5 parser and then generate your own reasonable
(HTML4 strict, for example) output: that will probable take a few days, but is
mostly just implementing the spec that Hixie spent forever writing. Even if
you get the parser wrong (as it is a long and complicated specification), it
doesn't matter, as you are regenerating the output entirely clean. Again: you
have _solved_ the problem.

In neither of these scenarios were there lessons to learn or scars to gain:
you don't spend years learning how you made mistakes and getting a feel for
this deep problem... you simply _solve_ it, as you defined the problem
correctly. It is amazing what problems you can solve when you first choose the
right problem and then take a direct path to the solution.

Given this, the complaint about the approach Jeff took then discussed
libraries (which is what Jeff focused on, possibly due to the title of the
other article), but honestly the horrifying part was that it also discussed
the solution direction that was taken: finding tons of special cases and
attempting to filter the input with regular expressions.

Those are simply not the right tool for the problem. Even simplified XML is
not a regular language. The definition of an individual tag might be, but you
are up against the horror that is an HTML parser: the same ones Hixie spent
years reversing the behaviors of to build the aforementioned parser
specification.

So, yeah: you can learn a lot from writing your own code, and you may even
want to develop things that are core to your business yourself rather than
using libraries, but of you are spending a ton of time, accumulating scars in
the process, writing code to solve _the wrong problem_... just, don't, okay?
;P

