News for hackers. Stuff that matters.
Re:Learn C and build your own Lisp by john_b on Friday April 04, 2014 @11:29AM (#7531981)
In my experience, aliasing numbers to words has never improved any code in any way whatsoever, and sometimes causes more headaches since numbers are easy and natural to reason about numerically (big surprise...), while values such as TWENTYFORTYEIGHT impose more mental overhead and open you up to typos.

It strikes me as a symptom of the "magic numbers are evil witchcraft" religion gone to the extreme. The whole point of banishing magic numbers is to improve code's clarity and robustness to change. I've seen

  #define ZERO 0
and

  #define ONE 1
more times than I care to admit. I have yet to see the value of either change.
Re:Learn C and build your own Lisp by theseoafs on Friday April 04, 2014 @11:40AM (#7532075)
Programmers that replace 0 with ZERO, 1 with ONE, and 2048 with TWENTYFORTYEIGHT are severely misunderstanding why magic numbers are a bad thing in the first place. TWENTYFORTYEIGHT means exactly the same thing as 2048 (that is to say, TWENTYFORTYEIGHT means roughly nothing), but replacing 2048 with a symbolic constant that actually means something (say, BUFFER_SIZE) is a good idea.
Re:Learn C and build your own Lisp by andyroid on Friday April 04, 2014 @11:43AM (#7532117)
I would say ONE_TB is an improvement over 1099511627776 when it comes to "natural to reason about" numbers, but yes, defining ZERO and ONE is moronic.
Re:Learn C and build your own Lisp by nostrademons on Friday April 04, 2014 @05:05PM (#7534384)
A lot of times TiB is spelled 1024 * 1024 * 1024 * 1024 or 1 << 40, relying on compile-time constant folding to compute the final value. I usually find that a lot more readable than remembering the actual number.
Re:Learn C and build your own Lisp by dalke on Friday April 04, 2014 @07:26PM (#7535114)
#define M_PI 3.14159265358979323846 is usually nicer than seeing (and possibly mistyping) those digits of pi each time.
Re:Learn C and build your own Lisp by zenlikethat on Saturday April 05, 2014 @12:05PM (#7537422)
Yeah, we were always taught that zero, one, empty string and other "edge case" values were O.K. to have in code directly. I'm inclined to agree.