TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

ALL code is ugly

43 pointsby old_soundabout 15 years ago

17 comments

mhansenabout 15 years ago
<p><pre><code> And, regarding "ugly"... ALL code is ugly. Yours, mine, everyone's. Code Is Ugly. Just face it. When someone says "beautiful code", hear "beautiful rotten entrails". The only beautiful code, the most clean code, is no code at all. If it's there, it's ugly. The unfortunate fact of software development is that, in order to create beautiful software, we must use ugly code. </code></pre> The premise that 'all code is ugly' is never really substantiated.<p>I believe code that accurately and clearly portrays the algorithm is beautiful code. For example, quicksort in Scala is concise, and reads like the mathematical description of the algorthm:<p><pre><code> def sort(xs: Array[Int]): Array[Int] = { if (xs.length &#60;= 1) xs else { val pivot = xs(xs.length / 2) Array.concat( sort(xs filter (pivot &#62;)), xs filter (pivot ==), sort(xs filter (pivot &#60;))) } }</code></pre>
评论 #1344332 未加载
评论 #1344046 未加载
评论 #1344391 未加载
评论 #1344047 未加载
评论 #1344481 未加载
评论 #1344408 未加载
edw519about 15 years ago
I always thought that code is like babies' diapers.<p>I'll change my own. I'm so used to the smell, it don't even notice it anymore.<p>You change your own. It smells so bad my eyes are watering.
评论 #1344341 未加载
评论 #1344082 未加载
fragmedeabout 15 years ago
As contrived as those examples are, Python does have one feature that I currently miss, which is that trailing commas are ignored.<p><pre><code> mylist = [ "ape", "bat", "cat", ]</code></pre>
评论 #1344164 未加载
评论 #1344031 未加载
评论 #1344058 未加载
chokmaabout 15 years ago
"If you disagree, then apparently, "clean" just means "looks like what I saw yesterday and the day before"."<p><pre><code> Well , sometimes the way it was done yesterday simply _is_ the right way to do it . Of course , one can occasionally try to challenge fundamental grammatical conventions like putting punctuation on the end of a sentence instead of the front of a line . To me , "clean" or "beautiful" code is both easy to read and understand and follows the conventions and best practices that have proven themselves over and over .</code></pre>
pradocchiaabout 15 years ago
Comma-first is beautiful! Comma-first is <i>functional</i>.<p>When we make lists, do we put the * at the end, or up front? Comma-first serves the same purpose. It delimits a new entry. <i>"here is a new entry! here is another!"</i><p>Comma-first is column aligned with the least about of white space. It visually identifies the list as such, set apart from other code. Easy to parse, easy to skim, easy to elide, depending on your need.
rbonvallabout 15 years ago
If separators are meant to be put before each item, as in comma-first style, they shouldn't have been commas in the first place. Commas should be used just like they're used in natural written language. If I were to design a language that uses comma-first style, I'd replace commas with bullets:<p><pre><code> var a = "ape" • b = "bat" • c = "cat" • d = "dog"</code></pre>
Pheterabout 15 years ago
"Note how the errors pop out in the comma-first style."<p>So what? Any decent IDE will highlight this error for you anyway.
评论 #1344040 未加载
tethaabout 15 years ago
What a misleading title. This is about putting commas in array initializations before the next line or after the last line and argues that ALL code is ugly, so it does not matter if it looks akward.
评论 #1344009 未加载
dmoneyabout 15 years ago
In determining the best coding style, ease of spotting errors is one thing to consider. Another is ease of interpreting correct behavior. At a glance, comma-first is harder, but that may just be because I'm used to comma-last.
vital101about 15 years ago
Sure code is ugly. So is paint when it's sitting in it's container. But when used by someone with skill, great works of art are created. Same goes for code. Out of context it's ugly, but what it creates is beautiful.
k33nabout 15 years ago
These examples are ridiculous.
评论 #1344101 未加载
mvandemarabout 15 years ago
I disagree with the title statement, as there is little in life more subjectively judged than beauty, but the post itself is very well written.
IgorPartolaabout 15 years ago
I've sometimes had my moments where I thought "no code could ever look good". If you read enough DailyWTF-like resources you'll gain a sense of pessimism about code.<p>My humble attempt to find some code that's pleasant to look at: <a href="http://lovelyco.de" rel="nofollow">http://lovelyco.de</a>.
Tichyabout 15 years ago
All code is ugly, but some code is uglier than other code.
st3fanabout 15 years ago
Not mine.
apphackerabout 15 years ago
jslint solves all of these problems.
david927about 15 years ago
<i>ALL code is ugly. Yours, mine, everyone's. Code Is Ugly.</i><p>I couldn't agree more. It's 2010 and we're using text files to describe rules. We're using text files to describe data.<p>My God. Everyone just stop what we're doing and look at your code. Look at it! It's worse than ugly; it's monstrously stupid. It's idiotic to a degree that beggars the mind. And here we are, in 2010, ignoring the elephant in the room: that code, the way we do it, is petulantly retarded.
评论 #1344064 未加载
评论 #1344056 未加载
评论 #1344043 未加载
评论 #1344030 未加载
评论 #1343982 未加载