Slashdot Mirror


C Code On GitHub Has the Most "Ugly Hacks"

itwbennett writes: An analysis of GitHub data shows that C developers are creating the most ugly hacks — or are at least the most willing to admit to it. To answer the question of which programming language produces the most ugly hacks, ITworld's Phil Johnson first used the search feature on GitHub, looking for code files that contained the string 'ugly hack'. In that case, C comes up first by a wide margin, with over 181,000 code files containing that string. The rest of the top ten languages were PHP (79k files), JavaScript (38k), C++ (22k), Python (19k), Text (11k), Makefile (11k), HTML, (10k), Java (7k), and Perl (4k). Even when controlling for the number of repositories, C wins the ugly-hack-athon by a landslide, Johnson found.

3 of 264 comments (clear)

  1. File this under "NO SHIT" by darkain · · Score: 5, Interesting

    Seriously guys. File this one under "NO SHIT" - Of course C is going to have the most ugly hacks. Why? Because it is by design able to access a hell of a lot more than other languages. How many languages have direct hardware access? Or inline ASM code? And does the word "hack" in the code really make it an "ugly" hack? Seriously? I wrote a micro-kernel for an ARM platform about a decade ago, and there was an assload of inline ASM code and direct pointer manipulation to access the underlying hardware, there is no other way to do this. Yeah, I'm sure the word "hack" appeared countless times in my code, because that's the general term we use. That doesn't make it "ugly" or bad by any means.

  2. Re:Such is C by Anne+Thwacks · · Score: 4, Interesting
    Some people may not even remember 10, 12, 18, 24, 36 and 60 bit processors.

    For ugly hacks, you can't beat trying to optimise string ops 8 bit bytes on a 60 bit (Cray) processor - they natively used 6-bit chars, and packed four 15 bit instructions in a word, but required jumps to be aligned on a double word boundary to avoid pipeline stalls. Apart from assembler, I think C is probably the only language that could do it at all.

    (I it tried in Fortran and then realised there were better things to do in life).

    --
    Sent from my ASR33 using ASCII
  3. It just shows the self awareness of C coders by 140Mandak262Jamuna · · Score: 3, Interesting
    They are just analyzing mostly comments, not code. Dijkstra gave the prescient warning ages ago: "Always debug the code, not the comment".

    C coders know when they are using ugly hacks and would take a moment to comment it or name the function with the term ugly hack. They realize it is not elegant and make a note so that future developers do not think it is a reference implementation worthy of replication and emulation. It is basically "this is probably not worth copy/paste, do a fresh implementation".

    Other language coders might be using these ugly hacks with pride not knowing anything better.

    --
    sed -e 's/Chuck Norris/Rajnikant/g' joke > fact