CHAPTER 2: Advantages and Disadvantages
Of course, Python is far from being the only programming language you can use for your coding needs. But why should you choose it? Here are some of the most common reasons Python is recommended:
Easy-to-learn Syntax. It doesn’t matter if you have been acquainted with other programming languages before -- both programmers and non-programmers can use Python easily because of its syntax.
Readability. If ever you need to take apart a code that someone else wrote (either for study or troubleshooting), you can easily do it due to the clear readability of the programming language. In fact, there are some who refer to Python as an “executable pseudo-code” due to its syntax following natural language used by real humans. This gets rid of the verbosity and formality used by other languages, and also goes as close as possible to the way programmers habitually outline their ideas. This bring Python inherently close to the very simple “pseudo-code” programmers use to outline their thoughts and solutions to other programmers. Even programmers who write in other languages are given to using Python as a testing ground wherein they can test their code before implementing it in a different language.
High-level Usage. Unlike the inscrutable low-level languages, Python allows you to code a lot faster.
Object-Oriented. In a nutshell, object-oriented programming lets a user create data structures which can then be re-used. This reduces the amount of repeated work that needs to be done. Languages often define objects with namespaces, which can then edit themselves using certain keywords. Python shares this distinction along with other languages such as Java, C#, and C++. Object-oriented languages can also be used to design almost any type of non-trivial software, which can in turn be implemented in any scripting or programming language. A good example lies in a number of Linux kernel features, which feature objects. These implement their own encapsulation of data structure and behavior through pointers to functions in C. New programmers benefit greatly from Python’s support for object-oriented programming since the same concepts and terminology used in its study will invariably appear in the work environment. In case the new programmer decides to learn a new language, the same object-oriented concepts can still be used.
Free of Charge. Being a Free and Open-Source Software (FOSS), Python is accessible to anyone. The pre-made binaries are distributed by the Python Software Foundation, and the code can also be modified and re-distributed as allows by the CPython license.
Cross Platform. As has been mentioned before, Python is available on all major operating systems—MS Windows, Mac OS X, and different flavors of Linux.
Wide Support. Like any good open-source project, Python has an active community that is complete with different forums, websites, mailing lists, and news groups that also attract knowledgeable contributors from different tech scenes.
Safety First. Unlike other languages based in C, Python does not have any pointers. This makes the language much more reliable. Errors also never silently pass unless this is explicitly ordered. This will allow the user to read and see why the resulting program crashed, allowing efficient error correction.
All In. In the language of many coders, Python has been known as the “batteries included” language. This means that there are more than 300 different standard library modules that contain both classes and modules for a large subset of programming scenarios. Some of these include creating temp files, mapping the files into memory (through anonymous and shared memory mappings), spawning sub-processes and controlling them, decompressing and recompressing files, accessing indexed database files, and a lot more. These libraries can also offer interface to various GUI, as well as send emails, and parse web pages. With less than a dozen code lines, a person can create a custom web server using the Python language—powered by one of these standard libraries.
Greatly Extensible. Aside from the standard libraries, there are also extensive collections of add-on modules that are freely available. There are also frameworks and libraries, as well as toolkits that all conform to conventions and standards. As an example, nearly all the database adapters (used in talking to any client-server engine like Oracle, MySQL, Posrgres, etc.) conform to Python DBAPI, thus allowing users to access them using the same code. This makes it easy to modify Python programs to support any type of database engine.
Then of course, like with any programming language, not everything is a rosy walk in the park. There are a couple of disadvantages in it that one should still watch out for as he learns:
Speed. Unlike languages that need to be separately compiled and then executed, Python is executed by an interpreter. This causes it to be slower. For most applications, this will not pose a problem. However, there are certain instances when an increase in speed is desirable. This brings up one idiom coined by Python users: “Speed is not a problem until it is a problem”.
Simple Rules. Python is a very easy programming language. However, when one has mastered it, one can be too accustomed to its features especially its late-binding dynamic models and its extensive libraries. Thus, when shifting to a new language that does not have these, the user may run into difficulties adjusting. In other languages, one typically has to declare the types of variables first and then cast values from this type to another. There are also requirements for adding curly braces and semi-colons (as well as other syntactic differences) in other languages that a Python user may take for granted.