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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s