Hacker News new | past | comments | ask | show | jobs | submit login

Uh...the reasons can vary quite wildly...so I'll stick to one scope: Why does production code suck even when it's been written by competent programmers? I would argue that in a non-trivial system, it becomes difficult to program components that reliably interact with each other. If one team changes the interface to their component, that is not as "deterministic" from your perspective, if the production workflow doesn't have adequate automated testing and so-forth.

In other words, production code can suck because you've failed to anticipate all the non-deterministic things that may interact with your system. Or you may have poorly anticipated them...which can manifest itself in the form of bloated, overly cautious or overly permissable code that becomes too hard to reason with or debug.

But this is moving far away from the original topic of why beginning coders have such problems...sure, when they start working on production code and have to deal with the complexities of the real world, they'll have to adapt. But before they get there, they have to have faith -- at first -- then the ability to confidently reason about code, step by step, in the same way that (hopefully) they've done with math equations...I'm pretty patient when teaching most beginners...but one thing that still sets me off is when someone says, "Well, the code worked 5 minutes ago, and now it doesn't"...and instead of actually thinking through the reasons why that might be (and the reasons could be quite complex, to be honest)...they just accept that as something that just happens with programming. Or even worse, start pasting in random code that worked somewhere else...which literally makes as much sense as adding random digits to an equation to get it to "work".




As someone who was a beginning, community college CS 101 coder at one time, I think focusing on the mechanical, "this code won't compile unless every i is dotted and t is crossed" way of thinking is only half the story. Getting code to compile, after about the 2nd week of class, isn't too hard. Figuring out why your code doesn't give the right result, even when it compiles and runs, is by far a harder skill for new coders to pick up.


Oh I agree, completely -- silent failures can confuse even experienced programmers. But it's very hard to get to the higher-level reasoning, i.e. does this code actually work...if you are continually tripping up on syntax. Moreover, a failure to understand the implications of the syntax can limit your ability to code.

For example, for beginners, it is not immediately evident that the two following code snippets are equivalent:

    a = "Hello world"
    b = a.lower()
    print(b)
and:

    print("Hello world".lower())
This isn't just a problem of recognizing the simple logic...but that when you're new to code, it takes more mental energy -- at first -- to pick apart the symbols and process them efficiently. And that mental energy is largely from the same reservoir that is used to process the higher-level concepts.




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

Search: