The myth of the
small script
Mario A. Santini - Full Stack Developer
JUG TAA
The Mith Of The Small Script
This is a story about how what seemed a simple
problem, actually is rather complicated
A New Task
• Your boss: “Please, write a small script that
prints out the 3rd and the 5th column of this
file.”
• Your boss: “Keep in mind, I need it: ASAP!”
Have A Deep Look At The
Task
• Looks as an easy and short task, but actually you
missed some important infos.
• Most of the requirements or client expectations
arrive like this.
• It is simple for your boss, just because it’s easy to
explain. Of course if you don’t go deep inside the
details.
Actually software is made by details!
Remember, We Don’t Have
Time
• On those situations it is better for you to go
back to your boss with something to show, and
not with something to ask about.
• So we guess the missed details and do our best!
The Script - Requirements
• We know we have a text file divided in columns
to parse
• We guess the files are on a Linux server
• We guess just to printout the result
• The fast and easy way is to write a very short
shell script in bash
The Script - The Code
$ cat ./my_short_script.sh <<EOF
> #!/bin/bash
>
> data="./data"
>
> cut -f 3,5 -d , ${data}/$1
>
> EOF
$ chmod a+x ./my_short_script.sh
>>> Test it!
$ ./my_short_script.sh the_file_to_compute.cv
head3,head5
field3,field5
field3,field5
field3,field5
field3,field5
field3,field5
field3,field5
field3,field5
field3,field5
…
Pretty easy, pretty fast!
The Script Doesn’t Work!
• Your boss: “Sorry, I launched your script and got
an error: “
cut: Error reading ./data/
… after a complicated interview with your boss…
• You: “You miss the parameter, that’s why the script fail”
• Your boss: “Sorry man, I don’t know anything about a
parameter”
The First Amendment
• Add a simple help
• Check if the data file is in input, if not print the
help
You don’t know how
people will use your code!
The First Amendment
$ cat ./my_short_script_v2.sh
#!/bin/bash
function help {
echo "Please run the script as follow example:"
echo ""
echo "$ $1 <data_file_name>"
echo ""
echo "<data_file_name>: as the name of a csv file in data folder"
echo ""
echo ""
}
if [ "$#" -ne 1 ]; then
help $0;
exit 0
fi
data="./data"
cut -f 3,5 -d , ${data}/$1
The Second Amendment
• Your boss: “It works with few files, but some times I
got an error, could you have a look please?”
• After a little investigation you have:
• your script doesn’t support fields that contains the
field separator, even if they are quoted and valid
csv files;
• your script doesn’t support different field
separator characters.
Now Works But…
• Your boss: “In some files, we need to print out
the 2nd and the 4th columns, instead of the 3rd
and the 5th.”
Things changes!
A New Improovement
• Your boss: “I would like to work at home, but I
don’t have any other Unix like Oss there.”
Possible Solutions
• Docker / Vagrant
… it’s a bunch of gigs and more headaches for the future…
• Cygwin…
No thanks… too complicated for my boss.
The better solution is to re-write your script in a way that it is more
easy to manage:
use a general purpose programming language like Java
( Of course you could use your preferred language to, but remember, we are a Jug! ;) )
What “Like Java” means
• a powerful general purpose language
• could run on many different operating systems
without needs of changes on the source code
• have a long list of available libraries that helps
writing less code and doing things fast and safe
• supported from a wide and huge community
• Last but not last: to be Open Source, better if FOSS
What We Need
In order to re-write the script in Java, we could
even use a short cut by including useful libraries:
• A lib to handle csv files
• A lib to handle command line options
• An installing framework tool
• A lib for log
Conclusions
In the real word you never have something as “a
small script”.
Even if you are a developer like me, and you have
your HD full of small scripts doing everything you
need to be done.
Conclusions 2
The scripts you write for yourself are simple
because you don’t have to deal with many choices,
you just design it as it perfectly fits your needs.
And more, you fits the world to fits your script.
If your needs will changes, you know it and you’ll
change the scripts first or adapt the environment
as convenient.
Conclusion 3
Don’t be afraid to use general purpose languages
like Java.
They are so widely spread because you could use it
for short programs, like the one we shown you, to
very complicated systems made by millions of line
of code.
So think it easy and simple as KISS wants, but not
be trivial.
The Java Version
https://github.com/alexmario74/jcut
Thank you!

More Related Content

PDF
JOSA TechTalks - Compilers, Transpilers, and Why You Should Care
PPTX
Sql server baselines
PDF
Effective text editing with vim
PPTX
5 reasons to program javascript
PPT
Top 10 Scalability Mistakes
ODP
Even internet computers want to be free: Using Linux and open source software...
PPT
Independent Publisher New England Ebook Presentation. April 27m 2012
PDF
Script for the water conservation and management presentation
JOSA TechTalks - Compilers, Transpilers, and Why You Should Care
Sql server baselines
Effective text editing with vim
5 reasons to program javascript
Top 10 Scalability Mistakes
Even internet computers want to be free: Using Linux and open source software...
Independent Publisher New England Ebook Presentation. April 27m 2012
Script for the water conservation and management presentation

