Introduction to the world of Programming languages
Starting with Perl, both are pure scripting languages. But the intention behind using either is 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 forgiving language. Perl provides numerous ways to solve a problem. In the case of python, one needs to make a simple and proper way to do things. Whereas both the languages try to make the code as compact as possible, there are still reasons for choosing either language. 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 a 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 a 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 to program for the first time, you need to understand how it works. Perl can give the best understanding of this. But, it cultivates a bad habit of leaving your program vulnerable to bugs and problems. Thus, that is when Python comes into existence.
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 the 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 a 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; let us 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 the 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% of companies due to fear of stability||6+ years old. So, no worry about being stable.|
So, looking at the table, you will surely get a good understanding of how much they differ from each other. As Arnold Schwarzenegger said in the Movie: “Terminator: Genisys” :- “I am Old, But not Obsolete”. The 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 a few examples that I will be writing in both versions and show you 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:
>>>try: This_is_a_NameError except NameError, err: print err, '--> our error message’
>>>try: This_is_a_NameError 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 this will be huge enough for you to disassemble your whole code when you are coding problems.
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 start with python, and I hope that you will find Python much more attractive and easier to start with…
Here are some articles that will help you get more detail about Python’s New Future, so just go through the link.