The Unix Programming Environment (Prentice-Hall Software Series)

Category: Programming
Author: Brian Wilson Kernighan, Rob. Pike
All Hacker News 8
This Year Hacker News 2
This Month Stack Overflow 1


by enneff   2022-08-30
This is a great book, one of my faves. It is a surprise to see it hosted on when it is still in print, though. Please support good technical writing!

by regularfry   2021-05-20
I recommend as an introduction to the fundamental concepts of the Unix filesystem. Certainly a better education than I could give here.
by anonymous   2019-07-21

You almost assuredly want to generate some other representation before evaluating in your calculator. A parse tree or ast are classic methods, but a simple stack machine is also popular. There are many great examples of how to do this, but my favorite is That shows how to take a simple direct evaluation tool like you have made in yacc (old bison) and take it all the way to a programming language that is almost as powerful as BASIC. All in very few pages. It's a very old book but well worth the read.

You can also look at SeExpr which is a simple expression language calculator for scalars and 3 vectors. If you look at on line 313 you will see the && implementation of he eval() function:

SeExprAndNode::eval(SeVec3d& result) const
    // operands and result must be scalar
    SeVec3d a, b;
    if (!a[0]) {
    result[0] = 0;
    } else { 
    result[0] = (b[0] != 0.0); 

That file contains all objects that represent operations in the parse tree. These objects are generated as the code is parsed (these are the actions in yacc). Hope this helps.

by anonymous   2019-07-21

It sounds like you need to get a handle on the *nix basics first. Everything else builds on that. For example, trying to configure your run-of-the-mill Apache with PHP/Python/Whatever setup will be pretty tough without that knowledge - if you can ssh into your server in the first place :)

With that in mind: Oldie but goldie, and should be easily accessible to any programmer coming from other environments. Perhaps someone can recommend an updated version of this?

by anonymous   2019-07-21


Unix Programming Environment by Kernighan and Pike will give you solid foundations on all things Unix and should cover most of your questions regarding shell command line scripting etc.

The Armadillo book by O'Reilly will add the administration angle. It has served me well!

Good luck!

by charlysl   2018-11-20
"On the criteria to be used in decomposing systems into modules" (1972) - because the core principles of modularity haven't changed []

"The Mythical Man Month" (1975) - because human nature hasn't changed []

"The History of Fortran I, II, and III" (1979) - because this historical piece by the author of the first high level language brings home the core principles of language design []

"The Unix Programming Environment" (1984) - because the core basics of the command line haven't changed []

"Reflections on Trusting Trust" (1984) - because the basic concepts of software security haven't changed []

"The Rise of Worse is Better" (1991) - because many of the tradeoffs to be made when designing systems haven't changed []

"The Art of Doing Science and Engineering: Learning to learn" (1996) - because the core principles that drive innovation haven't changed [] []

"xv6" (an x86 version of Lion's Commentary, 1996) - because core OS concepts haven't changed [] []

by mcguire   2018-03-30
I found it very interesting for being one of the very few books that deals with code as a formal system.

You don't need to understand the code; you don't need to step through the code. You follow the steps for "extract method" and you go from a working state to another working state with no worries.

The individual refactorings are more-or-less interesting, but as others have said, they're somewhat commonplace now.

Two books that every programmer should read: Software Tools[1] and The Elements of Programming Style[2] by Kernighan and Plauger. Bonus: The Unix Programming Environment[3] by Kernighan and Pike.




by wyc   2017-08-20
I remember The Unix Programming Environment by Kernighan and Pike as an excellent introduction to Unix shells and general Unix programming. IIRC, throughout the chapters, it has you build some kind of interactive command line music organizer, which really demonstrates how much you can get done with a few simple shell scripts.

Amazon link:

by nswanberg   2017-08-19
Here's the slightly modified answer I just posted there (even though it's an old question):

