Beautiful Codes
I wrote about "Function Art" last night. "Function Art" is beautiful, I think. So tonight, I'd like to write about "Beautiful Codes". What do you think about "Beautiful Codes"? What are "Beautiful Codes"? I mean that "Codes" are programs. I have been working on software for over 25 years. Moreover, I worked for two IT companies and developed several software systems. From my experience in software development, I have some policies to write programs. The most important thing when writing codes is simplicity, I think. Maybe, there are no programmers to object to this idea. But I can't explain the beauty of codes clearly. I think there are some different criteria for beautiful codes.
When I think about "Beautiful Codes", I always remember the "IOCCC". "IOCCC" is the acronym for the International Obfuscated C Code Contest. It's quite an interesting programming contest. In the "IOCCC", one of the most important points is the obfuscation of C codes (programs). But I don't think they are ugly. On the contrary, I think that the C codes of "IOCCC" winners are rather beautiful. They are quite hard to read, though.
For example, I often show the following C codes submitted to the "IOCCC" in 1988. It's quite old, but I strongly feel that the codes are beautiful and the programmer who wrote this code has quite a good sense of programming. The C codes are as follows.
You are probably confused by the above C codes. Can you imagine how to work the above codes? When I looked at the codes first, I couldn't understand the codes at all. At first, I didn't think that it was a program. It looks like an "Ascii Art". But the above codes are real C codes (programs) that can be executed. The answer is that it is a program to return the circular constant "Pi". That's the number 3.141592… When I knew the answer, I was deeply moved and respected its programmer. Probably, I can't think of these obfuscated C codes in my life.
But the above program that answers the circular constant "Pi" is beautiful code? I'm not sure whether the above code is beautiful or not. So I can't tell you what kind of codes are beautiful or not clear.
By the way, the above code is quite old. So it can be complied with a modern C compiler, but the result is not right. In fact, when I executed the above code, it returned the wrong number that was not the circular constant "Pi".