Live data from Hacker News

A Million Lines of Bad Code

varianceexplained.org

41–50 of 123 posts

Re: A Million Lines of Bad Code

#41

You have to have thick skin in the programming industry. Because you're surrounded by what might be the world's worst communicators, programmers. We can tell the machine exactly what to do, but our social IQs tend to suffer on the whole.

Worth remembering that there are two ends to every communication, and either end can screw up.

Re: A Million Lines of Bad Code

#42

> Building a string with a series of concatenations like this is extremely inefficient No. Not in Java since 1999 or so.

Factually incorrect. Creating new strings by concatenation requires reallocation because Strings are immutable in java. Using a Builder is over 700x faster:

Concat code: http://pastebin.com/CcezmJbf

Builder code: http://pastebin.com/Dd6kzcKa

Results, using JRE 7:

> time java concat data.blk Finished. java foo data.blk 170.08s user 1.52s system 102% cpu 2:48.12 total

> time java builder data.blk Finished. java builder data.blk 0.30s user 0.05s system 151% cpu 0.230 total

Re: A Million Lines of Bad Code

#43

Earlier quoted context omitted.

"Hey pretty cool program! Its a great start. I bet we can make it run faster if we changed the way files are imported to something like this... nice work" I usually hear this referred to as a "criticism sandwich": Criticism surrounded on either side with compliments.

We Brits are the masters of allusive and indirect speech, and I would automatically automatically strip of both pieces of bread translate that to "you're reading in files wrong".

Yes, I would automatically parse the "bread" as being boilerplate politeness -- but as with most forms of politeness, I would probably feel differently about the speaker if it wasn't there.

Re: A Million Lines of Bad Code

#44
post #6

I recently read the book "How to Win Friends & Influence People", bad title great book. My main take away from this is I've been talking to people really badly for the last 27 years. I wish I had read this book in middle school. But this blog reminded me of some of the concepts from the book, its far more productive to give positive encouragement than to give negative feedback, and just adding a complement isn't enou…

Hah, nice to hear that famous book (which I've never read so far) coincides with my understanding and behavior. The only motivation for me is that I value people and their feelings much more than any other thing. To be honest, it is not planned or contrived... It is just a natural feedback.

Re: A Million Lines of Bad Code

#45
I have here some 10 year old C++ code I've written lying around. It's pretty terrible style-wise, but not as bad as I imagine it to be without looking at it.

But the main point is that it worked in production for years. I would have written it much better today, and it will probably work faster and be easier to maintain. But it would also probably take longer to develop (though less time to debug and stabilize) - and ultimately, it would do the same work in production.

I'm not saying that improving your coding style and skills is not important. Just that we need to keep our eye on the ball - which is delivering working software, not code.

Re: A Million Lines of Bad Code

#46
post #6

I recently read the book "How to Win Friends & Influence People", bad title great book. My main take away from this is I've been talking to people really badly for the last 27 years. I wish I had read this book in middle school. But this blog reminded me of some of the concepts from the book, its far more productive to give positive encouragement than to give negative feedback, and just adding a complement isn't enou…

When I read that book by Dale Carnegie one think struck me. Aside from being well with words and advice he never succeeded in his own life. Two divorces and almost no friends at the end of his life.

General advice is easy to give. There are millions of tiny details which tend to guide you away.

Re: A Million Lines of Bad Code

#47

> Building a string with a series of concatenations like this is extremely inefficient No. Not in Java since 1999 or so.

I built a string this way in java just 5 years ago. Still made it 100x times faster by using a StringBuilder.

So like 1ms down from 100ms? Either way a rounding error in the episode-of-LOST-average-duration timescale ;)

Re: A Million Lines of Bad Code

#48

> Building a string with a series of concatenations like this is extremely inefficient No. Not in Java since 1999 or so.

Factually incorrect. Creating new strings by concatenation requires reallocation because Strings are immutable in java. Using a Builder is over 700x faster: Concat code: http://pastebin.com/CcezmJbf Builder code: http://pastebin.com/Dd6kzcKa Results, using JRE 7: > time java concat data.blk Finished. java foo data.blk 170.08s user 1.52s system 102% cpu 2:48.12 total > time java builder data.blk Finished. java builder…

What about the time to write the program?

Re: A Million Lines of Bad Code

#49
post #6

I recently read the book "How to Win Friends & Influence People", bad title great book. My main take away from this is I've been talking to people really badly for the last 27 years. I wish I had read this book in middle school. But this blog reminded me of some of the concepts from the book, its far more productive to give positive encouragement than to give negative feedback, and just adding a complement isn't enou…

This is helpful for sure, but it's also very useful to work on having a thick enough skin to take insulting feedback in a positive fashion. After all, the only way someone can offend you is if you let them.

>This is helpful for sure, but...

You did this on purpose, didn't you. ;)

Re: A Million Lines of Bad Code

#50
post #6

I recently read the book "How to Win Friends & Influence People", bad title great book. My main take away from this is I've been talking to people really badly for the last 27 years. I wish I had read this book in middle school. But this blog reminded me of some of the concepts from the book, its far more productive to give positive encouragement than to give negative feedback, and just adding a complement isn't enou…

Don't you feel patronized when people do that though? Be as rude as you want to me, as long as you're correct. As for myself, I tend to not call out the positive parts of something, because that's sort of implicit. I would not bother to point out that the file reading code is wrong if the whole thing was broken. I admit I'm probably incorrect here, but I notice people try this "say something positive" and it really c…

I strongly agree. Sentence formulas are a hack. The actual advice should be, believe something positive. Specifically, believe that the person is basically smart but just didn't know X. That leads to natural utterances like:

"Sweet! Uh...that run time is pretty terrible though. Don't worry, let's see what's up with that. (Twenty seconds later:) Ohhhhhhhhh, ha, ok, check this out."

The novice coder knows they suck. They're not really worried about that because, well, they're still here. What they are worried about is that you'll write them off. So don't.

Post reply on HN