Live data from Hacker News

Interesting C code

a1k0n.net

1–10 of 31 posts

Re: Interesting C code

#2
Interesting indeed. But weird that he uses obfuscated code when doing a piece of explaining how it's done. Or do people actually write for loops like those? :P

Re: Interesting C code

#3
"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

#5
post #3

"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!

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

#7
post #4

'warnings which real programmers ignore' ... That tells me pretty much all I needed to know about that article.

In case you're wondering...

  $ gcc -o yanim yanim.c -lm
  yanim.c:1:1: warning: data definition has no type or storage class [enabled by default]
  yanim.c: In function ‘main’:
  yanim.c:5:24: warning: incompatible implicit declaration of built-in function ‘cos’ [enabled by default]
  yanim.c:5:33: warning: incompatible implicit declaration of built-in function ‘sin’ [enabled by default]

Re: Interesting C code

#8
post #3

"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!

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

#10
post #3

"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!

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.

Post reply on HN