Viewers also liked (19)

PDF
Lambda architecture
ODP
Docker jug taa
DOCX
Short film script
DOCX
Planning the cast
PPTX
Unit 11 analysis of scripts
PPT
Lottery choice
PPTX
Story board of example script
DOCX
Short film script
PPTX
Bachelor Thesis Presentation (Italian)
DOCX
Script for short film analysis
PDF
Script Example
PPTX
How To Write A Great Corporate Video Script
PPTX
Short film script presentation
DOC
Troy script
DOC
Dakilang mangingibig.script
DOCX
Fast Love - Comedy Short Film Script
DOCX
Abhishek group script of role play
PPT
roleplay in the classroom
PPTX
Anatomy of maxilla and mandible
Lambda architecture
Docker jug taa
Short film script
Planning the cast
Unit 11 analysis of scripts
Lottery choice
Story board of example script
Short film script
Bachelor Thesis Presentation (Italian)
Script for short film analysis
Script Example
How To Write A Great Corporate Video Script
Short film script presentation
Troy script
Dakilang mangingibig.script
Fast Love - Comedy Short Film Script
Abhishek group script of role play
roleplay in the classroom
Anatomy of maxilla and mandible
Ad

Similar to The myth of the small script (20)

PDF
Lab4 scripts
PPTX
Unix - Shell Scripts
PDF
Shell Script
DOCX
What is a shell script
PPTX
Chapter 2: Introduction to Bash Scripting
PDF
Shell scripting _how_to_automate_command_l_-_jason_cannon
PPT
Unix Shell Scripting Basics
PPT
Unix shell scripting basics
PPT
Unix And Shell Scripting
PPT
PPT
390aLecture05_12sp.ppt
PDF
Lets make better scripts
PPTX
shellScriptAlt.pptx
PPTX
Linux System Administration
PPTX
AOS_Module_3ssssssssssssssssssssssssssss.pptx
PPT
Linux-shell_scripting for new user/shell script
PDF
Real programmers use programming languages (Not shell scripts)
PDF
Bash production guide
PPTX
Geecon 2019 - Taming Code Quality in the Worst Language I Know: Bash
Lab4 scripts
Unix - Shell Scripts
Shell Script
What is a shell script
Chapter 2: Introduction to Bash Scripting
Shell scripting _how_to_automate_command_l_-_jason_cannon
Unix Shell Scripting Basics
Unix shell scripting basics
Unix And Shell Scripting
390aLecture05_12sp.ppt
Lets make better scripts
shellScriptAlt.pptx
Linux System Administration
AOS_Module_3ssssssssssssssssssssssssssss.pptx
Linux-shell_scripting for new user/shell script
Real programmers use programming languages (Not shell scripts)
Bash production guide
Geecon 2019 - Taming Code Quality in the Worst Language I Know: Bash
Ad

More from Mario Alexandro Santini (7)

PDF
A Safe Dock for our Programs
PDF
Rust With async / .await
PDF
Rust_Threads.pdf
PDF
The_Borrow_Checker.pdf
PDF
The Rust Programming Language
PDF
Introduction to typescript
A Safe Dock for our Programs
Rust With async / .await
Rust_Threads.pdf
The_Borrow_Checker.pdf
The Rust Programming Language
Introduction to typescript

Recently uploaded (20)

PDF
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
PPTX
Foundations of Marketo Engage: Nurturing
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PPTX
UNIT II: Software design, software .pptx
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
PDF
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
PPTX
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
PPT
3.Software Design for software engineering
PPTX
AI Tools Revolutionizing Software Development Workflows
PPTX
Human Computer Interaction lecture Chapter 2.pptx
PDF
IT Consulting Services to Secure Future Growth
PPTX
Relevance Tuning with Genetic Algorithms
PPTX
Folder Lock 10.1.9 Crack With Serial Key
PPTX
Improving Audience Engagement ROI with ERP-Powered Insights
PPTX
FLIGHT TICKET API | API INTEGRATION PLATFORM
PDF
Top AI Tools for Project Managers: My 2025 AI Stack
PPTX
Beige and Black Minimalist Project Deck Presentation (1).pptx
PPTX
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
PPTX
Chapter_05_System Modeling for software engineering
PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
Foundations of Marketo Engage: Nurturing
ROI from Efficient Content & Campaign Management in the Digital Media Industry
UNIT II: Software design, software .pptx
Understanding the Need for Systemic Change in Open Source Through Intersectio...
WhatsApp Chatbots The Key to Scalable Customer Support.pdf
Bandicam Screen Recorder 8.2.1 Build 2529 Crack
3.Software Design for software engineering
AI Tools Revolutionizing Software Development Workflows
Human Computer Interaction lecture Chapter 2.pptx
IT Consulting Services to Secure Future Growth
Relevance Tuning with Genetic Algorithms
Folder Lock 10.1.9 Crack With Serial Key
Improving Audience Engagement ROI with ERP-Powered Insights
FLIGHT TICKET API | API INTEGRATION PLATFORM
Top AI Tools for Project Managers: My 2025 AI Stack
Beige and Black Minimalist Project Deck Presentation (1).pptx
Swiggy API Scraping A Comprehensive Guide on Data Sets and Applications.pptx
Chapter_05_System Modeling for software engineering
Top 10 Project Management Software for Small Teams in 2025.pdf

