Why learn Python
From Wikiversity
Advantages [edit]
- Easy learning: Python is quite easy to learn, so it's a good choice if you have never programmed before.
- Readability: The syntax is very clear, so it is easy to understand program code. (Python is often referred to as "executable psuedo-code" because its syntax mostly follows the conventions used by programmers to outline their ideas without the formal verbosity of code in most programming languages; in other words syntax of Python is almost identical to the simplified "psuedo-code" used by many programmers to prototype and describe their solution to other programmers. Thus Python can be used to prototype and test code which is later to be implemented in other programming languages).
- Very high-level language: Python looks way more like plain English than like a low-level language or machine code, so you can more easily write down what you think instead of first having to translate it to code in your mind.
- Object oriented programming (OOP): OOP allows you to create classes of objects which can closely model behavior of real-world or abstract objects. Most modern programming languages are object-oriented (such as Java, C++) or have support for OO features (such as Perl version 5 and later). Additionally object-oriented techniques can be used in the design of almost any non-trivial software and implemented in almost any programming or scripting language. (For example a number of Linux kernel features are "objects" which implement their own enscapsulation of behavior and data structive via pointers, specifically pointers to functions, in the C programming language). Python's support for Object oriented program is of great benefit to new programmers because they will be encountering the same concepts and terminology in most of their work in any environment and while using any programming language.
- Free language: Python is both open source and free. It's freely available and distributable and you can freely modify it and re-distribute your modified versions.
- Compatibility: Python runs on all major operating systems.
- Widely supported: Python has an active support community with many web sites, mailing lists, and USENET "netnews" groups that attract a large number of knowlegeable and helpful participants.
- Extensive "standard library": Python is famous for being the "batteries are included" language. There are over 300 standard library modules which contain modules and classes for a wide variety of programming tasks. For example the standard library contains modules for safely creating temporary files (named or anonymous), mapping files into memory (including use of shared and anonymous memory mappings), spawning and controlling sub-processes, compressing and decompressing files (compatible with gzip or PK-zip) and archives files (such as Unix/Linux "tar"), accessing indexed "DBM" (database) files, interfacing to various graphical user interfaces (such as the TK toolkit and the popular WxWindows multi-platform windowing system), parsing and maintaining CSV (comma-separated values) and ".cfg" or ".ini" configuration files (similar in syntax to the venerable WIN.INI files from MS-DOS and MS-Windows), for sending e-mail, fetching and parsing web pages, etc. It's possible, for example, to create a custom web server in Python using less than a dozen lines of code, and one of the standard libraries, of course.
- Extensible: In addition to the standard libraries there are extensive collections of freely available add-on modules, libraries, frameworks, and toolkits. These generally conform to similar standards and conventions; for example almost all of the database adapters (to talk to almost any client-server RDBMS engine such as MySQL, Postgres, Oracle, etc) conform to the Python DBAPI and thus can mostly be accessed using the same code. So it's usually easy to modify a Python program to support any database engine.
Disadvantages [edit]
- Speed: Python is executed by an interpreter instead of compilation, which causes it to be slower than if it was compiled and then executed. However, for most applications, it is by far fast enough. One Python idiom is "Speed isn't a problem until it's a problem."
- "Too Easy": When one has mastered Python one can become so accustomed to its features, particularly its dynamic late-binding model and its many libraries, that it can be difficult to learn and become comfortable in other programming languages. Specifically the need to declare variable "types" and to "cast" values from one type to another and the syntactic requirements for adding semi-colons and curly braces used by other programming languages can be viewed as tedious or onerous by experienced Python programmers.
Further reading [edit]
- http://www.linuxjournal.com/article/3882 - Eric Raymond (of "The Cathedral and the Bazaar" fame) recounts his first experience with Python. A great story.
- http://altis.pycs.net/2003/07/21.html - Bruce Eckel (of "Thinking in C++" and "Thinking in Java" famve) uses Python as his language of choice; he explains why in a detailed analysis here. And yes, there's a "Thinking in Python" book.
- http://www.python.org/about/success/ - a small sampling of the things Python has been used for.
- http://archaeopteryx.com/python - an evaluation of Python by a software company called Archaeopteryx. Check out the links on the left-hand side, especially "Resources for Python Evaluators" and the "Complementing other tools" section within that, which discusses how you can incorporate Python into Java, C++, .NET, COM, XML...