News for hackers. Stuff that matters.
Re:What happens when you search 'ugly hack' in GitHub by DCKing on Thursday July 17, 2014 @06:16AM (#8046717)
I love the term 'ugly hack'. It's a very short way of saying 'a solution for a problem that assumes too much of the current context in which this component is called, and is guaranteed to break when the context changes'. It also implies 'this is intended to be temporary because I don't feel like doing the proper solution at this moment' which is accompanied with the intent 'we should fix this later' although most people who write it also have the wisdom that that almost never happens.

All of this is expressed in just two words :)

Re:What happens when you search 'ugly hack' in GitHub by madeofpalk on Thursday July 17, 2014 @08:36AM (#8047118)
When I write it it usually means I know it sucks, but I'm reasonably happy with it - but if someone catches me out on it it's ok because I already criticised it myself
Re:What happens when you search 'ugly hack' in GitHub by andrey-p on Thursday July 17, 2014 @10:06AM (#8047564)
Excellently put. It's like lampshading[1], for code.

[1]: http://tvtropes.org/pmwiki/pmwiki.php/Main/LampshadeHanging

Re:What happens when you search 'ugly hack' in GitHub by goblin89 on Thursday July 17, 2014 @07:31AM (#8046910)
In my experience “ugly hack” means any technical debt that spans lines of code, as opposed to components of a system.

(Edited for clarity.)

Re:What happens when you search 'ugly hack' in GitHub by DCKing on Thursday July 17, 2014 @07:39AM (#8046931)
It's actually too general. What I mean with component here can be anything from a line of code to a class hierarchy.

In a sense, using the word 'component' here was an ugly hack. I should have gone for the proper solution and properly define it. You see now that it breaks down when the interpretation changes.

Re:What happens when you search 'ugly hack' in GitHub by goblin89 on Thursday July 17, 2014 @07:50AM (#8046965)
I guess I understand. I objected because I felt you were assuming too much of some context in your definition of “ugly hack” :) I can't imagine using the term “ugly hack” to describe some unfortunate high-level architectural decision.
Re:What happens when you search 'ugly hack' in GitHub by mmahemoff on Thursday July 17, 2014 @07:29AM (#8046901)
It's a worthy practice indeed. Bowing to the virtue of taking on some technical debt instead of deluding oneself that all code must be Pristine.
Re:What happens when you search 'ugly hack' in GitHub by ebiester on Thursday July 17, 2014 @12:14PM (#8048328)
Sometimes, instead of "I don't feel like doing the proper solution," it's "I haven't yet figured out the proper solution," or "A cleaner solution means adding 250 lines of code to address problems we may not have."
Re:What happens when you search 'ugly hack' in GitHub by brudgers on Thursday July 17, 2014 @10:35AM (#8047746)
'Ugly hack' is an ugly hack of 'kludge'.
Re:What happens when you search 'ugly hack' in GitHub by gjm11 on Thursday July 17, 2014 @07:33AM (#8046914)
Some results normalized by overall language popularity. Specifically, the entry in row R and column C is 1000 * (hits for C in language R) / (hits for "the" in language R) or "---" if either the numerator or denominator was small enough not to make the top-10 list on github.

All the scraping was done by hand and the numbers rounded to a limited number of places in the process, so there may very well be mistakes.

[EDIT: oops, initially I failed to paste in the actual data.]

       ugly hack      ugly beautiful       lol       wtf     buggy
   xml       ---       ---    14.330    72.775     2.489       ---
     c     6.348    35.421     0.670     0.768     3.650    32.009
  html     1.359     9.001    34.791     4.233     3.095     5.870
    rb       ---       ---       ---     4.483     3.151       ---
    py     9.051    35.614    28.506       ---    11.135    15.066
   php     3.731     8.333     1.781    39.037     1.792     3.754
   c++     2.851    12.507       ---     0.501   102.657     7.579
    js     6.850    16.826     2.643     2.635     7.406    29.761
Tentative conclusions: Python is ugly-hack-iest and (almost exactly tied with C) ugliest; HTML is most beautiful with Python a close second, XML is lolliest, C++ is WTFiest, and C is buggiest.

Tentative meta-conclusion: these numbers have no value beyond idle amusement. But they idly amused me, so that's OK.

(The weirdest result of the lot, to me, is XML coming top for "lol". If you do the search and click on "XML" on the left you'll see why it is. Lots of instances of what I think are the same file, full of "&lol;" entities. LOL, that's pretty ugly. WTF? An ugly hack, I guess.)

Re:What happens when you search 'ugly hack' in GitHub by BetaCygni on Thursday July 17, 2014 @07:46AM (#8046956)
The &lol; entities are the "Billion laughs" attack: http://en.wikipedia.org/wiki/Billion_laughs
Re:What happens when you search 'ugly hack' in GitHub by BaltoRouberol on Thursday July 17, 2014 @08:18AM (#8047040)
bwhaha that's insane
Re:What happens when you search 'ugly hack' in GitHub by adamc on Thursday July 17, 2014 @08:16AM (#8047035)
I read your table and immediately jumped to a different conclusion: That python programmers are more sensitive to ugly hacks and more likely to call them out. Not saying I'm right, but I don't know that the data can distinguish the hypotheses.
Re:What happens when you search 'ugly hack' in GitHub by brudgers on Thursday July 17, 2014 @10:31AM (#8047727)
Not picking a language fight.

My intuition tells me that if your alternative hypothesis were true, then php programmers have higher standards because they ajudge more code 'ugly and C++ programmers are universally perfectionists...or at least when they are not confused which it appears they usually are.

Just for fun with hypothesizing, does Python's near 50/50 split between 'ugly and 'beautiful suggest a large degree of random use? Or more interestingly, does it suggest there is a tendency to classify middle cases as extreme cases, and is this a result of the community having 'a Pythonic Way?'

Re:What happens when you search 'ugly hack' in GitHub by logicallee on Thursday July 17, 2014 @09:00AM (#8047226)
I immediately felt the same and left a comment. But what would distinguish it is if "Go" had a high proportion of such comments, where "Perl" would have a low one.
Re:What happens when you search 'ugly hack' in GitHub by logicallee on Thursday July 17, 2014 @08:53AM (#8047191)
Could .py have the greatest number of "ugly hacks" because the community's standards for explicit, "beautiful" designs is higher? This would be shown if languages like Go have a much higher prevalence for "ugly hack" than a language like Perl. (Where even core language features, ahem you can complete the thought.)
Re:What happens when you search 'ugly hack' in GitHub by hornetblack on Thursday July 17, 2014 @08:31AM (#8047080)
I literally laughed out loud at C++ in wtf column.
Re:What happens when you search 'ugly hack' in GitHub by steelcm on Thursday July 17, 2014 @08:42AM (#8047138)
There is a namespace in C++ called WTF, which probably accounts for a skew in that column.
Re:What happens when you search 'ugly hack' in GitHub by pfultz2 on Thursday July 17, 2014 @12:57PM (#8048684)
There is a library in C++ called Web Transaction Framework(WTF): https://github.com/belzano/WTF
Re:What happens when you search 'ugly hack' in GitHub by namuol on Thursday July 17, 2014 @06:19AM (#8046727)
Re:What happens when you search 'ugly hack' in GitHub by int19h on Thursday July 17, 2014 @06:42AM (#8046789)
Re:What happens when you search 'ugly hack' in GitHub by chdir on Thursday July 17, 2014 @06:37AM (#8046778)
If you actually look at the details, these terms aren't used in the same context as we might imagine. If there was a way to filter out useless projects, this would get interesting.
Re:What happens when you search 'ugly hack' in GitHub by peaton on Thursday July 17, 2014 @07:48AM (#8046959)
As you said, big grains of salt... It would be probably more helpful if they were normalized by the percentage any particular language is used overall on Github.
Re:What happens when you search 'ugly hack' in GitHub by ntaso on Thursday July 17, 2014 @06:22AM (#8046743)
So, HN's hate-child PHP is funnier, more beautiful, less ugly and less confusing than sexy JavaScript. Although Python rules them all.
Re:What happens when you search 'ugly hack' in GitHub by DCKing on Thursday July 17, 2014 @06:27AM (#8046754)
To be fair, PHP has a well-known problem of a lot of people not being able to properly judge the quality of the code they write ;) [1]

[1] Of course I don't mean you, my dear PHP writing comment reader.

Re:What happens when you search 'ugly hack' in GitHub by girvo on Thursday July 17, 2014 @07:40AM (#8046941)
And no other widely used language has that problem ;)
Re:What happens when you search 'ugly hack' in GitHub by paddyoloughlin on Thursday July 17, 2014 @06:30AM (#8046762)
Python seems to get a leg-up on the beauty stakes thanks to the popularity of the BeautifulSoup library :)
Re:What happens when you search 'ugly hack' in GitHub by watwut on Thursday July 17, 2014 @06:16AM (#8046718)
I love this one - someone made Java annotation for ugly hacks: https://github.com/benpage26/libxron/blob/016dd953a54eacada2...
Re:What happens when you search 'ugly hack' in GitHub by mcv on Thursday July 17, 2014 @09:32AM (#8047378)
That is some real dedication the the Java way.
Re:What happens when you search 'ugly hack' in GitHub by jamesk14022 on Thursday July 17, 2014 @07:16AM (#8046870)
"Fix ugly hack to at least be consistent with itself", haha, this is brilliant.
Re:What happens when you search 'ugly hack' in GitHub by amirmc on Thursday July 17, 2014 @05:48AM (#8046649)
I'd be curious to see if there's a relationship between 'ugly hack' in code commits and the languages being used (though it'd probably say more about the programmer than the language). The bar chart on the left of the page hints that it's possible, but would have to be normalised.

My hypothesis is there'd be no real difference, but it would be fun to explore nonetheless.

Re:What happens when you search 'ugly hack' in GitHub by exabrial on Thursday July 17, 2014 @06:02AM (#8046687)
I would think the left bar would remain accurate. C lets you shoot yourself and people do it. PHP is terrible for a lot of well documented reasons. Javascript is being used for things it originally never envisioned.

The hyped dynamic languages sort of surprise me, with their modern APIs. I'm guessing most of that is poor framework programing.

Finally, Java's numbers? lol. Its a brave new world. If this was 8 years ago in ejb v1.2 Java world have taken the crown.

Re:What happens when you search 'ugly hack' in GitHub by fuzzix on Thursday July 17, 2014 @05:55AM (#8046668)
> I'd be curious to see if there's a relationship between 'ugly hack' in code commits and the languages being used

Perl is not in their list.

Either everything we do is an ugly hack, or everything we do is simple and elegant. :)

Re:What happens when you search 'ugly hack' in GitHub by giancarlostoro on Thursday July 17, 2014 @09:02AM (#8047234)
Or... nobody writes in Perl anymore... or... every Perl developer is a seasoned Perl developer.
Re:What happens when you search 'ugly hack' in GitHub by fuzzix on Thursday July 17, 2014 @09:57AM (#8047517)
Welp, neither of those are true.
Re:What happens when you search 'ugly hack' in GitHub by mysterywhiteboy on Thursday July 17, 2014 @06:06AM (#8046694)
Another fun search on GitHub - looking for the code paradox i.e. this should "never happen".

https://github.com/search?l=c&p=7&q=never+happen&ref=searchr...

Re:What happens when you search 'ugly hack' in GitHub by paddyoloughlin on Thursday July 17, 2014 @06:31AM (#8046765)
Amusingly, a lot of Python's hits appear to be hacking the import logic.

[0]: https://github.com/search?l=python&q=ugly+hack&ref=cmdform&t...

Re:What happens when you search 'ugly hack' in GitHub by KhalPanda on Thursday July 17, 2014 @05:46AM (#8046638)
It looks like ugly hacks are far more popular than clever ones.

https://github.com/search?q=clever+hack&type=Code&ref=search...

Re:What happens when you search 'ugly hack' in GitHub by reidrac on Thursday July 17, 2014 @05:57AM (#8046675)
Look for dirty hacks; still... C way ahead the rest.

Interesting that "ugly" places PHP over Javascript, but "dirty" is the other way around.

I wonder what does it mean. The comments and the "ugly" or "dirty" qualifiers are just part of the perception of the person writing the comment, and they're contributing to spread that perception to others.

What qualifies as "ugly", "dirty" and "clever", or even as "hack", may be quite different depending on the language and the community behind it.

Re:What happens when you search 'ugly hack' in GitHub by leni536 on Thursday July 17, 2014 @06:06AM (#8046695)
Yeah, I don't think "ugly hack" or any other variants is frequent in bash script comments.
Re:What happens when you search 'ugly hack' in GitHub by duiker101 on Thursday July 17, 2014 @05:48AM (#8046652)
because "ugly hack" is a warning to however might want to fiddle with it, clever hack is more just a show off.
Re:What happens when you search 'ugly hack' in GitHub by KhalPanda on Thursday July 17, 2014 @05:50AM (#8046657)
That, and ugly hacks are easier. I was only kidding. :-)
Re:What happens when you search 'ugly hack' in GitHub by hugofirth on Thursday July 17, 2014 @06:14AM (#8046713)
Haha:

https://www.dropbox.com/s/j7rwshax2e9zwln/Screenshot%202014-...

Not even PHP can come within a factor of 5 of C when it comes to ugly hacks.

EDIT: And its not exactly like there is a bias at work: http://goo.gl/ZezFiP

Re:What happens when you search 'ugly hack' in GitHub by torrent-of-ions on Thursday July 17, 2014 @06:19AM (#8046726)
But is it because C programmers make more ugly hacks or that C programmers are more likely to know when they are making an ugly hack?
Re:What happens when you search 'ugly hack' in GitHub by krapp on Thursday July 17, 2014 @08:38AM (#8047126)
I think PHP is more or less just for the web, giving C programmers more ugly hack surface overall.

Also PHP itself is an ugly hack of C anyway.

Re:What happens when you search 'ugly hack' in GitHub by spyder on Thursday July 17, 2014 @06:53AM (#8046820)
There is a bias because there is more C code. The number of repositories doesn't equal to the quantity of code and if you search for general things that are used in both languages frequently then there is always more C results, for example:

https://github.com/search?p=1&q=if+&ref=searchresults&type=C...

https://github.com/search?p=1&q=return+&ref=searchresults&ty...

Re:What happens when you search 'ugly hack' in GitHub by hugofirth on Thursday July 17, 2014 @07:16AM (#8046868)
Fair enough. If there is a bias towards C I would guess it was more due to the situations in which C gets used, than C itself. Talking to a friend who has to try and get the same C/C++ codebase to compile for 6 different platforms (consoles) has been an eye opening experience. That kind of environment is like a slightly warm petri dish for ugly hacks.
Re:What happens when you search 'ugly hack' in GitHub by wildmXranat on Thursday July 17, 2014 @07:29AM (#8046900)
Search for "temporary fix" https://github.com/search?q=temporary+fix&type=Code&ref=sear.... 3 million plus and counting :)
Re:What happens when you search 'ugly hack' in GitHub by mcv on Thursday July 17, 2014 @09:27AM (#8047355)
That also matches with just "fix" or "temporary". This one works better: https://github.com/search?q=%22temporary+fix%22&type=Code&re...

Now to figure out how old these are.

Re:What happens when you search 'ugly hack' in GitHub by zmk_ on Thursday July 17, 2014 @07:37AM (#8046927)
Re:What happens when you search 'ugly hack' in GitHub by miohtama on Thursday July 17, 2014 @06:24AM (#8046749)
Re:What happens when you search 'ugly hack' in GitHub by stared on Thursday July 17, 2014 @08:59AM (#8047221)
I was not surprised to see tex (even though it is not a popular language on GitHub). It seems that one have to resort to (ugly) hacks when dealing with it.

(That said, I love its fruits.)

Re:What happens when you search 'ugly hack' in GitHub by buddha on Thursday July 17, 2014 @08:10AM (#8047020)
Re:What happens when you search 'ugly hack' in GitHub by diminoten on Thursday July 17, 2014 @08:37AM (#8047121)
A modern-day batman might do this search and then submit pull requests which fix the "ugly hacks".
Re:What happens when you search 'ugly hack' in GitHub by xvirk on Thursday July 17, 2014 @07:56AM (#8046980)
it's even better when you search for "temporary hack"

https://github.com/search?q=temporary+hack&type=Code&ref=sea...

Re:What happens when you search 'ugly hack' in GitHub by pnngndclsng on Thursday July 17, 2014 @06:15AM (#8046716)
Simple question: does "ugly hack" mean "a quick fix before relase" ?
Re:What happens when you search 'ugly hack' in GitHub by jobigoud on Thursday July 17, 2014 @06:30AM (#8046763)
It usually means that something out of your control is acting strange and you don't know or can't properly fix it, but you have found a weird workaround that should probably not even work, or an very contrived way to achieve the result.

As one obviously only writes extremely elegant code, it is important to notify the programmer coming after that you were forced to write it this way.

Re:What happens when you search 'ugly hack' in GitHub by karlcoelho1 on Thursday July 17, 2014 @12:14PM (#8048337)
I love how Ruby isn't even included in the list. RUBY THE BEST
Re:What happens when you search 'ugly hack' in GitHub by aadlani on Thursday July 17, 2014 @08:35AM (#8047114)
No ugly hacks in ruby! that's a great news.
Re:What happens when you search 'ugly hack' in GitHub by jonheller on Thursday July 17, 2014 @07:38AM (#8046930)
Surprised CSS isn't on the top of this list
Re:What happens when you search 'ugly hack' in GitHub by JetSpiegel on Thursday July 17, 2014 @06:00AM (#8046683)
400k results for C, the next one is 40k for PHP
Re:What happens when you search 'ugly hack' in GitHub by miohtama on Thursday July 17, 2014 @06:06AM (#8046699)
Looks like Ruby doesn't have ugly hacks.
Re:What happens when you search 'ugly hack' in GitHub by nXqd on Thursday July 17, 2014 @06:51AM (#8046811)
How about 'for now' :D
Re:What happens when you search 'ugly hack' in GitHub by JimmaDaRustla on Thursday July 17, 2014 @08:41AM (#8047136)
Wait...you mean...I find the words "ugly hack" in source files across thousands of projects on GitHub?
Re:What happens when you search 'ugly hack' in GitHub by n0body on Thursday July 17, 2014 @05:55AM (#8046669)
I have no idea why this is on the front page.
Re:What happens when you search 'ugly hack' in GitHub by mkesper on Thursday July 17, 2014 @06:49AM (#8046805)
fun? meta-programming?
Re:What happens when you search 'ugly hack' in GitHub by n0body on Thursday July 17, 2014 @08:55AM (#8047199)
You and I have a very different definition of fun, and meta-programming.
Re:What happens when you search 'ugly hack' in GitHub by kvirani on Thursday July 17, 2014 @05:47AM (#8046645)
Mostly C!