SlideShare a Scribd company logo
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

Viewers also liked

Lambda architecture
Lambda architectureLambda architecture
Lambda architecture
Mario Alexandro Santini
 
Docker jug taa
Docker   jug taaDocker   jug taa
Docker jug taa
Mario Alexandro Santini
 
Short film script
Short film scriptShort film script
Short film script
chloe spencer
 
Planning the cast
Planning the castPlanning the cast
Planning the cast
chloe spencer
 
Unit 11 analysis of scripts
Unit 11  analysis of scriptsUnit 11  analysis of scripts
Unit 11 analysis of scriptselliottickle
 
Story board of example script
Story board of example scriptStory board of example script
Story board of example scriptflickham
 
Short film script
Short film scriptShort film script
Short film script
Holly Thomson
 
Bachelor Thesis Presentation (Italian)
Bachelor Thesis Presentation (Italian)Bachelor Thesis Presentation (Italian)
Bachelor Thesis Presentation (Italian)Jovan Stevovic
 
Script for short film analysis
Script for short film analysisScript for short film analysis
Script for short film analysis
Adrianna Paniak
 
How To Write A Great Corporate Video Script
How To Write A Great Corporate Video ScriptHow To Write A Great Corporate Video Script
How To Write A Great Corporate Video Script
Bold Content Video Production
 
Short film script presentation
Short film script presentationShort film script presentation
Short film script presentationashhillfilm
 
Dakilang mangingibig.script
Dakilang mangingibig.scriptDakilang mangingibig.script
Dakilang mangingibig.script
DASeries
 
Fast Love - Comedy Short Film Script
Fast Love - Comedy Short Film ScriptFast Love - Comedy Short Film Script
Fast Love - Comedy Short Film Script
Lloyder
 
Abhishek group script of role play
Abhishek group script of role playAbhishek group script of role play
Abhishek group script of role playRiya Sinha
 
roleplay in the classroom
roleplay in the classroomroleplay in the classroom
roleplay in the classroom
africahi
 
Anatomy of maxilla and mandible
Anatomy of maxilla and mandibleAnatomy of maxilla and mandible
Anatomy of maxilla and mandible
Fardan Qadeer
 

Viewers also liked (19)

Lambda architecture
Lambda architectureLambda architecture
Lambda architecture
 
Docker jug taa
Docker   jug taaDocker   jug taa
Docker jug taa
 
Short film script
Short film scriptShort film script
Short film script
 
Planning the cast
Planning the castPlanning the cast
Planning the cast
 
Unit 11 analysis of scripts
Unit 11  analysis of scriptsUnit 11  analysis of scripts
Unit 11 analysis of scripts
 
Lottery choice
Lottery choiceLottery choice
Lottery choice
 
Story board of example script
Story board of example scriptStory board of example script
Story board of example script
 
Short film script
Short film scriptShort film script
Short film script
 
Bachelor Thesis Presentation (Italian)
Bachelor Thesis Presentation (Italian)Bachelor Thesis Presentation (Italian)
Bachelor Thesis Presentation (Italian)
 
Script for short film analysis
Script for short film analysisScript for short film analysis
Script for short film analysis
 
Script Example
Script ExampleScript Example
Script Example
 
How To Write A Great Corporate Video Script
How To Write A Great Corporate Video ScriptHow To Write A Great Corporate Video Script
How To Write A Great Corporate Video Script
 
Short film script presentation
Short film script presentationShort film script presentation
Short film script presentation
 
Troy script
Troy scriptTroy script
Troy script
 
Dakilang mangingibig.script
Dakilang mangingibig.scriptDakilang mangingibig.script
Dakilang mangingibig.script
 
Fast Love - Comedy Short Film Script
Fast Love - Comedy Short Film ScriptFast Love - Comedy Short Film Script
Fast Love - Comedy Short Film Script
 
Abhishek group script of role play
Abhishek group script of role playAbhishek group script of role play
Abhishek group script of role play
 
roleplay in the classroom
roleplay in the classroomroleplay in the classroom
roleplay in the classroom
 
Anatomy of maxilla and mandible
Anatomy of maxilla and mandibleAnatomy of maxilla and mandible
Anatomy of maxilla and mandible
 

Similar to The myth of the small script

Introduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsIntroduction to Python for Security Professionals
Introduction to Python for Security Professionals
Andrew McNicol
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013Iván Montes
 
ACM Init() lesson 1
ACM Init() lesson 1ACM Init() lesson 1
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
Derek Jacoby
 
Git Makes Me Angry Inside
Git Makes Me Angry InsideGit Makes Me Angry Inside
Git Makes Me Angry Inside
Emma Jane Hogbin Westby
 
Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...
Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...
Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...
panagenda
 
Vimperl
VimperlVimperl
Vimperl
Ynon Perek
 
miniproject.pptx
miniproject.pptxminiproject.pptx
miniproject.pptx
AnkurMahour1
 
Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.ppt
Rehnawilson1
 
