Should I learn Python or Shell Scripting | Difference Between Two?
Are you confused between Python and Shell scripting?
As the way Python is dominating in the automation field, is it going to replace shell scripting in the near future?
I have lots of thought about it.
Whether if you have programming experience or new to the programming, it is very difficult to choose one programming language to learn out of two languages.
The one which will help you to grow your career.
As I have experience of working on Python and shell scripting language, I can promise you to give you detail insight. After that, it’s easy for you to choose one.
In an earlier post, you might have read 5 simplest programming language for beginners. It’s a very nice compilation by Scarlett Erin for beginners. In this post, I am writing about Python vs shell scripting.
There are huge numbers of computer languages. Some programming languages emerge over the decades, some vanishes with no time.
Here is one of comment on my blog. Chehal is very career oriented guy and right now he is in dilemma over Python vs Shell scripting.
Do you have the same question?
Choosing right or wrong programming can change your career either way. It’s not easy. So, I decided to contemplate my opinion by writing this article.
Now let’s talk about Python vs shell scripting.
Table of Contents:
To give input you should know the difference between Python scripting and Shell scripting.
What is Shell Scripting?
Shell is just a programming interface that is useful to access operating system services. And Shell scripting is nothing but writing multiple commands on the shell to complete a certain task.
What are the different shell scripting languages?
When we talk about shell scripting, Bash is considered to be the most prominent Unix shell and programming language.
Apart from Bash, there are many scripting languages such as sh, csh, dash… But, bash is more matured and widely used among all.
Bash is used to writing command line coding. So, in other words, we can say, bash is command language.
Whereas Python is not a just scripting language, it is a complete programming language.
Is Python Programming a Scripting Language?
Why do I call Python as a complete programming language rather just scripting language?
Now consider you have to write code that needs a data structure to store the input or output values.
You can use a variable in a bash script to store a single value. But there is no such advance data structure privileged such as list, dictionary or set.
These advance data structures are available in Python.
Python can be used for web development as it has various web development framework such as bottle framework. The wide range of libraries can be useful for data science and data analytics, machine learning and what not…
Looking at this scalability and use cases, it’s wise to call Python as a complete programming language.
Python vs Shell Scripting:
Now let’s start differentiating Python Vs Shell Scripting.
Suppose you are writing a script to replaces some string in a file with other string. It is just a couple of lines of code in a bash script.
That, you can also write in Python. And if you are importing any library, it will be even easy to make the things work for you.
Other advantages of Python over bash is, there are lots of external libraries you can import and use it without any hustle. It reduces your program length and coding effort.
In Python, most of the things you can do by calling one line function from the imported library. Isn’t that so easy?
But there are some places you need shell scripting.
What is the use of Shell scripting?
Shell or bash scripting is only preferable if you are interested in system administration work. And it is extremely powerful in this field.
Now on another side, if you know both Python and bash script. It will be honey over the bread.
If you are a newbie, I would suggest learning basic bash command that can speed up your productivity working in Linux environment.
You don’t need to be the God of shell programming unless you are working as data administrator. Basic commands are enough to improve your productivity.
So command line coding language like bash scripting and complete programming language like Python have their own features to differentiate between them.
Moreover, I would suggest you go and learn both of these computer languages. You can find it very handy and useful if you are primarily working on a Unix or Linux environment.
How to Start Learning Shell scripting?
There are many basic shell commands to start. Use these shell script commands in the day to day work.
Once you get good hands on these basic commands, start using iteration such as loop, while or piping. Play with an external data source such as contents in a file. Accessing data from a file and manipulating it.
Where does shell scripting lack over Python?
In other words, what are the advantages of Python over Shell scripting?
Up to now, it’s very fine with shell scripting.
Suppose you want to use an array, data structure or you need some data manipulations in your project task. Things will start feeling the heat with bash scripting. And this is where you need to hone some Python skills.
After getting comfortable with shell commands, learn the Python programming language. You will find an improvement in your productivity as you have basic shell commands for quick moves.
I can tell you, whatever you have done with bash scripting you can do the same with Python programming.
Just to give you some example…
Reading .csv file in Python is so much easy if you are using the external libraries.
More to that, if you start working on its prominent datatypes like the list, dictionary, set. It will downsize the huge numbers of lines of code. You will be amazed, how a small line of Python code can make such big things happen.
One of the quick examples is…
You can create HTTP-server in Python with a just single line of code.
In my case, I learned Python first and then started learning bash script. I was so amazed by the Python programming.
But if you are a beginner, according to my experience you should go for bash scripting first. Start using basic bash commands. Then start learning python programming.
Once you learn both languages, you will realize my opinion.
Note: I have differentiated both of these languages depending on their programming capabilities. Nowhere I have considered trends and job requirements. If you are looking for a future job, you can read my post regarding types of programmer need for a software developer job in the future. You will understand, why I am saying Python is the future programming language.
This is my opinion, and I am sure it will even work for you.
I have shared many Python tricks, and unfortunately, I would not make time to write about shell scripting. Soon I will start writing about shell scripting. If you are a subscriber, you will get all these bash script codes in your email box. If you are not a member of CSEstack FREE weekly newsletter, don’t forget to subscribe now and start learning.
Pro Tips: If you are learning any programming language, practice as much as you can. Don't keep the code up to you. I strongly suggest share it with your friends. Make use the LinkedIn account or any of your programming group, write over there.
Even you can also write and share your code on the CSEstack portal. There are many authors on CSEstack they share their code and discuss with other members. Getting other programmers comments on your code is a kind of improving yourself. I have shared all my initial learning and Python Tricks on CSEstack portal. Trust me, if you read any program, you will forget one day. But when you start writing, it will remain with you.
My Thought about Python vs Shell Scripting:
If you have any question or if you have any doubt, don’t let it burst inside you. It is very harmful. Write in the comment below. Let’s have a fruitful discussion. I would like to help you with my best.
If you make your mind to choose Python, here is you can start learning Python.
Now you have enough to make your choice for Python vs Shell scripting. Kindly do share this with your programming friends as well. It will help them to make their decision and to determine their goodwill future.