News for hackers. Stuff that matters.
Re:The Most Beautiful Piece of Code That Prints 42 by _kst_ on Sunday May 13, 2018 @05:24PM (#17061119)

    #include <stdio.h>

    #define SIX 1+5
    #define NINE 8+1

    int main(void)
    {
        printf("%d * %d = %d\n", SIX, NINE, SIX * NINE);
        return 0;
    }
https://github.com/Keith-S-Thompson/42
Re:The Most Beautiful Piece of Code That Prints 42 by andrewflnr on Sunday May 13, 2018 @06:40PM (#17061407)
I never thought code could make me feel like this.
Re:The Most Beautiful Piece of Code That Prints 42 by thezilch on Sunday May 13, 2018 @08:30PM (#17061854)
Nice.
Re:The Most Beautiful Piece of Code That Prints 42 by dynamicvariable on Sunday May 13, 2018 @07:31PM (#17061609)
Ever waste days debugging a subtle bug introduced by C macros? It's PTSD material.

I love C but I will never understand why C has a naive macro system.

Re:The Most Beautiful Piece of Code That Prints 42 by anitil on Sunday May 13, 2018 @09:03PM (#17061960)
I always thought it was a historical choice that simple substitution languages were simpler to implement so were chosen as a default.

It is kind of infuriating that the preprocessor always feels simultaneously _too powerful_ and _not powerful enough_ for the jobs you want to get done. I find myself reaching for other tools (kaitai, m4 etc) a lot more these days to take the role.

Re:The Most Beautiful Piece of Code That Prints 42 by dexen on Monday May 14, 2018 @03:19AM (#17063467)
The kenc[1] compiler subsequent to K&R C had much more constrained macro system exactly for those reasons. Thanks to advances in optimization and improved machine speed, it was reasonable to skip preprocessor-level const operations. Thanks to dead code elimination it was feasible to mostly give up conditional compilation.

[1] as used, for example, in Plan 9.

Re:The Most Beautiful Piece of Code That Prints 42 by jurjenh on Sunday May 13, 2018 @07:59PM (#17061732)
Could be "improved"

  #define SIX 1+8
  #define NINE 5+1