The Practice of Programming – Preface

The Practice of Programming
===========================
Brian Kernighan & Rob Pike

——-
Preface
——-

Have you ever…

wasted time coding the wrong algorithm
used a too complicated data structure
missed an obvious problem despite testing
spent all day looking for an obvious bug
needed to make a program run 3x faster and use less memory
run a program on different computer than it written on
tried to make a modest change in someone else’s program
rewritten a program because you couldn’t understand

what a great set of questions

these practices are not taught:
testing
debugging
portability
performance
design alternatives
style

underlying principles:
simplicity
clarity
generality

clear description of the applicable target solution

tools and notations that let the computer assist you
automation – let the machine do the work for you
free you from mundane tasks

learn design, debugging, testing, performance improvements independent of language, os, or programming paradigm

Chapter summaries
—————–

Chapter 1: Programming Style
well written programs are better than badly written ones
– fewer errors
– easier to debug
– easier to modify
important to think about style from the start
use language appropriate idioms

Chapter 2: Algorithms and Data Structures
review common ones that show up in most programs
more complex algorithms should evolve from building blocks so master the basics

Chapter 3: Implement alg & ds in different languages
compare expressiveness and performance

Chapter 4: Designing interfaces
between users, programs, subsystems
evolution of small library for parsing a data format
small example illustrate concerns of interface design
– abstraction
– information hiding
– resource management
– error handling

Chapter 5: Debugging
debugging is inevitable
systematic & effective debugging strategies & tactics
signatures of common bugs
patterns in debugging output indicate where a problem is

Chapter 6: Testing
attempt to develop a reasonable assurance that a program is working correctly
and that it stays correct as it evolves

Chapter 7: Efficiency & Performance
most programs are “fast enough” on modern hardware
orderly way of making programs use resources efficiently
make sure programs remain correct and sound as perf improves

Chapter 8: Portability
Successful programs will see environment change underneath them
Goal of portability is to reduce maintenance by minimizing change needed to adapt to a new environment

Chapter 9: Language
general purpose vs specialized languages
simplify
guide implementations
programs that write programs

Code: C, C++, Java
descendants of C

Your task is to do the best you can with the tool you have

Examples may be in C even though another language might be better suited to a particular problem.

Reviewing classic computing literature

I’m going to be reading through and commenting on some of the classics in the field.  I’d welcome anyone who wants to join along and do a kind of virtual book club where we share our thoughts on blogs, twitter, etc.

I’m starting with “The Practice of Programming” by Brian Kernighan and Rob Pike.  It’s a nice general primer on programming style with concrete examples.   After that I’ll dive into the original K&R “The C Programming Language” working through the exercises and looking for the principles mentioned in the later book.  And then I’ll take a look at “The Unix Programming Environment” to round out the trifecta and consider how it has influenced modern systems.

And then I’ll look for some other classics, and maybe some modern books.  Open to suggestions.

Planning about 1 book every month or 2.  Spending just 30-60 minutes / day 3-4 days a week on each book, not going to deep, but looking for little insights and comparison founding principles with modern views.

Let me know if you’re interested in reading along, maybe a hangout or chat room or discussion board.