2019年8月19日 星期一

Phthon (程式語言) 的禪學思想

資訊科技日益,環視今日程式語言發展, Python 具有易學易用的特色可以說是初學者者最佳首選(Python 排名最熱門的程式語言第一名)。這個程式語言 於1991年出現, 二十幾年來都沒有受到重視,直到最近因為市場需求突然受人青睞。 Python 原始發展者 Tim Peters在 Python ( 外加套件) 中暗藏他發展 Python 的禪學思想,非常有意思。在提示符號 >>> 底下打 import this 會列出一段英文,我們將這段英文翻成中文,看看 Python 作者對禪學思想的推崇 ! >>> import this The Zen of Python, by Tim Peters 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! ----------------(中譯)-------------------------- Tim Peters的Python之禪 美麗勝過醜陋。 顯式優於隱式。 簡單比複雜更好。 複雜比複雜更好。 平淡優於嵌套。 稀疏優於密集。 可讀性很重要。 特殊情況不足以打破規則。 雖然實用性勝過純潔。 錯誤不應該默默地傳遞。 除非明確沉默。 面對模棱兩可,拒絕猜測的誘惑。 應該有一個 - 最好只有一個 - 明顯的方法來做到這一點。 雖然這種方式起初可能並不明顯,除非你是荷蘭人。 現在比永遠好。 雖然現在永遠不會比*正確*好。 如果實施很難解釋,這是一個壞主意。 如果實現很容易解釋,那可能是個好主意。 命名空間是一個很棒的主意 - 讓我們做更多的事情吧! -------------------------------------------------

沒有留言:

張貼留言