Coding: Obfuscation vs Elegance

There is a joy in being opaque and mysterious because it makes you seem smart and cool for knowing something that nobody knows. Programming in high-level languages like C and Java don’t really give you the same kind of obfuscioness as programming in Assembly (PIC microcontroller, anyone?). However, for awhile people have been injecting complexity into their high level programming languages for the sake of creating hyper-baffling code.

Python was a wonderful discovery for me because they purposely turn away from this tendency to worship esotericity and writing obfuscated code.  It’s a beautiful thing to goto a forum and search “How to Program X in Python.” Instead of just getting the correct result, someone will usually try to find the most correct and elegant result. So here I will try to adhere to these great guidelines and I will reproduce the Python Zen below (you can find it just by typing python >> import this):

#The Zen of Python
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: