夏日落傷 发表于 2016-10-5 09:15:43
The C programming language is not trendy. The most recentedition of the canonical C text (the excitingly named The C Programming Language) was published in 1988; C is so unfashionable that the authors have neglected to update it in light of 30 years of progress in software engineering. Everyone “has been meaning to” learn Rust or Go or Clojure over a weekend, not C. There isn’t even a cute C animal in C’s non-logo on a C decal not stuck to your laptop.
您需要 登录 才可以下载或查看，没有帐号？立即注册
But Myles and I are not trendy people, so we insist that all of our students become fluent in C. A fresh class of C converts has just finished working through the K&R bible, making this a good time for me to reflect on why we deify this ancient tongue.
We give students four reasons for learning C:
The first is easy to dismiss if one likesthe Bay Area web/mobile startup echo chamber, the second if one hatesC’s influence on many more modern languages. Most engineers should take head of reason three, although our students also learn computer architecture and at least one assembly language, so have a firm mental model of how computers actually compute. But reason four is hard to ignore.
- It is still one of the most commonly used languages outside of the Bay Area web/mobile startup echo chamber;
- C’s influence can be seen in many modern languages;
- C helps you think like a computer; and,
- Most tools for writing software are written in C (or C++)
Forsaking C means forsaking anything below the level of abstraction at which one happens to currently work. Those who work for instance as web developers forsake thoroughly understanding the browsers, operating systems and languages on top of which their own work stands.
When learning about common data structuressuch as hashmaps and dynamic arrays, we need to either implement these ourselves in a language where we can think concretely about memory layout, or to read good implementations that do so. For a student to understand how a Python list or ruby array works, we have them either write a version from scratch or read the source of the standard library implementations—gaining the same level of understanding without diving into C is almost impossible.
Learning about operating systemswould be much harder without C. The operating systems that we use are mostly written in C, the C standard library is tightly coupled to the syscall interface, and most resources dealing with operating systems concepts assume knowledge of C.
While it is certainly possible to learn about computer networkingwithout being fluent in C, practitioners who need to understand their operating system’s TCP/IP stackwill find themselves grasping for C.
Lastly most of the work we do with databases, key value stores, message queues and other distributed systems technologiesmandates C, for performance reasons.
Many practicing software engineers do fine work without fully understanding the above. Routine work in a narrow domain may not demand foundational knowledge. But our students strive to do novel, high-impact work, and quickly find that a solid understanding of C is a prerequisite. If you have similar goals, I would encourage you to put aside that trendy new language for a few more weekends and brush up on good old C.
下一篇：How I test Ansible configuration on 7 different OSes with Docker