Live data from Hacker News

Ask HN: What code have you read recently?

news.ycombinator.com

31–40 of 40 posts

Re: Ask HN: What code have you read recently?

#31
post #25
post #23

Earlier quoted context omitted.

I think on the whole peoples reaction to Code Complete is very much connected to when in their coding career they first come across. If you come across it early in your career while still inexperienced it can completely change your approach to coding for the better. If you come across it later in your career it just seems like a collection of obvious ideas that you already know.

I came across it pretty early, though admittedly I'd read quite a few suggestion articles & management articles prior to it. It's still largely obvious, and super management-oriented. Even the little check-lists at the end of each chapter reek of a manager looking over someone's shoulder, tsk-ing, and marking "flaws" in code, rather than actually being a useful metric of any sort to measure quality against. I can't g…

""Do X, Y, and Z and your code will improve" is something only managers believe"

The thing is, it is absolutely correct for some definitions of X, Y and Z. There are plenty of programmers in the workplace who just suck at constructing code. They don't know how to write good comments, format their code logically and consistently, use good variable and function names, etc. It goes even further: they do not understand why these things are important. I still see plenty of code like this:

bool nothingToDo; // Is there anything to do

....

if (nothingToDo) {

    // We don't need to continue

    return;
}

or

if (time.elapsed() > 10) // If ten seconds or more have passed

{...}

Requests to refactor such code are often met with "This is trivial, just step through the code and figure it out", sometimes from senior programmers (at least in title). And these are not necessarily stupid people, they are often good programmers but not very good software engineers. Have you ever read some of the code open sourced by Google and found yourself thinking "Sheetz, this code is ultra clean"? I bet the people responsible for Google's coding guidelines have read Code Complete. I have been involved in writing coding standards a few times and I referred to Code Complete in each of those instances.

I also completely disagree that this book was written for managers. A manager with no technical background is very likely to dismiss refactoring or code layout as wasted time.

Re: Ask HN: What code have you read recently?

#33
post #25

Earlier quoted context omitted.

I came across it pretty early, though admittedly I'd read quite a few suggestion articles & management articles prior to it. It's still largely obvious, and super management-oriented. Even the little check-lists at the end of each chapter reek of a manager looking over someone's shoulder, tsk-ing, and marking "flaws" in code, rather than actually being a useful metric of any sort to measure quality against. I can't g…

""Do X, Y, and Z and your code will improve" is something only managers believe" The thing is, it is absolutely correct for some definitions of X, Y and Z. There are plenty of programmers in the workplace who just suck at constructing code. They don't know how to write good comments, format their code logically and consistently, use good variable and function names, etc. It goes even further: they do not understand w…

they are often good programmers but not very good software engineers

Agreed. There was a gentleman I had the pleasure of working with years ago who wrote an application in Perl that literally performed an inventory of every switch, router and attached device and did so faster than anything I've seen commercially available.

He quit on negative terms (I can't remember the specifics) and upon examining his code, it was FORTRAN in Perl (http://www.codinghorror.com/blog/2005/04/you-can-write-fortr...).

He was a brilliant individual. Myself and a few of his coworkers enjoyed bouncing ideas off of him, often is areas outside of his expertise. When he didn't have an outright "try this instead", he knew what questions to ask to get us mere mortals to think about the solution differently.

If I didn't know the man better, I would say that he intentionally obfuscated his own code. But I get the impression after reviewing several of his projects that he simply thought differently and that expression was displayed in his work. Unfortunately, it made him an island and all of his projects a one-man effort. His manager didn't know good code from bad and didn't require documentation or review. Nobody could support this guy's code except this guy.

Re: Ask HN: What code have you read recently?

#34
post #25

Earlier quoted context omitted.

I came across it pretty early, though admittedly I'd read quite a few suggestion articles & management articles prior to it. It's still largely obvious, and super management-oriented. Even the little check-lists at the end of each chapter reek of a manager looking over someone's shoulder, tsk-ing, and marking "flaws" in code, rather than actually being a useful metric of any sort to measure quality against. I can't g…

""Do X, Y, and Z and your code will improve" is something only managers believe" The thing is, it is absolutely correct for some definitions of X, Y and Z. There are plenty of programmers in the workplace who just suck at constructing code. They don't know how to write good comments, format their code logically and consistently, use good variable and function names, etc. It goes even further: they do not understand w…

A manager with no technical background is very likely to dismiss refactoring or code layout as wasted time.

But they're very likely to throw the biggest "guaranteed to improve code" book they can find, with the biggest company name on it they can find (Microsoft), at all the programmers under them, whether or not it makes sense. And they're more likely to use the book dogmatically, rather than pragmatically, and much of the book seems structured to encourage this use.

Re: Ask HN: What code have you read recently?

#35
post #2

I had a look at the Haskell Prelude code: http://www.haskell.org/onlinereport/standard-prelude.html Lots of good code in there, especially in regard of simplicity and beauty . If you're diving into functional programming, be sure to have a look at it, even if you're a beginner like I am.

Alternate Haskell Prelude, for how the Haskell Prelude should have been written: http://patch-tag.com/r/jmcarthur/alt-stdlib/snapshot/current...

Nobody actually likes the standard one in its entirety, particularly Num, Monad, etc.

Re: Ask HN: What code have you read recently?

#36
post #34

Earlier quoted context omitted.

""Do X, Y, and Z and your code will improve" is something only managers believe" The thing is, it is absolutely correct for some definitions of X, Y and Z. There are plenty of programmers in the workplace who just suck at constructing code. They don't know how to write good comments, format their code logically and consistently, use good variable and function names, etc. It goes even further: they do not understand w…

A manager with no technical background is very likely to dismiss refactoring or code layout as wasted time. But they're very likely to throw the biggest "guaranteed to improve code" book they can find, with the biggest company name on it they can find (Microsoft), at all the programmers under them, whether or not it makes sense. And they're more likely to use the book dogmatically, rather than pragmatically, and much…

I don't think the book encourages this. There are several instances where it concedes that consistency should take precedence over using the "bestest" practice for example. Also, the dogmatic manager will be dogmatic regardless of the book or standard they use as a reference.
Post reply on HN