News for hackers. Stuff that matters.
Re:Interesting C code by tintin on Friday July 08, 2011 @07:31AM (#2742019)
"in six lines of C"

I'm not impressed. It could be done in 1 line of C when he left out the line-breaks.

I don't think obfuscated code is interesting. It's unreadable. And therefore it's hard to learn something from it.

But it's nice he is explaining the code. Now that is interesting!

Re:Interesting C code by a1k0n on Friday July 08, 2011 @03:36PM (#2743794)
I could have said "in 454 characters of C" but that wouldn't have been as linkbaity. Thanks for clicking!

Yes, the aim was compression (golfing), not obfuscation. Compression of silly ASCII things has been sort of a hobby of mine for a while and I intend to blog about that in particular. Another little compressed snippet is my "email signature" at the bottom of my site root. Try clicking on it.

Re:Interesting C code by chamakits on Friday July 08, 2011 @10:37PM (#2744847)
Both of these (the signature, and the post) are amazing!

....jealous

Re:Interesting C code by huhtenberg on Saturday July 09, 2011 @01:06AM (#2745065)
http://a1k0n.net/2006/09/15/obfuscated-c-donut.html

Jesus Christ. I love you, dude. Your site must have the highest awesomeness-per-bit ratio on the Internet :)

Re:Interesting C code by a1k0n on Saturday July 09, 2011 @01:23AM (#2745084)
Thanks. :) I'm most proud of my IOCCC 2006 winner (the IOCCC organizers announced the winners, but not the actual entries, then disappeared from the planet): http://a1k0n.net/2006/09/20/obfuscated-c-donut-2.html
Re:Interesting C code by Kapelson on Friday July 08, 2011 @08:19AM (#2742120)
I treat obfuscated code as a kind of puzzle. "Given a crazy string of seemingly random semicolons and numbers, can you discover what it does and how it works?" It's like a magic eye puzzle for a programmer.
Re:Interesting C code by nadam on Friday July 08, 2011 @09:40AM (#2742354)
Obfuscation alone is not interesting, but 'code compression' (to achieve something using as few characters as possible) is a very interesting puzzle for the brain I think.
Re:Interesting C code by pavel_lishin on Friday July 08, 2011 @02:10PM (#2743459)
It's called "code golf", and from what I can tell, perl is the undisputed king of golfing languages.

Someone ought to make a quiz page - "is this perl golf, or a cat walking on a keyboard".

Re:Interesting C code by apgwoz on Friday July 08, 2011 @02:41PM (#2743593)
,[.,] is /bin/cat in brainfuck. Though, brainfuck fails miserably at most golfing challenges.
Re:Interesting C code by icebraining on Friday July 08, 2011 @10:35PM (#2744841)
,[.,] doesn't actually concatenate files, though.

Personally, I think that using golf handicapped languages is the only way to keep it interesting. If you can choose the language, it gets too easy. One could even implement 'cat' as a single character, provided his language of choice.

Re:Interesting C code by alecbenzer on Friday July 08, 2011 @01:27PM (#2743319)
"It could be done in 1 line of C when he left out the line-breaks." Yeah, exactly. It's incredibly silly when people "count" lines of code like this. If you want to talk about lines of code in any kind of practical way, the code you're referring to really needs to be at least somewhat sanely formatted according to the conventions of whatever language you're in. Otherwise, any given sample of code can be in {1,2,3,...,# of characters in program} lines of code. You should just count characters (which is the more appropriate thing to do when you're trying to write a compressed program anyway). A metric of lines of code = ceil(characters/80) is weird because a) it's relatively arbitrary (in that it has nothing to do with languages but with the conventions of terminals), and b) it goes against the more common understanding of "lines of code".

/rant

I think compressed (edit: golfed - new word of the day :) code in general is pretty cool, though.

Re:Interesting C code by rcfox on Friday July 08, 2011 @10:28AM (#2742526)
The code isn't obfuscated; it's golfed. (http://codegolf.com/)

I assume the line-breaks are to allow the code to fit within 80 columns to display on most standard terminals. If you look closely, they occur at places you wouldn't expect them to. I'm guessing they were placed by cat and not the author.

Re:Interesting C code by thehelix112 on Friday July 08, 2011 @04:52PM (#2744049)
Agreed.