Ask Slashdot: What Do You Consider Elegant Code? 373
lxrslh writes: "Since the dawn of computing, we have read about massive failed projects, bugs that are never fixed, security leaks, spaghetti code, and other flaws in the programs we use every day to operate the devices and systems upon which we depend. It would be interesting to read the code of a well-engineered, perfectly coded, intellectually challenging program. I would love to see the code running in handheld GPS units that first find a variable number of satellites and then calculate the latitude, longitude, and elevation of the unit. Do you have an example of a compact and elegant program for which the code is publicly available?"
Duff's Device (Score:5, Informative)
Re:Duff's Device (Score:3, Informative)
Uh... that Wikipedia article shows 3 lines of code, which it describes as "straightforward":
Then this reference implementation of Duff's device:
Then this penny drops:
Re:Complete Spectrum Rom Disassembly (Score:4, Informative)
ftp://www.worldofspectrum.org/pub/spectrum/books/CompleteSpectrumROMDisassemblyThe.pdf
GPS code (Score:4, Informative)
http://www.gpstk.org/bin/view/... [gpstk.org]
http://www.rtklib.com/ [rtklib.com]
http://gnss-sdr.org/ [gnss-sdr.org]
Next time do your own google search.
Re:GPS? Are you kidding? (Score:5, Informative)
As someone who has a copyright assignment on file with the FSF for GCC and actually tried to write an implementation of the Visual C++ __declspec(thread) keyword for GCC-on-windows (i.e. proper OS-provided thread-local-storage support) and got lost somewhere deep in the code that actually converts the intermediate representation into assembler (I needed to do stuff to it so it would correctly access the thread-local-storage data when an access to a thread local variable was made) I question your statement that GCC is well-written, elegant or easy to understand...