1. What is Python?
Python is a programming language that is freely available and that makes solving a computer problem almost as easy as writing out one's thoughts about the solution. It can be written once and run on almost any computer without needing to change the program. In this section, you can learn more about what Python is, how it is used, and how it compares to other programming languages. Use the menu below to browse the various sections of this article.
2. A Brief History of Python
Python was first created by Guido von Rossum in 1990 and was named after the Brit-com Monty Python's Flying Circus. It has since been developed by a large team of volunteers and is freely available from the Python Software Foundation. The most recent version of Python, 2.5, was released in September, 2006.
Python is now found in many incarnations. At the website of the Python Software Foundation, Python is written in C. Other incarnations exist. A Java-based version of Python exists in Jython and may be used to work with Java code natively. Iron Python, a C# version, exists for the .Net and Mono platforms and allows C# programmers access to Python's power and flexibility. In each of these instances, Python is written in one language and works natively with that language; however, it also interacts very well with other languages through its many modules.
For purposes of research and development, there is also a Python implementation written in Python itself. The project PyPy was founded in 2003 in order to enable Python programmers to change the behaviour of the Python interpreter at will. While it is an open source project, being developed openly by a community of developers for free distribution and modification, PyPy is also supported by the European Union as a Specified Targeted Research Project (STReP), part of the FP6 funding program.
3. How Python is Used
Python is a general purpose programming language that is able to be used on any modern computer operating system. It may easily be used for processing text, numbers, images, scientific data, or anything else which one might save on a computer. It is used daily in the operations of the Google search engine, the video sharing web site YouTube, NASA , and the New York Stock Exchange. These are but a few of the places where Python plays important roles in the success of business, government, and non-profit organisations; there are many others.
Python is also an interpreted language. This means that it is not converted to computer-readable code before the program is run but at runtime. In days gone by, this type of language was called a scripting language, intimating its use for trivial or banal tasks. However, programming languages such as Python have forced a change in that nomenclature. Increasingly, large applications are written almost exclusively in Python. As mentioned above, in addition to being used by Google and NASA to complement other languages, Python is used almost exclusively for such applications as YouTube and the web-based transaction system of the New York Stock Exchance (NYSE).
Some other ways that you can apply Python are:
- Programming CGI for Web Applications
- Building an RSS Reader
- Reading from and Writing to MySQL
- Reading from and Writing to PostgreSQL
- Creating Calendars in HTML
- Working with Files
4. How Does Python Compare to PHP?
As it is another programming language, the commands and syntax of Python differ from other interpreted languages. PHP is increasingly displacing Perl as the lingua franca of down-and-dirty web development. However, more than either PHP or Perl, Python is much easier to read and to follow.
At least one downside which PHP shares with Perl, however, is its squirrely code. Because of the syntax of PHP and Perl, it is much harder to code programs that exceed 50 or 100 lines. Python, on the other hand, has readability hard-wired into the very fabric of the language. The readability of Python makes such programs easier to maintain and extend, as well.
While it is starting to see more general usage, PHP is, at heart, a web-oriented programming language. The name itself stands for "PHP: Hypertext Processor", suggesting the fact that it was meant to output web-readable information, not handle system-level tasks. This difference is exemplified in the fact that one can develop a web server in Python that can understand PHP (e.g., Zope), but one cannot develop a web server in PHP that can understand Python.
Finally, Python is object-oriented. PHP is not. This has significant implications for the readability, maintability, and scalability of programs written in each.
5. How Does Python Compare to Perl?
Python is an excellent language for large or complex programming projects. Integral to programming in any language is making the code easy for the next programmer to read and maintain. It takes great effort to keep Perl and PHP programs readable. Where Perl gets unruly after 20 or 30 lines, Python remains neat and readable, making even the largest projects easy to manage.
For its readability, ease of acquisition, and extensibility, Python was recently chosen by MIT for students learning to program. In addition to readability and extensibility, Python offers much faster application development. For more on Perl vs. Python, see Eric Raymond's Why Python?.
In addition to easy syntax and substantial processing abilities, Python is sometimes said to come with "batteries included" because of its extensive library, a repository of pre-written code that works "out of the box".
6. How does Python compare to Ruby?
Python is frequently compared to Ruby. Both are interpreted and therefore high-level. Their code is implemented in such a way that one need not understand all of the details. They are simply taken care of.
Both are object-oriented from the ground up. Their implementation of classes and objects allow for greater re-use of code and ease of maintainability.
Both are general purpose. They can be used for the simplest of tasks like converting text or for much more complicated matters like controlling robots and managing major financial data systems.
There are two major differences between the two languages: readability and flexibility. Due to its object-oriented nature, Ruby code does not err on the side of being squirrely like Perl or PHP. Instead, it errs in being so obtuse that it is often unreadable; it tends to presume upon the programmer's intentions. One of the chief questions asked by students learning Ruby is "How does it know to do that?". With Python, this information is typically plain in the syntax. Aside from enforcing indentation for readability, Python also enforces transparency of information by not assuming too much.
Because it does not assume too much, Python allows for easy variation from the standard way of doing things when needed while insisting that such variation be explicit in the code. This give power to the programmer to do what is necessary while ensuring that those who read the code later can make sense of it. Very often, once a programmer uses Python for a few tasks, they find it hard to use anything else.
7. How Does Python Compare to Java?
Both Python and Java are object-oriented languages with substantial libraries of pre-written code that can be run on almost any operating system. Their implementations, however, are very different.
Java is neither an interpreted language nor a compiled language. It is a bit of both. When compiled, Java programs are compiled to bytecode -- a Java-specific type of code. When the program is run, this bytecode is run through a Java Runtime Environment (jre) in order to convert it to machine code, which is readable and executable by the computer. Once compiled to bytecode, Java programs cannot be modified.
Python programs, on the other hand, are typically compiled at the time of running, when the Python interpreter reads the program. They can, however, be compiled to computer-readable machine code. Also, Python does not use an intermediary step for platform independence. Instead, platform independence is in the implementation of the interpreter.
