SlideShare une entreprise Scribd logo
1  sur  19
The UNIX Philosophy
What is the UNIX Philosophy?
The Unix philosophy emphasizes building simple, short, clear,
modular, and extensible code that can be easily maintained
and repurposed by developers other than its creators.
The UNIX Philosophy should (DougMcIlroy)
1. Make each program do one thing well. To do a new job, build a fresh rather than complicate old
programs by adding new “features”.
2. 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.
3. 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.
4. 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.
Where did it originate?
The Unix philosophy, originated by Ken Thompson, is a set of
cultural norms and philosophical approaches to minimalist,
modular software development. It is based on the experience of
leading developers of the Unix operating system.
Do one thing well
cat does exactly one thing. It concatenates files and displays them on standard
output. That’s all it does. It doesn’t do pagination. It doesn’t offer search
functionality. It just does exactly what it says on the tin and no more.
true and false are perhaps the best examples of doing one thing well. true does
nothing, successfully! false does nothing.
false && echo Hi # does nothing
true && echo Hi # Prints Hi
Worse is Better
- Although this idea wasn’t a direct relative of the Unix philosophy, it’s
certainly similar.
- The idea references the fact that additional features or complexity doesn’t
necessarily make things better, and a “worse” project — one with fewer
features and less complexity — is actually better because it will tend to be
more reliable and usable.
- Most of us can recognize this idea in at least one of our projects. We start
work on a project but midway though the project we decide that it should
have another feature. The feature creep causes the project to be
unusable or unreliable, even given its initial simple design goal. An
emphasis on simplicity and interoperability helps fight feature creep.
Composition
In Unix, most operations have the ability to read and write to standard output in a
well understood textual format. With a few commands, such as | and > we can
feed the output of one program to another. Let’s look at some examples:
In this example, we use cat to output the contents of a file and feed the output into
wc who can count the number of lines in a file.
cat text.txt | wc -l
Everything is a file
In UNIX everything is a file (or more precisely, everything is a stream of bytes). This
means that the same APIs/commands can be used for reading a CD-ROM drive,
writing a network socket or finding out CPU info.
For example, the entire /proc file system on Linux isn’t really files — it’s a dynamic view
of information that’s exposed as a bunch of file descriptors.
Some examples:
cat /proc/cpuinfo # Displays your CPU info exposed as a file
echo "This is the next line in the log" >> log.file # Redirects output
into a file called log.file
Example in code
A simple program
- Does one thing
- Does it well
- No versioning problems
- Can be used by any program written in any language
func upper(f *os.File) {
input := bufio.NewScanner(f)
for input.Scan() {
fmt.Println(strings.ToUpper(input.Text()))
}
}
func main() {
files := os.Args[1:]
if len(files) == 0 {
upper(os.Stdin)
} else {
for _, file := range files {
f, err := os.Open(file)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %vn", os.Args[0], err)
continue
}
upper(f)
f.Close()
}
}
}
Another example
- Does one thing
- Does it well
- No versioning problems
- Can be used by any program written in any language
func spilt(f *os.File) {
input := bufio.NewScanner(f)
for input.Scan() {
lines := strings.Split(input.Text(), " ")
for _, line := range lines {
fmt.Println(line)}
}
}
func main() {
files := os.Args[1:]
if len(files) == 0 {
split(os.Stdin)
} else {
for _, file := range files {
f, err := os.Open(file)
if err != nil {
fmt.Fprintf(os.Stderr, "%s: %vn", os.Args[0], err)
continue
}
split(f)
f.Close()
}
}
}
Composing Programs
We build complex programs from simple ones
#!/bin/bash
./uppercase | ./split
We build complex programs from simple ones
cat text.txt | ./uppercase | ./split
Building Technical Capital
cat text.txt text2.txt | ./uppercase | ./split | sort | uniq
- We build in a short while a program that does the majority of the work of
a spell checker
- Pros:
- Less lines of code
- Less buggy
- More efficient
- Short build time
Difficulties
- Requires discipline - It requires much more time in planning for the
future of the project
- Requires experience - To create a good plan, you have to know where
the difficulties in software development are. (i.e Communication between
teams)
- It's not a complete science - There's no hard science telling us how to
implement the UNIX philosophy. May depend on the size of the project or
future expectations
How to learn
- Learn from experienced developers - Learn from their mistakes and
build on them
- Learn by doing - Learn from your own mistakes. Start small and build
your way up
- Reflect on your code - Look over your code and see where you could
redesign or refactor your code and make it better.
Hope you all gained some new knowledge
Links
- https://www.youtube.com/watch?v=aY7OzGPaP5I&t=176s&ab_channel=P
hilipBohun
- https://www.youtube.com/watch?v=dDwXnB6XeiA&ab_channel=StevieJay
- https://en.wikipedia.org/wiki/The_Art_of_Unix_Programming
- https://medium.com/ingeniouslysimple/philosophy-of-unix-development-
aa0104322491