Back when he was still doing podcasts Joel Spolsky answered the similar question, which was partly "Does a good programmer without a CS degree really have a chance to get a job at Fogcreek?[1]" (It's near the end of the page.)

He says that for a good self-taught programmer who began with a high-level language, say PHP or Java, who comes at programming from a practical perspective, there are a few important parts of the CS curriculum the person may have missed out on, and goes on to list some books that would help fill in those gaps.

Off the top of his head he named these books in about this order:

- Structure and Interpretation of Computer Programs[2] (also free online[3])

- C Programming Language[4]

- The Unix Programming Environment[5]

- Introduction to Algorithms[6]

He said that those books covered the aspects of the CS curriculum his company needs in a good programmer, e.g. being able to create algorithms for an uncommon data structure.

Those books all have the added advantage of having exercises, and all being a very pleasant read. SICP is an introduction to many of the big ideas in CS: data structures, streams, recursion, interpretation, compilation, register machines, etc., and their implementation in Scheme (a kind of Lisp). It's a great place to start. The next two focus on implementation details like pointers and memory allocation. They are compact, powerful books. The last, Introduction to Algorithms, seems misleadingly titled, as it is fairly comprehensive and used in both undergraduate and graduate courses. If you work your way through the entire book, chapeau!







by stiff   2017-08-19
It is actively harmful to teach students that software architecture is something that somehow arises from diagrams or that those kinds of silly pictures capture anything important about it. Powerful architectures come out of powerful ideas that in turn come from accumulated hard work of many people in different disciplines. One can learn much more from walking through the actual source code of some classic projects and from trying to understand the ideas that make them tick: - UNIX philosophy of small tools, DSLs, CS theory: state machines / regular expressions, Thompson algorithm ... - Both a program and a VM for a programming language, hooks, before/after/around advices, modes, asynchronous processing with callbacks, ... Worth to think of challenges of designing interactive programs for extensibility. - Metaprogramming DSLs for creating powerful libraries, again a lesson in hooks (before_save etc.), advices (around_filter etc.), ... - The distributed paradigm, lots of CS theory again: hashing for ensuring consistency, DAGs everywhere, ... By the way, the sentence "yet the underlying git magic sometimes resulted in frustration with the students" is hilarious in the context of a "software architecture" course.

One of computer algebra systems - the idea of a

One of computer graphics engines - Linear algebra


There are loads of things one can learn from those projects by studying the source in some depth, but I can't think of any valuable things one could learn by just drawing pictures of the modules and connecting them with arrows. There are also several great books that explore real software design issues and not that kind of pretentious BS, they all come from acknowledged all-time master software "architects", yet all of them almost never find diagrams or "viewpoints" useful for saying the things they want to say, and they all walk you through real issues in real programs:

To me, the kind of approach pictured in the post, seems like copying methods from electrical or civil engineering to appear more "serious", without giving due consideration to whether they really are helpful for anything for real-world software engineering or not. The "software engineering" class which taught those kind of diagram-drawing was about the only university class I did not ever get any use from, in fact I had enough industry experience by the point I took it that it just looked silly.

by ctrlp   2017-08-19
If you consider C to be language-agnostic, here are some gems. These are personal favorites as much for their excellent writing as for their content.

The Unix Programming Environment was published in 1984. I read it over 20 years later and was astonished at how well it had aged. For a technical book from the 80's, it is amazingly lucid and well-written. It pre-dates modern unix, so things have changed but much that goes unstated in newer books (for brevity) is explicit in UPE. (Plus, the history itself is illuminating.) It gave me a much deeper understanding of how programs actually run over computer hardware. Examples in C are old-school and take a bit of close reading but oh so rewarding.

Mastering Algorithms in C. Another fantastically well-written book that shows (with practical examples) how to implement common algorithms. This is just such a great book!


Code (Petzold). This one is truly language-agnostic. Others have mentioned it already. Can't recommend enough if you're iffy on the internals of computers and programming.

Write Great Code (Volumes I and II). Randall Hyde's books are fantastic explications of the underlying computer operations. Examples are in assembly or pseudo-code but easy to understand.