News for hackers. Stuff that matters.
Re:Deciphering the Business Card Raytracer by raminf on Sunday September 22, 2013 @02:30AM (#6426004)
#define op operator

#define rt return

Then replacing the corresponding inline tokens shaves off another 25 bytes from the source without affecting the output or (arguably) the readability.

Sorry, my inner obfuscator couldn't resist :-)

Beautiful bit of coding, btw.

Re:Deciphering the Business Card Raytracer by a_e_k on Sunday September 22, 2013 @03:52AM (#6426166)
Thanks, glad you liked it!

Yes, it's true that even more could have been shaved off and I did explore some #defines. As I recall, there were also some other changes I could have made to shave off yet more. Ultimately, I decided against them for two main reasons. First, they'd need to occupy lines by themselves which I felt created a bigger gap at the top that ruined the aesthetics somewhat. I wanted something that would look nice and roughly fill the 1.75 aspect ratio of a typical US business card. Secondly, as noted in my reply to matthew-wegner below, I'd noticed the file size that I had achieved.

Re:Deciphering the Business Card Raytracer by zem on Sunday September 22, 2013 @03:22AM (#6426097)
#defines have to be one to a line, though - in this case, where you're optimising for layout rather than bytes, i'm not sure it would be a net win. counting, there are 5 instances of "operator", so that's a saving of 36 chars versus 40 taken up by the #define (including the whitespace at the end). there are 10 "return"s, so saving 40 chars there just about draws you even.
Re:Deciphering the Business Card Raytracer by phySi0 on Sunday September 22, 2013 @11:50AM (#6426939)
>Then replacing the corresponding inline tokens shaves off another 25 bytes from the source

I dunno, I kinda like the current size.

Re:Deciphering the Business Card Raytracer by fabien_sanglard on Sunday September 22, 2013 @02:32AM (#6426011)
Can you pastebin.com it so we can see what it looks like ?
Re:Deciphering the Business Card Raytracer by raminf on Sunday September 22, 2013 @02:27PM (#6427425)
http://pastebin.com/ktukPBHE

I reformatted it so it would justify right like the original but for some reason Pastebin likes to reflow things.

It turns out the single-character tokens 'u' and 'w' were not being used so repurposing them for the #defines leads to a saving of 46 characters at the cost of an extra line. There are a few other recurring tokens but you hit a point of diminishing return.

One should not, however, lose sight of what an awesomely clever hack the whole thing is. Reminds me of some of the text-flow layouts in old illuminated manuscripts, or the more modern variations here (like the one with the light-bulb): http://www.smashingmagazine.com/2008/02/11/award-winning-new...