Tuesday, May 22, 2018

Why Python & its popular libraries

This is second article in the series of python programming language by Zachary Farley , you can check the first article from here.




History of python?
In 1999 Van Rossum submitted a funding proposal to DARPA titled “Computer Programming for Everybody” where he defined the clear goals for Python: 
1) An easy intuitive language
2) Code understandable as plain English
3) Suitability for everyday tasks, allowing short development times


Now Python has become one of the most popular programming languages to learn, next to Java and JavaScript.
A little more background into Python: it was first released in 1991 by a Dutch programmer named  Guido van Rossum. Being known as the BDFL  (Benevolent Dictator For Life) he continues to oversee language development. A fun fact about Rossum is that he worked at Google from 2005 to 2012 and spent half of his time developing Python.
What is Python? 
Some of the two most common types of languages are compiled and interpreted languages. A few examples of compiled languages include C, C++ and COBOL. A couple interpreted languages are Ruby and JavaScript.  Python belongs to the latter as an interpreted programming language. In layman’s terms, when executing a Python script, each line must be read in by the PC and translated before executing the script. There are different advantages and disadvantages to a compiled language versus an interpreted one. 
For a compiled programming language, when the source code is ran through a compiler you obtain a very efficient program that can be executed a number of times rapidly. Compared to  interpreted languages these need to be parsed, interpreted and then executed – making them less efficient than a compiled language. However, there are advantages to interpreted languages as well. Since they are less labor intensive, it’s easy to build, test and change when needed. It’s often good to use for prototyping applications.
Figure 1: Pros and Con list ( source: https://learntocodewith.me/programming/source-code/ )

The type of project you’re working on will guide you to which language you need to learn. One unique advantage python holds over other languages is the highly readable syntax that’s very close to the English language. See below a Python and Java function to check if a number is even or odd
Figure 2: function created in python to tell even and odd numbers
public static void main(String[] args) { 
System.out.println("Enter a number to check if it is even or odd"); System.out.println("Your number is " + (((new Scanner(System.in).nextInt() & 1) == 0) ? "even" : "odd")); 
} (3)
Figure 3: Function created in Java to tell even and odd numbers
As you can see, when compared to a standard language such as Java, the Python script is easier to understand to the untrained eye. Another key point to make is that Python doesn’t require brackets as it uses the off-side rule, which is expressed using indentations.

What are the uses?
Here are some companies and what they use Python for:

  • D-Link uses Python to create a multi threaded application that allows one machine to service multiple devices when upgrading firmware over a network connection. In this case Python provides an easy-to-use serial communication code when completing the task.
  • ForecastWatch uses Python for data analysis by collecting thousands of weather forecasters and comparing against actual climatological data to determine the accuracy of their weather predictions. They also use pythons enhanced multi threading abilities to collect forecasts from around 5,000 sources daily.
  • Industrial Light and Magic uses Python in the production process of scripting complex, computer graphic-intensive films. This was done by integrating Python within larger software systems (even if written in C or C++), allowing Python to interact with the systems in situations where other languages can’t.
  • United Space Alliance uses Python’s dynamic typing and pseudo code syntax to unit test each piece of an Oracle database within a workflow automation system. The simplicity of Python allows this company to develop the tool faster.
  • Advantages of Python include the extensive support libraries for areas like string operations; web service tools; OS interfaces; and protocols. It also includes a powerful integration feature making it easy to develop web services and processing XML with the simple readability.
Of course, no language is without fault. In Python’s case it has not solved many enterprise solutions, users of Python find it difficult to using other languages. They become so accustomed to its features and library collection when switching to languages that need variable type declaration, or even adding curly braces for loops the task proves difficulty. 

Another common limitation with Python is that it’s weak for mobile computing and is only known for desktop and server platforms. Python also has underdeveloped database access layers. For example, common enterprise solutions use Java database connectivity (JDBC) or open database connectivity (ODBC). Lastly, as mentioned above, being an interpreted language, Python eventually slows down during compilation. However, it’s seen as fast for other web applications.

What are popular libraries?
Django
Django is a Python framework for web development. It allows developers to take web application to launch in hours. There are also numerous extra support such as built-in RSS feeds, site maps, user authentication, and even content administration. Django websites are also highly secure and protect against common security mistakes such as SQL injections.
Figure 4: Youtube website that’s run and powered by Django (source: https://www.shuup.com/blog/25-of-the-most-popular-python-and-django-websites/ )

Pandas and MatPlotlib
Pandas is an open source Python library that provides high-performance , easy-to-use data structures for analyzing data. With built-in support for numerous file formats, it creates data frame objects to perform easy data manipulation. Working in tandem with Pandas, the library Numpy adds fundamental data types such as vectors and matrices for increased support into heavy data analysis. The library MatPlotlib provides the visualization for the analysis to see results outside of a table format.

Tensorflow
Another good library that Python can use is Tensorflow. Tensorflow is an open source library meant for machine learning. Created by Google, Tensorflow offers an easy overlay with Python to implement its many computational features. Machine learning has rapidly increased in presence recently, with well-known applications including Google Maps’ traffic predictions. By performing a congestion analysis Google Maps will offer an alternate route in hopes of a shorter ETA. 


Facebook's own feature of offering friend request recommendations is another result of machine learning. By comparing your profile information with other users, Facebook makes a “guess” at who you most likely know and would want to connect with. For example, if you and another coworker list your job under workplace, Facebook will most likely suggest them to add as a new friend. 

Lastly are product recommendations. Ever wonder why you get emails offering coupons of websites you just visited? Well, now you know it’s all thanks to machine learning. If you stay on a web page for a certain amount of time or even look for a certain product on multiple web pages, it’s all factored in when you see a new email with a coupon on the new video game you were looking to buy.
Figure 7: Tensorflow image processing example (source: https://www.tensorflow.org/tutorials/image_recognition )


I hope this will definitely help you , and if you like it please share it with your friends and colleagues as well.

Thanks for reading



0 comments:

Post a Comment