Jez Higgins

Freelance software grandad
software created
extended or repaired


Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations

Hire me
Contact

Older posts are available in the archive or through tags.

Feed

Monday 05 August 2019 The Forest Road Reader, No 2.21 : Software Tools In C++

STinC++ rewrites the programs in Software Tools in Pascal using C++

Software Tools In Pascal

One of my very favourite books about software is Kernighan and Plauger’s Software Tools in Pascal. The authors set their stall out in the very first line of the Preface

This book teaches how to write good programs that make good tools, by presenting a comprehensive set, each of which provides lessons in design and implementation.

They continue

The principles of good programming are presented not as abstract sermons but as concrete lessons in the context of working programs. For example, there is no chapter on "efficiency". Instead, throughout the book there are observations on efficiency as it relates to the particular program being developed. Similarly there is no chapter on "top-down design," nor on "structured programming," nor on "testing and debugging." Instead, all of these disciplines are employed as appropriate in every program shown.

I first found Software Tools in Pascal a bit over 20 years ago, hidden in amongst old VAX manuals in the library of the company where I worked at the time. Unusually for a technical book, Software Tools in Pascal has a terrific narrative. It starts with a tiny task – copy everything from the console input to the console output – and presents the correspondingly tiny program. Step by step, program by program, you arrive at the end of the book with an ex-like line editor, a roff-style print formatter, and a macro processor. En route, you take in filtering, file archiving, sorting, and regular expressions. Each incremental step seems so logical and the code presented is so clear, that you just want to keep reading. Chunks of code in a book can be rather tedious, but Kernighan and Plauger’s is a joy. The lessons imparted on simplicity, clarity, efficiency, on tools and the Unix philosophy, in common sense, how each decision effects the finished program – well, they are at the core of what we do, and how we should think about programming.

Your mind can only be blown once, but I re-read bits of this book often to remind myself of the feeling it gave me.

I’ve long toyed with the idea of working through Software Tools in Pascal reimplementing the programs therein in another language. The invitation is, after all, right there on the cover.

Good Programming is not learned from generalities, but by seeing how significant programs can be made clean, easy to read, easy to maintain and modify, human-engineered, efficient, and reliable, by the application of common sense and good programming practices. Careful study and imitation of good programs leads to better writing.

Software Tools in Pascal is itself a revised edition of an earlier book, called simply Software Tools. The programs in Software Tools were presented in RatFor, a modified version of Fortran. Ouroborus-like, one of the tools presented in Software Tools is the RatFor to Fortran preprocessor. While Software Tools in Pascal presents the same tools, the implementations are new Pascal programs, not straight translations of the existing code.

The programs here are not just transliterations into Pascal, however. Almost every program has been improved in some way. Pascal lets us do some things much better than is possible in Fortran. Recursion in particular is a boon. Quicksort and regular expression closure are much simpler when done recursively instead of with a stack or linked list; expression evaluation has been added to the macro processor.

And yet other languages allow us to do some things much better even than that! Languages now provide much larger and more capable standard libraries that came with early-80s vintage Pascal, for instance. Much richer data types, either built in or via libraries, are available, and so on.

Partly because I’m working in C++ at the moment (albeit the C++ of the past) and partly because C++ is what I regard as my programming first language (even though it’s not even close to the first progamming language I learned), I’m thinking about C++. While I’ve done a reasonable amount of C++ work over the past few years, at the same time C++ itself has undergone some fairly major changes and so I’m not bang-up-to-date and I’ll have an excuse to do a bit of catching up. Of course, C++ and Pascal share a broad family lineage and maybe that’ll help and maybe it won’t. There are so many ways to slice this, but whichever, I think it’ll be interesting and fun to write some Software Tools in C++.


Tagged code, and software-tools-in-c++


Jez Higgins

Freelance software grandad
software created
extended or repaired

Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations

Hire me
Contact

Older posts are available in the archive or through tags.

Feed