Back Contents Next

UNIX Philosophy

We hope to convey a flavor of UNIX programming in the following chapters. Although programming in C is in many ways the same whatever the platform, it's true to say that UNIX developers have a special view of program and system development.

 

The UNIX operating system encourages a certain programming paradigm, a philosophy if you will. Here are a few characteristics shared by typical UNIX programs and systems.

Simplicity

Many of the most useful UNIX utilities are very simple and, as a result, small and easy to understand. KISS (Keep It Small and Simple) is a good technique to learn. Larger, more complex systems are guaranteed to contain larger, more complex bugs and debugging is a chore we'd all like to avoid!

Focus

It's often better to make a program perform one task well. A program with 'feature bloat' can be difficult to use and difficult to maintain. Programs with a single purpose are easier to improve as better algorithms or interfaces are developed. In UNIX, small utilities are often combined to perform more demanding tasks as and when the need arises, rather than trying to anticipate a user's needs in one large program.

Reusable Components

Make the core of your application available as a library. Well-documented libraries with simple but flexible programming interfaces can help others to develop variations or apply the techniques to new application areas. Examples include the dbm database library, a suite of reusable functions rather than a single database management program.

Filters

Very many UNIX applications can be used as filters. That is, they transform their input and produce an output. As we'll see, UNIX provides facilities that allow quite complex applications to be developed from other UNIX programs by combining them in new and novel ways. Of course, this kind of reuse is enabled by the development methods that we've just mentioned.

Open File Formats

The more successful and popular UNIX programs use configuration files and data files that are plain ASCII text. If this is an option for your program development, it's a good choice. It enables users to use standard tools to change and search for configuration items and to develop new tools for performing new functions on the data files. A good example of this is the ctags source code cross-reference system, which records symbol location information as regular expressions suitable for use by searching programs.

Flexibility

You can't anticipate exactly how ingeniously users will use your program. Try to be as flexible as possible in your programming. Try to avoid arbitrary limits on field sizes or number of records. If you can, write the program so that it's network-aware and able to run across a network as well as on a local machine. Never assume that you know everything the user might want to do.

Summary

In this introductory chapter, we've taken note of the things in common between Linux and proprietary UNIX systems and the wide variety of programming systems available to us as UNIX developers.

 

We've written a simple program and library to demonstrate the basic C tools, comparing them with their MS-DOS equivalents. Finally, we've covered the UNIX programming paradigm.

 

Back Contents Next
©1999 Wrox Press Limited,US and UK.





Sponsored Links

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map
Jupiterweb networks

internet.comearthweb.comDevx.comClickZ

Search Jupiterweb:

Jupitermedia Corporation has four divisions:
JupiterWeb, JupiterResearch, JupiterEvents, and JupiterImages

Copyright 2004 Jupitermedia Corporation All Rights Reserved.
Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Jupitermedia Corporate Info | Newsletters | Tech Jobs | E-mail Offers