Lurker News
Preferably an elegant snippet rather than an entire (well engineered) codebase.

Comments (380) 116 threads

Earlier comments
stillworks#
This is a very open ended question.

For me, lazy as I am, most recursive algorithms operating on binary trees are a thing of beauty. Post-order ones even more so.

anhldbk1 reply#
Well, it's a C macro in Apache Thrift code base [1]

#ifdef __GNUC__
#define TDB_LIKELY(val) (__builtin_expect((val), 1))
#define TDB_UNLIKELY(val) (__builtin_expect((val), 0))
#else
#define TDB_LIKELY(val) (val)
#define TDB_UNLIKELY(val) (val)
#endif
This code is beautiful when it deal with CPU cache-line effects to speed up your program.
[1] https://github.com/apache/thrift/blob/647501693bd14256df8839...

tomtomtom777#
You seem to be referring to the arguably beautiful effect of code.

Are you seriously praising this monstrosity of preprocessor macros, integers used as magic booleans and compiler specific builtins as beautiful code??

drallison#
This 4 instruction 8080/Z80 code sequence converts a 4-bit quantity in the A-register into the equivalent ASCII code: adc 40h
lgas#
I always liked the elegance of this definition of the power set function in Haskell:

  powerSet = filterM (const [True, False])

Load more comments