当你编码时你在做什么:谈编程的本质(一)状态机
这学期学习了两门有意思的课,Theory of Computation和Distributed System,一低一高完全两个层次上的分支,却意外地发现两者在理论方面的重叠——那就是状态机。在Theory of Computation中,DFA、NFA、Turing Machine都是非常经典的State Machine,而在Distributed System中,Global State的确定、一致性协议的Replicated State Machine等处,又再次看到了它的身影。
于是搜到了图灵奖大牛Lamport的一篇论文《Computation and State Machines》,讲述了无所不能的State Machine。下面对这篇note中触及编程本质的几处做下摘录,句句经典:
1. Think Better, Code Better
“I believe that the best way to get better programs is to teach programmers how to think better. Thinking is not the ability to manipulate language; it’s the ability to manipulate concepts. Computer science should be about concepts, not languages. But how does one teach concepts without getting distracted by the language in which those concepts are expressed? My answer is to use the same language as every other branch of science and engineering—namely, mathematics.”
“The obsession with language is a strong obstacle to any attempt at unifying different parts of computer science. When one thinks only in terms of language, linguistic differences obscure fundamental similarities. Simple ideas can become complicated when they must be expressed in a particular language.”
Lamport认为想要让程序员写出更好的代码,不是天天教他们如何使用语言,而是如何更好地思考,而思考也不是使用编程语言的能力,而是操纵概念