Nixers Book Club - Book #4: The Art of UNIX Programming - Community & Forums Related Discussions

Users browsing this thread: 2 Guest(s)
seninha
Long time nixers
Chapter 7 is about multiprocess (or, as the book calls, multiprogramming).

Quote:UNIX encorages us to break our programs into simpler subprocesses, and to concentrate on the interfaces between the subprocesses.

It does that in three ways: by making process-spawning cheap, by providing IPC methods, by encoraging the use of simple text protocols.

The IPC methods are the following:
  • Shelling out (call a program, with system(3) for example).
  • Bolting on (call a program with popen(3)).
  • Pipelining (run filter programs concurrently on a pipeline).
  • Wrapping (create a new interface for a called program).
  • Tempfiles (communication via a temporary file).
  • Signals (signals were originally designed into UNIX as a way for the operating system to notify programs of certain errors and critical events, not as an IPC facility).

Quote:GNOME's main competitor, KDE, started with CORBA but abandoned it in their 2.0 release. They have been on a quest for lighter-weight IPC methods ever since.
And thus D-Bus was born.

Quote:The combination of threads, remote-procedure-call interfaces and heavyweight object-oriented design is especially dangerous. [...] if you are ever invited onto a project that is supposed to feature all three, fleeing in terror might well be an appropriate reaction.

Chapter 8 is about domain-specific languages.

Quote:more expressive languages mean shorter programs and fewer bugs

I have been using a little language, awk, for much of the stuff I would do in C. In particular, after playing with coding styles, I wanted to write a small indent(1) program. At first I thought in fork OpenBSD indent(1), then I thought in using lex(1) for the lexical analyzer. Then I thought, why not awk? It would be hacky, but way more feasible.

The book says there are two right ways to develop a domain-specific language (design the language from the beginning or notice that a specification file format looks more and more like a DSL; and a wrong way (extend the program towards a DSL).
We see several examples of DSL: make, awk, m4 (which I have never used), glade, troff, yacc, lex, etc.

Quote:There are a few embarrassing exceptions; notably, tbl(1) defaults to using a tab as a field separator between table columns, replicating an infamous botch in the design of make(1) and causing annoying bugs when editors or other tools invisibly change the composition of whitespace.
Chatting with freem, he convinced me that tab should be used for TABles.
I do not consider tbl(1), make(1) and, in my case, xprompt(1) and xmenu(1) to have a botched input format anymore.

The book gives a pic(1) example, I remember the first time I have to use pic(1) and troff(1), in an attempt to get rid of LaTeX.

From the examples in the book, I use awk, troff and pic. m4 and PostScript are the ones I want to learn.


Messages In This Thread
RE: Nixers Book Club - Book #4: The Art of UNIX Programming - by seninha - 29-05-2021, 02:36 PM