Should I learn Python or Shell Scripting | Difference Between Two?
You will completely agree with me if I say…
“It is very difficult to choose out of two languages, especially if you are new to both of the Programming languages.”
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 a large number of computer languages. You just pick the word; it’s one of them. And it is always difficult to choose one language and start learning it. So here is one of comment I read from the early programmer about his dilemma over Python vs Shell scripting.
I am sure many have such dilemma. It’s not easy to guide one to make such a decision. So I decide to contemplate my opinion by writing this article.
Now let’s talk about Python vs shell scripting.
To give input you should know the difference between Python scripting and Shell scripting.
What is Shell Scripting?
Shell is just 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.
When we talk about shell scripting, Bash is considered to be most prominent Unix shell and programming language. (Apart from Bash there are many scripting languages such as sh, csh, dash…) Bash is used to writing command line coding. So, in other words, we can say, bash is command language rather than scripting.
Bash is used for writing command line code. So, in other words, we can say, bash is a language to give command over scripting.
Whereas Python is not a just scripting language, it is a complete programming language.
Is Python Programming or 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 are all 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, it’s not wrong to call it 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.
In Python, most of the things you can do by calling one line function from the imported library. Isn’t that so easy?
You might be surprised as I have only right words for Python.
Then you may ask…
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 need it for your shell scripting project. Basic commands are enough to improve your productivity.
So command line coding language like bash scripting and complete programming language like Python have their 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 Unix or Linux environment.
How to Start 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 this commands. Then start using iteration such as loop, while or piping. Accessing data from a file and manipulating it.
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 its 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 get starting Python skills.
After getting comfortable with shell commands, learn Python programming language. You will find an improvement in your productivity as you have basic shell commands for quicker moves.
I can tell you, whatever you have done with bash scripting you can do the same with python programming. Reading .csv file in Python is so much easy if you are using the external libraries.
More to that, if you starts 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 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. This is all because of my project requirement.
But if you are a beginner, according to my experience you should go for bash scripting first. Get used to for 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 software developer job in future. Even in that scope, Python is the best choice.
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 a 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 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.
If you have any point to mentioning 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 on 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 discussion and to determine their goodwill future.