Development language pros and cons

A developer's guide to the pros and cons of Python

Devotees talk about what's good (ease of use, IoT potential) and not so good (design issues, performance) about the language

Python snake

Development language pros and cons

Show More

Python is billed by the Python Software Foundation as being easy to learn and running everywhere. It's useful for a range of application types, including Web development, scientific computing, and education. Google and Instagram have been among the many users of Python, and the language scores well in popularity indexes.

But Python has had its issues, with questions raised about its performance and design quirks. To get to the bottom of what's right -- and maybe not so right -- about Python, InfoWorld Editor at Large Paul Krill asked dignitaries in the Python community for their input.

Python pros

Read it, use it with ease. "The main characteristics of a Python program is that it is easy to read," says Pierre Carbonnelle, a Python programmer and blogger who runs the PyPL language index. "This has benefits to you and to others. It helps you think more clearly when writing programs, and it helps the others who will maintain or enhance your program. In both cases, it requires less effort to write a Python program than to write one in another language like C++ or Java." Readability of Python facilitates open source development, Carbonnelle added.

Python is easy to use and extremely popular in academia, creating a large talent pool, says Sumit Chachra, CTO at Tivix, a software consulting firm that specializes in Python/Django development. Django and Python are leveraged by Tivix in Web and mobile development, he says.

Python is a very productive way to write code, says Stephen Deibel, of Wingware, which makes the Wing Python IDE. "Some of this comes from the simple syntax and readability -- there is virtually no 'boilerplate' at all. Some of it comes from the rich, well-designed built-ins and standard library and the availability of many third-party open source libraries and modules." By being easy to understand, the code is easier to maintain, he adds. 

Python, says Chachra, is dynamically typed and flexible, with code that is less verbose. However, he cites dynamic typing as a potential negative (see below).

Internet of things opportunities. Python may become popular for the Internet of things, as new platforms such as Raspberry Pi are based on it, Carbonnelle says. Raspberry Pi's documentation cites the language as "a wonderful and powerful programming language that's easy to use (easy to read and write) and with Raspberry Pi lets you connect your project to the real world."

Asynchronous coding benefits. Python, Deibel says, "is great for writing asynchronous code, which rather than threading uses a single event loop to do work in small units." This code, he says, is often easier to write and maintain without confusing resource contention, deadlocks, etc. "Python's generators are a great way to interleave running many processing loops in this approach." 

Multiparadigm approach bests Java. Python's programming approach is not as limited as Java's, Carbonnelle says. "For example, you don't need to create an OO class to print 'Hello world' in Python -- you have to in Java." Unlike Java, Python is multiparadigm and supports OO, procedural, and functional programming styles, he says. (Java recently added functional capabilities in Java 8.)

"In Python, everything is an object," says Brian Curtin, a member of the Python Software Foundation board of directors and a core contributor to CPython. "It's possible to write applications in Python using several programming paradigms, but it does make for writing very clear and understandable object-oriented code."

Python's cons

Speed can be an issue. "Because it is an interpreted language, it is often many times slower than compiled languages," Curtin says. "However, it comes back to separating the language from the runtime. Certain benchmarks of Python code run under PyPy run faster than the equivalent C code or others."

"A possible disadvantage of Python is its slow speed of execution," says Carbonnelle. But many Python packages have been optimized over the years and execute at C speed, he says.

Performance, Chachra says, "is slower compared to older languages such as C/C++ and even newer ones such as Go."

Absence from mobile computing and browsers. "Python is present on many server and desktop platforms, but it is weak in mobile computing; very few smartphone applications are developed with Python," says Carbonnelle. "It is also rarely seen on the client side of a Web application."

Python isn't in Web browsers, Deibel notes. "That's a real shame. There is brython, but I don't think it's real-world usable." Python is hard to secure, and that's why it is not in browsers, he adds. "There still isn't really a good secure sandbox/jail for Python, and I think it's considered basically impossible for CPython (the standard implementation). 

Design restrictions. Python devotees cited several issues with the design of the language. Because the language is dynamically typed, it requires more testing and has errors that only show up at runtime, Chachra says.

Python's global interpreter lock, meanwhile, means only one thread can access Python internals at a time, Deibel says. "This may be less important these days, since you can so easily spawn tasks out to separate processes using the multiprocessing module, or write asynchronous code instead." 

Curtin says there are a few conventions around the use of Python, but significant whitespace is one that is enforced by the interpreter. "The structure of Python programs must be consistent, so where brackets or other identifiers allow the user more freedom in other languages, indentation is what matters when it comes to Python."