Contenu connexe

Similaire à The UNIX philosophy

Cs121 Unit Test
Cs121 Unit TestCs121 Unit Test
Cs121 Unit TestJill Bell
 
Program design in the UNIX environment
Program design in the UNIX environmentProgram design in the UNIX environment
Program design in the UNIX environmentmustafa sarac
 
Linux principles and philosophy
Linux principles and philosophy Linux principles and philosophy
Linux principles and philosophy salamassh
 
"Hints" talk at Walchand College Sangli, March 2017
"Hints" talk at Walchand College Sangli, March 2017"Hints" talk at Walchand College Sangli, March 2017
"Hints" talk at Walchand College Sangli, March 2017Neeran Karnik
 
Computational biology
Computational biologyComputational biology
Computational biologySpringer
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-pythonYuvaraja Ravi
 
Automation and machine learning in the enterprise
Automation and machine learning in the enterpriseAutomation and machine learning in the enterprise
Automation and machine learning in the enterprisealphydan
 
Linux principles and philosophy
Linux principles and philosophyLinux principles and philosophy
Linux principles and philosophyfatimarashid66
 
C programming basics
C  programming basicsC  programming basics
C programming basicsargusacademy
 
Synapse india fundamentals of dotnet development
Synapse india fundamentals of dotnet  developmentSynapse india fundamentals of dotnet  development
Synapse india fundamentals of dotnet developmentSynapseindiappsdevelopment
 
Life & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@PersistentLife & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@PersistentPersistent Systems Ltd.
 
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptxThe-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptxalo154283
 

Similaire à The UNIX philosophy (20)

Old Is the New New
Old Is the New NewOld Is the New New
Old Is the New New
 
THE BASIC TOOLS
THE BASIC TOOLSTHE BASIC TOOLS
THE BASIC TOOLS
 
Cs121 Unit Test
Cs121 Unit TestCs121 Unit Test
Cs121 Unit Test
 
Program design in the UNIX environment
Program design in the UNIX environmentProgram design in the UNIX environment
Program design in the UNIX environment
 
hw1a
hw1ahw1a
hw1a
 
hw1a
hw1ahw1a
hw1a
 
Linux principles and philosophy
Linux principles and philosophy Linux principles and philosophy
Linux principles and philosophy
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
 
"Hints" talk at Walchand College Sangli, March 2017
"Hints" talk at Walchand College Sangli, March 2017"Hints" talk at Walchand College Sangli, March 2017
"Hints" talk at Walchand College Sangli, March 2017
 
Computational biology
Computational biologyComputational biology
Computational biology
 
Csharp tp
Csharp tpCsharp tp
Csharp tp
 
01.intro
01.intro01.intro
01.intro
 
Socket programming-in-python
Socket programming-in-pythonSocket programming-in-python
Socket programming-in-python
 
Automation and machine learning in the enterprise
Automation and machine learning in the enterpriseAutomation and machine learning in the enterprise
Automation and machine learning in the enterprise
 
Linux principles and philosophy
Linux principles and philosophyLinux principles and philosophy
Linux principles and philosophy
 
C programming basics
C  programming basicsC  programming basics
C programming basics
 
Synapse india fundamentals of dotnet development
Synapse india fundamentals of dotnet  developmentSynapse india fundamentals of dotnet  development
Synapse india fundamentals of dotnet development
 
Life & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@PersistentLife & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@Persistent
 
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptxThe-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
The-Command-Line-Part-1-Slidebbbbbbbbbbbbbbbbs.pptx
 
Bp301
Bp301Bp301
Bp301
 

Dernier

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 

Dernier (20)

Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