The myth of the small script

  • 1. The myth of the small script Mario A. Santini - Full Stack Developer JUG TAA
  • 2. The Mith Of The Small Script This is a story about how what seemed a simple problem, actually is rather complicated
  • 3. A New Task • Your boss: “Please, write a small script that prints out the 3rd and the 5th column of this file.” • Your boss: “Keep in mind, I need it: ASAP!”
  • 4. Have A Deep Look At The Task • Looks as an easy and short task, but actually you missed some important infos. • Most of the requirements or client expectations arrive like this. • It is simple for your boss, just because it’s easy to explain. Of course if you don’t go deep inside the details. Actually software is made by details!
  • 5. Remember, We Don’t Have Time • On those situations it is better for you to go back to your boss with something to show, and not with something to ask about. • So we guess the missed details and do our best!
  • 6. The Script - Requirements • We know we have a text file divided in columns to parse • We guess the files are on a Linux server • We guess just to printout the result • The fast and easy way is to write a very short shell script in bash
  • 7. The Script - The Code $ cat ./my_short_script.sh <<EOF > #!/bin/bash > > data="./data" > > cut -f 3,5 -d , ${data}/$1 > > EOF $ chmod a+x ./my_short_script.sh >>> Test it! $ ./my_short_script.sh the_file_to_compute.cv head3,head5 field3,field5 field3,field5 field3,field5 field3,field5 field3,field5 field3,field5 field3,field5 field3,field5 … Pretty easy, pretty fast!
  • 8. The Script Doesn’t Work! • Your boss: “Sorry, I launched your script and got an error: “ cut: Error reading ./data/ … after a complicated interview with your boss… • You: “You miss the parameter, that’s why the script fail” • Your boss: “Sorry man, I don’t know anything about a parameter”
  • 9. The First Amendment • Add a simple help • Check if the data file is in input, if not print the help You don’t know how people will use your code!
  • 10. The First Amendment $ cat ./my_short_script_v2.sh #!/bin/bash function help { echo "Please run the script as follow example:" echo "" echo "$ $1 <data_file_name>" echo "" echo "<data_file_name>: as the name of a csv file in data folder" echo "" echo "" } if [ "$#" -ne 1 ]; then help $0; exit 0 fi data="./data" cut -f 3,5 -d , ${data}/$1
  • 11. The Second Amendment • Your boss: “It works with few files, but some times I got an error, could you have a look please?” • After a little investigation you have: • your script doesn’t support fields that contains the field separator, even if they are quoted and valid csv files; • your script doesn’t support different field separator characters.
  • 12. Now Works But… • Your boss: “In some files, we need to print out the 2nd and the 4th columns, instead of the 3rd and the 5th.” Things changes!
  • 13. A New Improovement • Your boss: “I would like to work at home, but I don’t have any other Unix like Oss there.”
  • 14. Possible Solutions • Docker / Vagrant … it’s a bunch of gigs and more headaches for the future… • Cygwin… No thanks… too complicated for my boss. The better solution is to re-write your script in a way that it is more easy to manage: use a general purpose programming language like Java ( Of course you could use your preferred language to, but remember, we are a Jug! ;) )
  • 15. What “Like Java” means • a powerful general purpose language • could run on many different operating systems without needs of changes on the source code • have a long list of available libraries that helps writing less code and doing things fast and safe • supported from a wide and huge community • Last but not last: to be Open Source, better if FOSS
  • 16. What We Need In order to re-write the script in Java, we could even use a short cut by including useful libraries: • A lib to handle csv files • A lib to handle command line options • An installing framework tool • A lib for log
  • 17. Conclusions In the real word you never have something as “a small script”. Even if you are a developer like me, and you have your HD full of small scripts doing everything you need to be done.
  • 18. Conclusions 2 The scripts you write for yourself are simple because you don’t have to deal with many choices, you just design it as it perfectly fits your needs. And more, you fits the world to fits your script. If your needs will changes, you know it and you’ll change the scripts first or adapt the environment as convenient.
  • 19. Conclusion 3 Don’t be afraid to use general purpose languages like Java. They are so widely spread because you could use it for short programs, like the one we shown you, to very complicated systems made by millions of line of code. So think it easy and simple as KISS wants, but not be trivial.