Skip to main content

Timeline for How do you define elegant code?

Current License: CC BY-SA 3.0

17 events
when toggle format what by license comment
Apr 14, 2016 at 19:26 comment added HelloWorld @PéterTörök The question is about elegant code which does not exist, why do you answer with: "good code should be clean". Clean code does not exist. Dirty code not either. These are the wrong terms to describe quality of code.
Mar 26, 2014 at 18:18 comment added clearscreen @ReiMiyasaka - The question is "how do you define elegant code?" - which is basically asking for opinions on what makes code elegance. Peter exposed his point of view in that elegance is defined by many things, and that one of them is simplicity. You can argue you don't agree but you can't argue that his opinion is wrong. BTW: I agree in that I see no elegance unless there's simplicity.
Aug 4, 2011 at 11:49 comment added Rei Miyasaka @Péter The question title says quite clearly, "how do you define elegant code?", so it's pretty obvious that we're discussing the difficult task of defining what makes code elegant. Just because you know good music when you hear it doesn't mean you have an understanding of harmony, so this question is clearly not as easy as people make it seem. Either way, I don't see what the distinction between creating and recognizing elegant code has to do with the distinction between elegant code and good code.
Aug 4, 2011 at 8:29 comment added Péter Török @Rei, to me you seem to be confusing the issues of creating elegant code and recognizing it. The former is a long and arduous task, as I have noted in my answer above. The latter is "sort of" easy - as several comments and answers said, "I know it when I see it". However, defining what makes code elegant is much more difficult than simply recognizing it. IMHO simplicity is an inherent part of it - elegant code manages to uncover a so far hidden element or view of a previously complex problem, thus making it simpler and easier to understand.
Aug 4, 2011 at 6:14 comment added Nash0 Very well said. Simplicity and readability are where it's at :)
Aug 4, 2011 at 0:10 comment added Rei Miyasaka @Nick The definition of elegance is multi-faceted. What's efficient might not have the best complexity profile; what has the best complexity profile might not be the most legible; what's legible might not be the most conceptually minimal -- yet all these things contribute to the idea of elegance. The question of elegant code isn't as simple as these answers make it seem, and I don't claim to have an answer either -- but at the very least it's a mistake to confuse it with "good code".
Aug 3, 2011 at 22:30 comment added Nick Hodges Rei -- I think you have it exactly backwards. Readability is a requirement of elegance.
Aug 3, 2011 at 21:05 comment added Rei Miyasaka @temptar Good code and elegant code are two different things. Elegant code can be impossible to read (x ^= y ^= x ^= y) or extremely inefficient (purely functional quicksort). To speak of the two as the same is not only imprecise, it encourages elegance when there are more important values in question.
Aug 3, 2011 at 14:25 comment added sabertooth Simplicity is the pre-requisite of reliability. ~Edsger W. Dijkstra
Aug 3, 2011 at 14:03 history edited Michael Haren CC BY-SA 3.0
linkified the book (not an affiliate link!)
Aug 3, 2011 at 13:36 comment added temptar Rei, I disagree, or maybe it's that I want this to be the answer when for many other people it is not. Ultimately, I have a concern with people describing code as elegant when really all it is is code that is too clever and exclusionary.
Aug 3, 2011 at 13:35 vote accept temptar
Aug 3, 2011 at 5:21 comment added Rei Miyasaka -1 to both this and the other popular answer. They describe good code, not elegant code. They aren't answering the question.
Aug 2, 2011 at 18:05 history made wiki Post Made Community Wiki by user33201
Aug 2, 2011 at 16:29 comment added SoylentGray Not to mention if you are going to do something clever it should be WELL documented. 2 Years from now you are probably not going to be around to ask questions of or at least you should not have to answer questions about your old code.
Aug 2, 2011 at 13:52 history edited Péter Török CC BY-SA 3.0
added 99 characters in body
Aug 2, 2011 at 13:40 history answered Péter Török CC BY-SA 3.0