Join my course at Udemy (Python Programming Bible-From beginner to advanced )

Blogger templates

Monday 6 April 2020

Introduction to Python


Introduction to Python

Python implementation was started by Guido Van Rossum in the year 1989. First release of Python came out in the year 1990. Python 2.0 was released in 2000 and Python 3.0 was released in 2008.

To start with let's write HelloWorld program in Python and C++ to see the comparison between Python and C++

Python and C++ HelloWorld Program

HelloWorld code in Python can be written in one line but same code in C++ require around 5+ lines. Based on the above simple code, we can't make any conclusions but we can easily see that Python provides a framework to write simple and compact code.

Why use Python ?

This is the basic question that comes into the mind of every programmer.  Why to choose python when there are so many programming languages available. Many times the decision is guided by project implementation. But for a new application development one needs to know the advantages and disadvantages to take the right decision about Python.

Readability, Uniformity & Code reuse

Python focus on software quality makes it very different from other programming language. Python focus on readability, uniformity and Code reuse makes it very different. Python follows forceful formatted code and this make Python code uniform. This also takes care of any mistakes that may happen because of unformatted code as shown below :


Possible If/else error because of badly formatted code
From first look, the ELSE statement looks to be ELSE of outer IF. Even a seasoned programmer will make this error in first glance of code.  On the other hand, this type of error is not possible in Python as ELSE of corresponding IF will always be aligned to its IF. 

Python supports code reuse through the implementation of 'class', modules and procedural programming that reduces the code redundancy and increases the code reuse. OOPs functionality in Python is optional as this is not required to start on Python.

Developer productivity

Python has many features/advantages that makes it well suited to increase the productivity of developer.
- Python code size is generally lesser than other programming languages (like C++ and JAVA ). It has been observed that Python code is 1/3rd or 1/5th of C++/JAVA coding for same functionality. Less coding means lesser time to develop, lesser code to debug and maintain and hence increased productivity for developer.
- Dynamic typing allows developer not to worry about the datatype of a variable. Python internally takes care of resolving the data type in python statement. Developer can concentrate of application design free from the worries of data type.
- Python does not have the compile and link step. Developer write the code and proceed to run the code. The intermediate steps of compile and link does not exist in Python. This contributes to rapid development cycle.

 Support Libraries 

Python comes with good collection of support libraries. It has prebuilt library for basic python functionality, text pattern support, application support, network programming support etc. In addition to this there is good support for other domains. With Python one can do System programming, Database Programming, GUI based programming, Data Science, Machine Learning etc. It has grown over many domains and the list will continue to grow.

Others

The list for python features continue to grow. Python has tremendous support for cross platform. Same python code can run on Windows, Linux and other platforms without any change. Python code can invoke C/C++ library that makes the Python as fast as C/C++ platform. Many machine learning and data science platform invokes C/C++ APIs that make Python code execute faster. Python can also integrate with JAVA, and .NET platforms helping in product customization.

Python is completely free with great Python online support. Python source code is completely free and is available over internet.

Performance implication with Python

There are performance implication with Python. Python code does not run as fast as C/C++ code and it may not be very good choice if timing is a factor.
But Python capability to invoke C/C++ APIs make it quite interesting that combines the Python capability for ease of use and maintenance with C/C++ capability to run faster. For example NumPy libraries uses C API that makes Python faster by passing the data to external low level APIs. 
PyPy is another step towards making Python faster. According to Python creator (Guido van Rossum) "If you want your code to run faster, you should probably just use PyPy". On an average PyPy code runs 4.4 times faster than CPython.

Summary

The reach of Python is huge and now a days it is being used by many companies in diverse domains. Python has its own advantages and disadvantages. Python capability to integrate with C/C++/JAVA/.NET etc platforms provides us the capability to use Python's strength of 'ease to use' with the the speed of low level compiler language. PyPy work to make Python faster will be interesting to follow in future.












Share:

0 comments:

Post a Comment

Feature Top (Full Width)

Pageviews

Search This Blog