11 ms·
What happens when you search 'ugly hack' in GitHub
- n0body 12y agoI have no idea why this is on the front page.
- JetSpiegel 12y ago400k results for C, the next one is 40k for PHP
- KhalPanda 12y agoIt looks like ugly hacks are far more popular than clever ones. https://github.com/search?q=clever+hack&type=Code&ref=searchresults https://github.com/search?q=clever+hack&type=Code&ref=search...
- reidrac 12y agoLook 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 12y agoYeah, I don't think "ugly hack" or any other variants is frequent in bash script comments.
- duiker101 12y agobecause "ugly hack" is a warning to however might want to fiddle with it, clever hack is more just a show off.
- KhalPanda 12y agoThat, and ugly hacks are easier. I was only kidding. :-)
- kvirani 12y agoMostly C!
- amirmc 12y agoI'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 12y ago> 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 12y agoOr... nobody writes in Perl anymore... or... every Perl developer is a seasoned Perl developer.
- fuzzix 12y agoWelp, neither of those are true.
- exabrial 12y agoI 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.
- mysterywhiteboy 12y agoAnother 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=searchresults&type=Code https://github.com/search?l=c&p=7&q=never+happen&ref=searchr...
- miohtama 12y agoLooks like Ruby doesn't have ugly hacks.
- hugofirth 12y agoHaha: https://www.dropbox.com/s/j7rwshax2e9zwln/Screenshot%202014-07-17%2011.13.10.png 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 http://goo.gl/ZezFiP
- torrent-of-ions 12y agoBut 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 12y agoI 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.
- spyder 12y agoThere 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=Code https://github.com/search?p=1&q=if+&ref=searchresults&type=C... https://github.com/search?p=1&q=return+&ref=searchresults&type=Code https://github.com/search?p=1&q=return+&ref=searchresults&ty...
- hugofirth 12y agoFair 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.
- pnngndclsng 12y agoSimple question: does "ugly hack" mean "a quick fix before relase" ?
- jobigoud 12y agoIt 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.
- DCKing 12y agoI 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 :)
- mmahemoff 12y agoIt'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.
- goblin89 12y agoIn my experience “ugly hack” means any technical debt that spans lines of code, as opposed to components of a system. (Edited for clarity.)
- DCKing 12y agoIt'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.
- goblin89 12y agoI 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.
- madeofpalk 12y agoWhen 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
- watwut 12y agoI love this one - someone made Java annotation for ugly hacks: https://github.com/benpage26/libxron/blob/016dd953a54eacada2c8a00ed1592dee3d63a8be/src/main/java/org/xron/annotations/UglyHack.java https://github.com/benpage26/libxron/blob/016dd953a54eacada2...
- mcv 12y agoThat is some real dedication the the Java way.
- namuol 12y agoPretty 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 12y agoSo, HN's hate-child PHP is funnier, more beautiful, less ugly and less confusing than sexy JavaScript. Although Python rules them all.
- DCKing 12y agoTo 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 12y agoAnd no other widely used language has that problem ;)
- paddyoloughlin 12y agoPython seems to get a leg-up on the beauty stakes thanks to the popularity of the BeautifulSoup library :)
- chdir 12y agoIf 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.
- int19h 12y agoThere's plenty of work for C devs! https://github.com/search?q=todo&type=Code&ref=searchresults https://github.com/search?q=todo&type=Code&ref=searchresults
- miohtama 12y agoMaybe some ducklings too? https://github.com/search?q=ugly+duck&type=Code&ref=searchresults https://github.com/search?q=ugly+duck&type=Code&ref=searchre...
- paddyoloughlin 12y agoAmusingly, 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&type=Code https://github.com/search?l=python&q=ugly+hack&ref=cmdform&t...
- nXqd 12y agoHow about 'for now' :D
- jamesk14022 12y ago"Fix ugly hack to at least be consistent with itself", haha, this is brilliant.
- wildmXranat 12y agoSearch for "temporary fix" https://github.com/search?q=temporary+fix&type=Code&ref=searchresults https://github.com/search?q=temporary+fix&type=Code&ref=sear.... 3 million plus and counting :)
- mcv 12y agoThat also matches with just "fix" or "temporary". This one works better: https://github.com/search?q=%22temporary+fix%22&type=Code&ref=searchresults https://github.com/search?q=%22temporary+fix%22&type=Code&re... Now to figure out how old these are.
- gjm11 12y agoSome 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.)
- BetaCygni 12y agoThe &lol; entities are the "Billion laughs" attack: http://en.wikipedia.org/wiki/Billion_laughs http://en.wikipedia.org/wiki/Billion_laughs
- BaltoRouberol 12y agobwhaha that's insane
- adamc 12y agoI 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.
- zmk_ 12y agoSome hacks are just beautiful! https://github.com/search?q=%22beautiful+hack%22&ref=searchresults&type=Code https://github.com/search?q=%22beautiful+hack%22&ref=searchr...
- jonheller 12y agoSurprised CSS isn't on the top of this list
- xvirk 12y agoit's even better when you search for "temporary hack" https://github.com/search?q=temporary+hack&type=Code&ref=searchresults https://github.com/search?q=temporary+hack&type=Code&ref=sea...
- buddha 12y ago"dirty fix" https://github.com/search?q=dirty+fix&type=Code https://github.com/search?q=dirty+fix&type=Code
- aadlani 12y agoNo ugly hacks in ruby! that's a great news.
- diminoten 12y agoA modern-day batman might do this search and then submit pull requests which fix the "ugly hacks".
- JimmaDaRustla 12y agoWait...you mean...I find the words "ugly hack" in source files across thousands of projects on GitHub?
- stared 12y agoI 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.)
- karlcoelho1 12y agoI love how Ruby isn't even included in the list. RUBY THE BEST