The UNIX philosophy

  • 2. What is the UNIX Philosophy? The Unix philosophy emphasizes building simple, short, clear, modular, and extensible code that can be easily maintained and repurposed by developers other than its creators.
  • 3. The UNIX Philosophy should (DougMcIlroy) 1. Make each program do one thing well. To do a new job, build a fresh rather than complicate old programs by adding new “features”. 2. 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. 3. 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. 4. 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.
  • 4. Where did it originate? The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system.
  • 5. Do one thing well cat does exactly one thing. It concatenates files and displays them on standard output. That’s all it does. It doesn’t do pagination. It doesn’t offer search functionality. It just does exactly what it says on the tin and no more. true and false are perhaps the best examples of doing one thing well. true does nothing, successfully! false does nothing. false && echo Hi # does nothing true && echo Hi # Prints Hi
  • 6. Worse is Better - Although this idea wasn’t a direct relative of the Unix philosophy, it’s certainly similar. - The idea references the fact that additional features or complexity doesn’t necessarily make things better, and a “worse” project — one with fewer features and less complexity — is actually better because it will tend to be more reliable and usable. - Most of us can recognize this idea in at least one of our projects. We start work on a project but midway though the project we decide that it should have another feature. The feature creep causes the project to be unusable or unreliable, even given its initial simple design goal. An emphasis on simplicity and interoperability helps fight feature creep.
  • 7. Composition In Unix, most operations have the ability to read and write to standard output in a well understood textual format. With a few commands, such as | and > we can feed the output of one program to another. Let’s look at some examples: In this example, we use cat to output the contents of a file and feed the output into wc who can count the number of lines in a file. cat text.txt | wc -l
  • 8. Everything is a file In UNIX everything is a file (or more precisely, everything is a stream of bytes). This means that the same APIs/commands can be used for reading a CD-ROM drive, writing a network socket or finding out CPU info. For example, the entire /proc file system on Linux isn’t really files — it’s a dynamic view of information that’s exposed as a bunch of file descriptors.
  • 9. Some examples: cat /proc/cpuinfo # Displays your CPU info exposed as a file echo "This is the next line in the log" >> log.file # Redirects output into a file called log.file Example in code
  • 10. A simple program - Does one thing - Does it well - No versioning problems - Can be used by any program written in any language
  • 11. func upper(f *os.File) { input := bufio.NewScanner(f) for input.Scan() { fmt.Println(strings.ToUpper(input.Text())) } } func main() { files := os.Args[1:] if len(files) == 0 { upper(os.Stdin) } else { for _, file := range files { f, err := os.Open(file) if err != nil { fmt.Fprintf(os.Stderr, "%s: %vn", os.Args[0], err) continue } upper(f) f.Close() } } }
  • 12. Another example - Does one thing - Does it well - No versioning problems - Can be used by any program written in any language
  • 13. func spilt(f *os.File) { input := bufio.NewScanner(f) for input.Scan() { lines := strings.Split(input.Text(), " ") for _, line := range lines { fmt.Println(line)} } } func main() { files := os.Args[1:] if len(files) == 0 { split(os.Stdin) } else { for _, file := range files { f, err := os.Open(file) if err != nil { fmt.Fprintf(os.Stderr, "%s: %vn", os.Args[0], err) continue } split(f) f.Close() } } }
  • 14. Composing Programs We build complex programs from simple ones #!/bin/bash ./uppercase | ./split We build complex programs from simple ones cat text.txt | ./uppercase | ./split
  • 15. Building Technical Capital cat text.txt text2.txt | ./uppercase | ./split | sort | uniq - We build in a short while a program that does the majority of the work of a spell checker - Pros: - Less lines of code - Less buggy - More efficient - Short build time
  • 16. Difficulties - Requires discipline - It requires much more time in planning for the future of the project - Requires experience - To create a good plan, you have to know where the difficulties in software development are. (i.e Communication between teams) - It's not a complete science - There's no hard science telling us how to implement the UNIX philosophy. May depend on the size of the project or future expectations
  • 17. How to learn - Learn from experienced developers - Learn from their mistakes and build on them - Learn by doing - Learn from your own mistakes. Start small and build your way up - Reflect on your code - Look over your code and see where you could redesign or refactor your code and make it better.
  • 18. Hope you all gained some new knowledge
  • 19. Links - https://www.youtube.com/watch?v=aY7OzGPaP5I&t=176s&ab_channel=P hilipBohun - https://www.youtube.com/watch?v=dDwXnB6XeiA&ab_channel=StevieJay - https://en.wikipedia.org/wiki/The_Art_of_Unix_Programming - https://medium.com/ingeniouslysimple/philosophy-of-unix-development- aa0104322491