Hacker News new | ask | show | jobs
by glenda 4317 days ago
Writing too much code can make you a worse programmer.

The real way to get better is to pick an area of study and research the shit out of it, even non-technical aspects if applicable. Go back as far as you can and read every canonical book you can find on the subject. Even if it's outdated information, it will help you see how we arrived where we are now (as long as it's not a purely technical reference).

Read those things until you feel some things click in your head. Then go back and try to write some code.

This might be difficult to do while in school though. I'm sure you're doing a lot of reading already.

1 comments

I disagree with this. I read every software engineering book I could get my hands on when I was in school - GoF, Refactoring, SICP, Pragmatic Programmer, XP Explained, Implementation of Functional Programming Languages, TAPL, Basic Category Theory, On Lisp, Art of the Metaobject Protocol, numerous textbooks I wasn't assigned. As a result, my code ended up overcomplicated, with a bunch of cool algorithms, a lot of OO design, a nice smattering of patterns...but relatively few useful solutions for people. It was only when I was like "Alright, I've already read every book anyone I've met has ever mentioned...I need to push through and actually finish a project now" that my skills started shooting up.

Write code first. Write code until your programs collapse under their own weight. Then go out and read what the masters have written. You'll understand it much better when you have personally faced the problems that they were facing.

I was having a similar discussion with a friend of mine.

When I was a teenager, I wrote small C projects, then I discovered the world of OS development and set myself to write a minimal operating system from scratch. It was an amazing experience, with a lot of head-scratching, hours spent debugging weird hardware issues, reading other people's code and just churning out badly engineered (but working) code.

Now, 10 years after, after playing with Haskell, OCaml, Scheme, learning about best practices, variants, typeclasses, static vs dynamic typing and data structures, every time I set myself to write something more than 100 lines I just get stuck: which language is best for the job? How should I refactor this to be more clear and concise?

My programming life definitely got worse (as a C/Python programmer) after I discovered variants and the Option/Either monads.

As I said to him, ignorance is bliss.

It does get better - write a lot of code with the new language features and you'll get a sense when they're not useful, or how you can apply them to more mundane languages. You can define a decorator in Python to do Maybe monads, for example:

  def maybe(decorated):
    def worker(*args):
      if any(arg is None for arg in args):
        return None
      return decorated(*args)
    # Standard decorator machinery
    return worker
(This doesn't mean you should; this usage is pretty non-idiomatic and will do strange things in edge-cases. That's my point though...the only way to figure out when it's worth it is to try it out in a few situations and determine when it makes the code simpler.)
But that's not what the post you replied to said to do.

The post said to pick one area, research all of the shit right out of it, e.g., focus. Your list (and I assume it's abbreviated) is the opposite of that.

I agree you need to code (and a lot). I disagree (vehemently) that you need to fuck, then un-fuck, your code in order to progress.

Focus helps, of course. But my list (and other reading material..yes, it was abbreviated) was actually pretty focused - it specializes in programming language theory and implementation, particularly for functional programming languages.

The problem with reading a lot before coding is that you learn the knowledge ("what to do") without learning the wisdom ("when to do it). Even if you specialize in one area, there's a large body of practical knowledge that people do unconsciously when they're working on a problem, but don't think to write down in a book. Or if they do write it down in a book, you won't understand the context for it until you've been in several situaions where their advice has both worked and not worked. When I was studying this stuff in college, I read multiple books on each topic, it "clicked", I knew when to use each technique - but I didn't know when not to. As a result, my designs tended to be jam-packed with features. It takes experience to realize "Oh, metaclasses are really handy in this one situation...but most of the time, you are better off banning them because the cost in understanding your code is greater than the code simplification they give you."