Notes on Programming

by Alexander Stepanov

内容比较多,都是关于如何设计良好接口以及通用算法的,对于吸引不是特别大。我只是粗略地看了一章,有几段话感觉挺有共鸣的,就摘抄在这里

C++两大特点:操作机器以及抽象能力

In this book I will use C++. The main reason for that is that it is combines two essential characteristics: being close to the machine and powerful abstraction facilities. I do not believe that it is possible to write a book that I am trying to write without using a real programming language. And since I am strongly convinced that the purpose of the programming language is to present an abstraction of an underlying hardware C++ is my only choice. Sadly enough, most language designers seem to be interested in preventing me from getting to the raw bits and provide “better” machine than the one inside my computer. Even C++ is in danger of being “managed” into something completely different.

了解底层是个好习惯,但是不要永远地待在那里,必须向上进行抽象。抽象可以让你思考得更加清楚。

Starting at the bottom, even at the level of individual instructions, is important. It is, however, equally important not to stay at the bottom but always to proceed upwards through a process of abstraction. I believe that every interesting piece of code is a good starting point for abstraction. Every so-called “hack,” if it is a useful hack, could serve as a base for an interesting abstraction.

现代程序员基本上不需要学习如何编写编译器,相反更应该了解编译器做了些什么事情。

It is equally important for programmers to know what compilers will do to the code they write. It is very sad that the compiler courses taught now are teaching about compiler- writing. After all, a miniscule percentage of programmers are going to write compilers and even those who will, will quickly discover that modern compilers have little to do with what they learned in an undergraduate compiler construction course. What is needed is a course that teaches programmers to know what compilers actually do.