Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How Can I Know Whether I Am a Good Programmer?

I was looking at some posts on language execution speeds (e.g. whether one Language was faster then another or vice versa), and the common answer was that it really depends on how good the programmer is.

I was wondering what that actually means. How can I tell bad code from good code?

share|improve this question

migrated from Jan 10 '12 at 13:35

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Mark Trapp Jan 10 '12 at 13:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

experience will teach you to differentiate bad from good.keep programming and ask for opinion on your code.rinse and repeat. – Srinivas Reddy Thatiparthy Jan 10 '12 at 13:34
Languages have value other than their speed. If they didn't, there would be no reason to program in anything other than assembly language. I would encourage you to think about what that value is. Thinking about things like that will grow you as a programmer. – Mike Dunlavey Jan 10 '12 at 13:47
up vote 2 down vote accepted

How can I tell Bad code from Good Code?

There are many warning signs. Some you don't even need to be a programmer to notice

1) Bad or inconsistent formatting.
2) Lots of copy and pasting
3) Lack proper documentation in the code (purpose of the code, who wrote it, etc, not inline code comments)

There are some that you need to be a developer to understand

1) Using anti-patterns
2) Doing things in an inefficient manner
3) making things more complicated than they need to be

And some take time

1) Developer doesn't improve over time
2) Doesn't learn from mistakes
3) Doesn't care about code quality

share|improve this answer

it really depends on how good the programmer is... And I was wondering what that actually means.

It means, in this case, that the programmer knows the language s/he works in, and uses the right (fast) idioms to implement the right (fast) algorithms for the job at hand.

How can I tell Bad code from Good Code?

Learn, learn, learn. Practice, practice, practice. For optimization purposes, learn to use a profiler. Read books like Kernighan and Pike's The Practice of Programming or Bentley's Programming Pearls.

The idea of looking into open source code is very good, I learned many of my tricks that way. Contributing to one might be even better; fix bugs and send patches. In my experience, the OpenBSD folks in particular were always ready to review patches; they're also very careful programmers because of their security requirements.

share|improve this answer

Code is art. You cannot decide whether art is good or bad without making a cultural/political statement. This question should go into the Philosophy section.

Take why the lucky stiff. He wrote code without tests. Other people would cringe at that thought but he is considered an artist, thus he wrote good code.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.