Image Source: python.org
Introduction to the world of Programming languages
There are n number of programming languages out there. Heck, there are even n number of scripting languages out there. Then the question is why python? To be precise, Python is a scripting and not programming language. There is a thin line between being a programming language and a scripting language.
Starting with Perl, both are pure scripting languages. But the intention behind using either are totally different. To make it simple, Python has a set of defined rules that a programmer needs to follow, whereas Perl is more forgiving. But still, one doesn’t always need a forgiving language. Perl provides numerous ways to solve a problem.
In case of python, one needs to make a simple and a proper way to do things. Whereas both the languages try to make the code as compact as possible, there are still reasons of choosing either languages. When, a person is trying to develop something, he can choose to work with Perl if he does not have a defined time to complete a project.
But that’s not how the real world works, does it? In the real world, time is extremely important. One cannot spend time to find the smallest ways within multiple ways to get a proper piece of code right, especially when there is a need to write thousand pieces of codes. That is why, python comes into practice. Python has a defined set of rules, which one needs to follow, through which one can simply cultivate a habit of achieving desired results within small amount of time and making the code as compact as possible at the same time.
Though the code will not be as efficient as in Perl, but who cares? To give a proper example, think of it in this way: when you start to learn programming for the first time, you need to understand how it works. The best understanding of this can be given by Perl. But, it cultivates a bad habit of leaving your program vulnerable to bugs and problems. Thus, that is when Python comes into existence.
4.8 (4,355 ratings)
Python asks you to write your programs in a particular way, for example writing them in intended blocks, so that’s its easier to understand. This gets you into a habit of doing things in a suitable manner, because even if for some reason you drop the project, then any other person can look at the codes and it will be far easier for him to understand the codes than of that written in Perl.
Python has the least syntax possible. Besides, when learning a new language, one needs to know that just downloading an installer file isn’t sufficient. One needs to download other packages as well. But it isn’t the same in case of python.
If I talk about ruby, then it’s a totally different match. Although Ruby is a scripting language, both are made to do different thing. Besides writing this blog, if you ask me which one is better? I would recommend you to learn both. Because there is simply no comparison between the two. Ruby can be called as a mixture of Perl and python. It follows the philosophy of Perl to do things in multiple ways, but again it can also be used to write codes in a defined manner. I know that now you would be thinking simple maths:
Ruby = Perl + Python
Thus Ruby > Python.
But NO. You are wrong. Sometimes you don’t want everything. Having everything just makes life messier and complicated. To be precise, Ruby is an extrovert whereas Python is an introvert. When you actually write a program with little bugs, you will understand that Python is far more accurate and easier to debug, whereas Ruby is susceptible in nature. Python is easier to read, whereas ruby and Perl are easier to learn. Ruby is purely object oriented, even its classes and modules are object oriented.
Python is very near to Object oriented programming, but is not as raw as Ruby. Ruby has severe edges in aesthetics and web development, whereas python is used mainly for non-web tasks such as developing Gnome Apps, or API libraries. Python has a wide and diverse community of developers, whereas Ruby too has a great community, but is more focused on Rails Framework.
Now I would be assuming that you would be using python, lets proceed forward.
Installing Python on the system is not a tedious task. You can download python from its original website. When you go to the downloads section, you will see two types of downloads. One is v2.x and other would be v3.x. Now here, there would be people who are biased. Some people would think v2.7.9 is better, or someone else would think v3.3 or v3.4 is better.But the truth is neither.
Python v2.7.x vs Python v3.x
If you are new to programming, I would suggest going to v3.4. Although if you search the web, people would recommend you to go to v2.7.9. Personally, I would recommend using v3.x. Following is the Table of differences I have created to make it easier to understand.
|Python v2.7.x||Python v3.x|
|Old, but not Obsolete||New with New features|
|Very near to Object oriented programming||Pure Object oriented Libraries and Enumerations|
|Implicit Coding and Decoding||Better Tab completion and usage of history values|
|Easier to use for Web-development||Easier to learn python v2.7 after learning v3.4|
|Still being used by 90% companies due to fear of stability||6+ years old. So, no worry of being stable|
So, looking at the table you will surely get a good understanding how much they differ from each other. As Arnold Schwarzenegger said in the Movie: “Terminator: Genisys” :- “I am Old, But not Obsolete”. Same thing goes with Python 2.7. It is old, more like 20 years old, But still people prefer v2.7 rather than v3.x.
Now you know, what they are, let me give you few examples which I will be writing in both versions and will show you the difference why it is easier to understand python v2.7, if you know python v3.x.
Simplest Code Ever: Hello world.
In Python v2.7
>>>print ‘hello world’
In Python v3.3
>>>print (‘Hello world’)
Notice the braces? Yeah. That’s how it is. But it is still simple than writing hello world in C or C++. Now let’s look at some bigger programs:
except NameError, err:
print err, ‘–> our error message’
except NameError as err:
print(err, ‘–> our error message’)
Now you see the difference? The only difference is ‘as’ in the except statement. This may seem very small, but when you are coding problems, this will be huge enough for you to disassemble your whole code.
Enough about the differences. The only point of my whole blog, was to make you understand why Python is the chosen one among all these scripting languages. Point being cleared, now you can go off starting with python, and I hope that after reading this blog, you will find Python much more attractive and easier to start with…
Here are some articles that will help you to get more detail about the New Future of Python so just go through the link.