[Klug-general] Obscure C at saturday's meeting

Kevin Groves kgroves at ksoft-electrical-projects.co.uk
Wed Dec 1 13:17:40 UTC 2010


This reminds of some C code a mate showed me back in the late '80s from 
one of the UNIX flavours at the time. One was some nasty code in 
crypt.c, the worst was a 150 character single line (with no spaces) from 
somewhere inside the task scheduler.

There was serious use of nested:

     a ? b : c

conditions, a good number of using pointer to function array calls. And 
some other hideous things with for loops and inc/decs.

OK I understand that in the scheduler you want good performance and 
compact code to get the most out of it, but some things were never meant 
to be written.

Kev,


On 30/11/10 06:34, Thomas Edward Groves wrote:
> Actually I've never seen a language that doesn't allow the most 
> horrible spaghetti.
> It's just that some languages make it easy.
> On the other hand the languages which make it hard to write crap also 
> make it
> hard to write stuff that the designers of that language hadn't thought of.
> C was designed to let the programmer have all the rope he wanted,
> that's why we so often hang ourselves when using it.
> It's also why some of us so often return to it too.
> And as for code beautifiers: they're the most valuable tool that never 
> gets mentioned
> in books on programming that I know of.
> Odd that.
> Tom
>
>     ----- Original Message -----
>     *From:* Peter Childs <mailto:pchilds at bcs.org>
>     *To:* Kent Linux User Group - General Topics
>     <mailto:kent at mailman.lug.org.uk>
>     *Sent:* Monday, November 29, 2010 2:46 PM
>     *Subject:* Re: [Klug-general] Obscure C at saturday's meeting
>
>
>
>     On 29 November 2010 14:35, David Halliday
>     <david.halliday at gmail.com <mailto:david.halliday at gmail.com>> wrote:
>
>         There is a reason why C as a language does lean beautifully to
>         code obfuscation. We all know that C was just a joke that has
>         got out of hand, alongside the base of all *nix environments:
>         http://www.asandler.com/jokes/computer/c.shtml
>
>         From The Article:
>         We stopped when we got a clean compile on the following syntax:
>         for(;P("\n"),R-;P("|"))for(e=C;e-;P("_"+(*u++/8)%2))P("|"+(*u/4)%2);
>
>         To think that modern programmers would try to use a language
>         that allowed such a statement was beyond our comprehension!
>
>
>     Perl has a reputation for this too.....
>
>     Peter.
>
>
>
>         On 29 November 2010 12:53, Dan Attwood <danattwood at gmail.com
>         <mailto:danattwood at gmail.com>> wrote:
>
>
>
>                 And for exactly this reason there has been a policy in
>                 places I have worked of running any C code through the
>                 C beautifier automatically as part of the version
>                 control check-in process.  This has the advantage that
>                 coders arbitrarily rearranging the code in their
>                 preferred style whilst editing does not look like a
>                 change, and that all code retrieved is always in the
>                 house style, which makes for easier debugging.
>
>             someone at barcamp was talking about do just this.
>             Although they went one step further where if it fell
>             outside of some rules then they would stop it from
>             compiling and spit it back at the developer
>
>             _______________________________________________
>             Kent mailing list
>             Kent at mailman.lug.org.uk <mailto:Kent at mailman.lug.org.uk>
>             https://mailman.lug.org.uk/mailman/listinfo/kent
>
>
>
>         _______________________________________________
>         Kent mailing list
>         Kent at mailman.lug.org.uk <mailto:Kent at mailman.lug.org.uk>
>         https://mailman.lug.org.uk/mailman/listinfo/kent
>
>
>     ------------------------------------------------------------------------
>     _______________________________________________
>     Kent mailing list
>     Kent at mailman.lug.org.uk
>     https://mailman.lug.org.uk/mailman/listinfo/kent
>
>
> _______________________________________________
> Kent mailing list
> Kent at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/kent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/kent/attachments/20101201/7e8ca554/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kgroves.vcf
Type: text/x-vcard
Size: 319 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/kent/attachments/20101201/7e8ca554/attachment.vcf>


More information about the Kent mailing list