
What happens when you search 'ugly hack' in GitHub - BaltoRouberol
https://github.com/search?q=ugly+hack&ref=cmdform&type=Code
======
DCKing
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 :)

~~~
madeofpalk
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

~~~
andrey-p
Excellently put. It's like lampshading[1], for code.

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

------
gjm11
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.)

~~~
adamc
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.

~~~
brudgers
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?'

------
namuol
Pretty interesting/amusing to see the language breakdown of various words
(with big grains of salt):

[https://github.com/search?q=beautiful&type=Code](https://github.com/search?q=beautiful&type=Code)

[https://github.com/search?q=ugly&type=Code](https://github.com/search?q=ugly&type=Code)

[https://github.com/search?q=lol&type=Code](https://github.com/search?q=lol&type=Code)

[https://github.com/search?q=wtf&type=Code](https://github.com/search?q=wtf&type=Code)

~~~
ntaso
So, HN's hate-child PHP is funnier, more beautiful, less ugly and less
confusing than sexy JavaScript. Although Python rules them all.

~~~
DCKing
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.

~~~
girvo
And no other widely used language has that problem ;)

------
watwut
I love this one - someone made Java annotation for ugly hacks:
[https://github.com/benpage26/libxron/blob/016dd953a54eacada2...](https://github.com/benpage26/libxron/blob/016dd953a54eacada2c8a00ed1592dee3d63a8be/src/main/java/org/xron/annotations/UglyHack.java)

~~~
mcv
That is some real dedication the the Java way.

------
jamesk14022
"Fix ugly hack to at least be consistent with itself", haha, this is
brilliant.

------
amirmc
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.

~~~
fuzzix
> 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. :)

~~~
giancarlostoro
Or... nobody writes in Perl anymore... or... every Perl developer is a
seasoned Perl developer.

~~~
fuzzix
Welp, neither of those are true.

------
mysterywhiteboy
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...](https://github.com/search?l=c&p=7&q=never+happen&ref=searchresults&type=Code)

------
paddyoloughlin
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...](https://github.com/search?l=python&q=ugly+hack&ref=cmdform&type=Code)

------
KhalPanda
It looks like ugly hacks are far more popular than clever ones.

[https://github.com/search?q=clever+hack&type=Code&ref=search...](https://github.com/search?q=clever+hack&type=Code&ref=searchresults)

~~~
reidrac
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.

~~~
leni536
Yeah, I don't think "ugly hack" or any other variants is frequent in bash
script comments.

------
hugofirth
Haha:

[https://www.dropbox.com/s/j7rwshax2e9zwln/Screenshot%202014-...](https://www.dropbox.com/s/j7rwshax2e9zwln/Screenshot%202014-07-17%2011.13.10.png)

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](http://goo.gl/ZezFiP)

~~~
torrent-of-ions
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?

~~~
krapp
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.

------
wildmXranat
Search for "temporary fix"
[https://github.com/search?q=temporary+fix&type=Code&ref=sear...](https://github.com/search?q=temporary+fix&type=Code&ref=searchresults).
3 million plus and counting :)

~~~
mcv
That also matches with just "fix" or "temporary". This one works better:
[https://github.com/search?q=%22temporary+fix%22&type=Code&re...](https://github.com/search?q=%22temporary+fix%22&type=Code&ref=searchresults)

Now to figure out how old these are.

------
zmk_
Some hacks are just beautiful!
[https://github.com/search?q=%22beautiful+hack%22&ref=searchr...](https://github.com/search?q=%22beautiful+hack%22&ref=searchresults&type=Code)

------
miohtama
Maybe some ducklings too?

[https://github.com/search?q=ugly+duck&type=Code&ref=searchre...](https://github.com/search?q=ugly+duck&type=Code&ref=searchresults)

------
stared
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.)

------
buddha
"dirty fix"
[https://github.com/search?q=dirty+fix&type=Code](https://github.com/search?q=dirty+fix&type=Code)

------
diminoten
A modern-day batman might do this search and then submit pull requests which
fix the "ugly hacks".

------
xvirk
it's even better when you search for "temporary hack"

[https://github.com/search?q=temporary+hack&type=Code&ref=sea...](https://github.com/search?q=temporary+hack&type=Code&ref=searchresults)

------
pnngndclsng
Simple question: does "ugly hack" mean "a quick fix before relase" ?

~~~
jobigoud
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.

------
karlcoelho1
I love how Ruby isn't even included in the list. __RUBY THE BEST __

------
aadlani
No ugly hacks in ruby! that's a great news.

------
jonheller
Surprised CSS isn't on the top of this list

------
JetSpiegel
400k results for C, the next one is 40k for PHP

------
miohtama
Looks like Ruby doesn't have ugly hacks.

------
nXqd
How about 'for now' :D

------
JimmaDaRustla
Wait...you mean...I find the words "ugly hack" in source files across
thousands of projects on GitHub?

------
n0body
I have no idea why this is on the front page.

~~~
mkesper
fun? meta-programming?

~~~
n0body
You and I have a very different definition of fun, and meta-programming.

------
kvirani
Mostly C!

