Premium Only Content
 
			The Unix Philosophy
The Unix Philosophy
The Unix Philosophy is a system design philosophy of using minimalist composable components.
As a software development style the Unix Philosophy advocates building small tools that communicate over a universal interface to create larger systems. Higher level functionality then emerges from the combination of these composable tools instead of from a monolithic program.
Formulations
Peter Salus
Write programs that do one thing and do it well.
Write programs to work together.
Write programs to handle text streams, because that is a universal interface.
Doug Mcllroy
Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new "features".
Expect the output of every program to become the input to another, as yet unknown, program. Don't clutter output with extraneous information. Avoid stringently columnar or binary input formats. Don't insist on interactive input.
Design and build software, even operating systems, to be tried early, ideally within weeks. Don't hesitate to throw away the clumsy parts and rebuild them.
Use tools in preference to unskilled help to lighten a programming task, even if you have to detour to build the tools and expect to throw some of them out after you've finished using them.
This is the Unix philosophy: Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.
The notion of "intricate and beautiful complexities" is almost an oxymoron. Unix programmers vie with each other for "simple and beautiful" honors — a point that's implicit in these rules, but is well worth making overt.
"The Unix Programming Environment" - Brian Kernighan and Rob Pike
Even though the UNIX system introduces a number of innovative programs and techniques, no single program or idea makes it work well. Instead, what makes it effective is the approach to programming, a philosophy of using the computer. Although that philosophy can't be written down in a single sentence, at its heart is the idea that the power of a system comes more from the relationships among programs than from the programs themselves. Many UNIX programs do quite trivial things in isolation, but, combined with other programs, become general and useful tools.
"Program Design in the UNIX Environment" - Brian Kernighan
Much of the power of the UNIX operating system comes from a style of program design that makes programs easy to use and, more important, easy to combine with other programs. This style has been called the use of software tools, and depends more on how the programs fit into the programming environment and how they can be used with other programs than on how they are designed internally. [...] This style was based on the use of tools: using programs separately or in combination to get a job done, rather than doing it by hand, by monolithic self-sufficient subsystems, or by special-purpose, one-time programs.
Do One Thing and Do It Well
The central idea of the Unix Philosophy is to build composable components that do one thing well. Small minimalist components are easier to understand and modify which allows for faster experimentation. New features are added by connecting to existing components or creating a new component. Higher order functionality then emerges from the connections between components.
In Unix style development developers build tools to solve problems instead of using outside help. The limiting factor in software development is typically developer understanding. When modifying a system a developer often spend most of their time trying to understand the system, and a small amount of time making the relevant change. By scaling a single developer with tools they understand communication and understanding burdens are decreased. The volume of internal communication scales O(n3) with the number of developers while their surface area of useful work with the outside world scales O(n2). The modularity and composibility of the Unix Philosophy increases what individual developers can accomplish and makes it easier for developers to share code and work in parallel.
Everything is a File
Unix operating systems are based around files. Data is stored in files, configuration is done with files, logs are saved as files, and OS services like input output and communication with other processes is exposed through a file interface.
Examples
This is an example of reading and searching a log file with Unix tools.
$ cat logs.txt
info: Startup
info: Load data
info: Processing
error: Divide by zero line 42
warning: Calculation failed
info: Exiting
$ grep error logs.txt
error: Divide by zero line 42
Possible Improvements
The Unix Philosophy has traditionally been based around the universal text interface which works well but connecting components with a scripting language or structured data format has many advantages.
A disadvantage of the text interface is that it is difficult to pass data structures or advanced functionality between components which can be done easily using scripting languages like Python and data formats like JSON.
For example, if a programmer wanted to pass a list of dictionaries between two components through a text interface it would require complex parsing. However, this is easily accomplished by passing a JSON object.
[
{
"P.J.": 10,
"Brian": 6
},
{
"Peter": 8
}
]
- 	
				 15:48 15:48Sponsored By Jesus Podcast14 hours agoHow to Stop Being JEALOUS | When Comparison Steals Your Joy2.44K8
- 	
				 LIVE LIVEDLDAfterDark5 hours agoDon't Worry - Things Will Get SO Much Worse! Sometimes It Be Like That459 watching
- 	
				 25:41 25:41Robbi On The Record10 hours agoThe Billion-Dollar Lie Behind OnlyFans “Empowerment” (Her Testimony Will Shock You) | part II3.71K6
- 	
				 12:22 12:22Cash Jordan2 hours ago"CHICAGO MOB" Fights Back... "ZERO MERCY" Marines DEFY Judge, SMASH ILLEGALS15.8K28
- 	
				 46:58 46:58Brad Owen Poker14 hours agoI Make QUAD ACES!!! BIGGEST Bounty Of My Life! Turning $0 Into $10,000+! Must See! Poker Vlog Ep 3239K3
- 	
				 2:52:28 2:52:28TimcastIRL5 hours agoSTATE OF EMERGENCY Declared Over Food Stamp CRISIS, Judge Says Trump MUST FUND SNAP | Timcast IRL207K118
- 	
				 3:22:45 3:22:45Tundra Tactical12 hours ago $14.22 earned🚨Gun News and Game Night🚨 ATF Form 1 Changes, BRN-180 Gen 3 Issues??, and Battlefield 6 Tonight!27.8K2
- 	
				 1:45:13 1:45:13Glenn Greenwald8 hours agoJD Vance Confronted at Turning Point about Israel and Massie; Stephen Miller’s Wife Screams “Racist” and Threatens Cenk Uygur with Deportation; Rio's Police Massacre: 120 Dead | SYSTEM UPDATE #540106K151
- 	
				 LIVE LIVESpartakusLIVE6 hours agoSpart Flintstone brings PREHISTORIC DOMINION to REDSEC245 watching
- 	
				 1:05:02 1:05:02BonginoReport9 hours agoKamala CALLED OUT for “World Class” Deflection - Nightly Scroll w/ Hayley Caronia (Ep.167)127K74