PASS 24HOP Linux Scripting Tips and Tricks
PASS 24HOP Linux Scripting Tips and TricksPASS 24HOP Linux Scripting Tips and Tricks
PASS 24HOP Linux Scripting Tips and Tricks
Kellyn Pot'Vin-Gorman
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
Andrei KUCHARAVY
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
John Coggeshall
 
The View - The top 30 Development tips
The View - The top 30 Development tipsThe View - The top 30 Development tips
The View - The top 30 Development tipsBill Buchan
 
Week 5
Week 5Week 5
Week 5A VD
 
Week 5
Week 5Week 5
Week 5A VD
 
Improve your SQL workload with observability
Improve your SQL workload with observabilityImprove your SQL workload with observability
Improve your SQL workload with observability
OVHcloud
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
Weng Wei
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systemsBill Buchan
 

Similar to The myth of the small script (20)

Introduction to Python for Security Professionals
Introduction to Python for Security ProfessionalsIntroduction to Python for Security Professionals
Introduction to Python for Security Professionals
 
Programming Languages #devcon2013
Programming Languages #devcon2013Programming Languages #devcon2013
Programming Languages #devcon2013
 
ACM Init() lesson 1
ACM Init() lesson 1ACM Init() lesson 1
ACM Init() lesson 1
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 
Git Makes Me Angry Inside
Git Makes Me Angry InsideGit Makes Me Angry Inside
Git Makes Me Angry Inside
 
Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...
Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...
Way #5 Don’t end up in a ditch because you weren’t aware of roadblocks in you...
 
Vimperl
VimperlVimperl
Vimperl
 
miniproject.pptx
miniproject.pptxminiproject.pptx
miniproject.pptx
 
Python Programming1.ppt
Python Programming1.pptPython Programming1.ppt
Python Programming1.ppt
 
PASS 24HOP Linux Scripting Tips and Tricks
PASS 24HOP Linux Scripting Tips and TricksPASS 24HOP Linux Scripting Tips and Tricks
PASS 24HOP Linux Scripting Tips and Tricks
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Apache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 MistakesApache Con 2008 Top 10 Mistakes
Apache Con 2008 Top 10 Mistakes
 
The View - The top 30 Development tips
The View - The top 30 Development tipsThe View - The top 30 Development tips
The View - The top 30 Development tips
 
Week 5
Week 5Week 5
Week 5
 
Week 5
Week 5Week 5
Week 5
 
Improve your SQL workload with observability
Improve your SQL workload with observabilityImprove your SQL workload with observability
Improve your SQL workload with observability
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
 
First app
First appFirst app
First app
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systems
 
Lug
LugLug
Lug
 

More from Mario Alexandro Santini

A Safe Dock for our Programs
A Safe Dock for our ProgramsA Safe Dock for our Programs
A Safe Dock for our Programs
Mario Alexandro Santini
 
Rust With async / .await
Rust With async / .awaitRust With async / .await
Rust With async / .await
Mario Alexandro Santini
 
Rust_Threads.pdf
Rust_Threads.pdfRust_Threads.pdf
Rust_Threads.pdf
Mario Alexandro Santini
 
The_Borrow_Checker.pdf
The_Borrow_Checker.pdfThe_Borrow_Checker.pdf
The_Borrow_Checker.pdf
Mario Alexandro Santini
 
Vuejs
VuejsVuejs
The Rust Programming Language
The Rust Programming LanguageThe Rust Programming Language
The Rust Programming Language
Mario Alexandro Santini
 
Introduction to typescript
Introduction to typescriptIntroduction to typescript
Introduction to typescript
Mario Alexandro Santini
 

More from Mario Alexandro Santini (7)

A Safe Dock for our Programs
A Safe Dock for our ProgramsA Safe Dock for our Programs
A Safe Dock for our Programs
 
Rust With async / .await
Rust With async / .awaitRust With async / .await
Rust With async / .await
 
Rust_Threads.pdf
Rust_Threads.pdfRust_Threads.pdf
Rust_Threads.pdf
 
The_Borrow_Checker.pdf
The_Borrow_Checker.pdfThe_Borrow_Checker.pdf
The_Borrow_Checker.pdf
 
Vuejs
VuejsVuejs
Vuejs
 
The Rust Programming Language
The Rust Programming LanguageThe Rust Programming Language
The Rust Programming Language
 
Introduction to typescript
Introduction to typescriptIntroduction to typescript
Introduction to typescript
 

Recently uploaded

Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
vrstrong314
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
ShamsuddeenMuhammadA
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 

Recently uploaded (20)

Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Nidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, TipsNidhi Software Price. Fact , Costs, Tips
Nidhi Software Price. Fact , Costs, Tips
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptxText-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
Text-Summarization-of-Breaking-News-Using-Fine-tuning-BART-Model.pptx
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 

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.