Python is a widely used, general-purpose, high-level back-end programming language thatโs highly valued by startups who need to quickly prototype and develop applications, as well as data-driven companies that need to integrate data analysis and statistical techniques into their workflows.
Its combination of readability, flexibility, and suitability to data science operations have made Python one of the most popular and beloved languages according to developers on Stack Overflow. In this article, weโll explore what sets Python apart from other programming languages, why itโs popular with data scientists, and what you should look for in a Python engineer.
High-level, readable, and efficient
One of Pythonโs defining characteristics is its efficiency. Every programming language has to balance the programmerโs time and the machineโs resources. Python is biased toward the former, with a guiding philosophy that comes down to โthere should be oneโand preferably only oneโobvious way to do something.โ That can mean thereโs a bit of a learning curve as developers learn the ins and outs of Python syntax, but the upside is that developers can do more with fewer lines of code compared to more lower-level implementation languages like Java or C++. This efficiency is especially valuable for startups who need to quickly prototype applications and get them to market.
Python is also famous for its code readability, meaning that an application written by a developer in Python is more likely to be intelligible to the developers who have to maintain it months and years down the line.
Beloved by data scientists
Along with R and Java, Python is one of the most popular languages for data science and statistical analysis. For data scientists, Python combines Javaโs suitability for building high-traffic web applications with Rโs focus on executing complex statistical functions.
Another one of Pythonโs strongest assets is its extensive set of libraries. These libraries can make it easier for developers to perform complex machine learning or statistical analysis tasks without having to rewrite many lines of code. Some of the most popular libraries include tools for data manipulation and visualization (NumPy, SciPy, and matplotlib), data mining and Natural Language Processing (Pattern, NLTK). Perhaps unsurprisingly, Python is the language of choice for organizations with data-heavy workflows, from YouTube to the New York Stock Exchange to the National Web Service.
Python basics
- Itโs object-oriented.
- Itโs cross-platform, working on Linux, Windows, Mac, and most other operating systems.
- Pythonโs standard library supports:
- HTML & XML
- JSON
- E-mail processing
- HTTP Server libraries, easy for developing servers, and support for FTP, IMAP, and other Internet protocols
- Itโs free and supported by an active open-source community.
- Itโs often substituted for PHP in the LAMP software stack.
The Python developerโs toolbox
What should you look for in a Python engineer? Experience on large-scale, high-traffic applications is at the top of the list, along with fluency in SQL and database optimization. Common duties and core skills of Python developers include modular programming, object-oriented programming, and extensive experience with SQL.
A guide to Python web frameworks
Full-stack or microframework?
One of your main considerations in choosing a framework should be the size and complexity of your project. If youโre trying to get a feature-rich web app that will integrate with the rest of your organizationโs systems, then a full-stack option could potentially save your team lots of time and effort. If, on the other hand, youโre working on a small, relatively simple project with few requirements, then a microframework might have everything you need.
A related question is how much โscaffoldingโ you need from a framework. A full-stack option should have just about everything you need to actually build a functioning web appโform generators, templating, access control lists, etcโso your team can assemble the pieces as needed. This is an attractive option for teams that are trying to get a product together quickly because it allows them to focus on actually building the app and not the stuff that goes around it. But if you have complex custom requirements or are working with a lot of customized software already, you may not be able to take advantage of all those libraries in the first place.
Full-stack options
There are a bunch of full-stack options when it comes to Python frameworks. Some prominent examples include TurboGears 2, Pylons, and Web2py. That said, the most popular option, by far, is Django.
Django is the most popular Python framework around, and itโs easy to understand why. Thousands of websites are currently using Django, from daily newspapers to social media and sharing sites to major foundations and nonprofits. Since Django was originally developed for use in the newsroom, itโs no surprise that major daily publications like the Washington Post and The Guardian rely on it. Startups like Eventbrite and Disqus have turned to Django to scale quickly, while social media behemoths like Instagram and Pinterest have used it to power their dynamic web apps.
As a framework, Django is known for being fast to build and friendly to beginning programmers. Itโs a โbatteries includedโ framework, meaning it supplies all the critical components you needโtemplate rendering, ORM, authentication, routing, etc. Itโs also exceedingly well-documented, which isnโt necessarily the case with some other popular frameworks.
By taking care of a lot of decisions, Django can dramatically speed up the time it takes to bootstrap a new project. What you gain in speed, though, you may lose in long-term flexibility. For example, Djangoโs built-in ORM is considered fine for a majority of cases, but itโs not as powerful an ORM as SQLAlchemy, which is widely viewed as the best Python database abstraction tool. While you can theoretically use SQLAlchemy with Django, youโll lose a lot of the functionality that makes Django so appealing to begin with.
Web2py is another popular full-stack framework. One thing to keep in mind about Web2py is that it doesnโt support Python 3. The original developer of Web2py has promised a Python 3-compatible successor, but as of 2017 it hasnโt appeared.
Despite now being nearly a decade behind the latest version of Python, Web2py is still used by many major organizations, including a number of international banks. What makes this older framework still appealing for many developers? For one, itโs as easy to learn as Django, but also more flexible and extremely portable. The same code can run on just about any VPS with a SQL database or MongoDB, whether AWS or Google App Engine.
Web2py is extremely well supported with book-length documentation and a passionate community behind it. Another neat feature is that Web2py comes with its own IDE that includes a code editor, debugger, bug ticketing system, one-click deployment, and more. If your organization is committed to Python 2 for the foreseeable future or you plan to make use of some older Python libraries and software, then Web2py could suit your needs just fine.
Pyramid isnโt technically a full-stack framework. It instead bills itself as the โGoldilocksโ framework, feature-rich without enforcing one way of doing things, lightweight without leaving you on your own as your app grows. Itโs a favorite framework among many experienced Python developers thanks to its modularity and transparency, and has been used by small teams as well as tech giants like Dropbox, Yelp, SurveyMonkey, and Mozilla.
Practically speaking, nearly all of Pyramidโs components can be swapped out. You can choose how you connect to a database, or even what type (or types) of databases you want to be able to connect to. It doesnโt enforce certain choices for you the way Django does, and it also discourages the sort of โmagicโ features that handle certain tasks automatically but donโt always behave in a predictable or desirable manner.
Pyramid is often celebrated for its security system, which makes it easy to set up and check access control lists. Another point worth calling out is Pyramidโs Traversal system for mapping URLs to code, which can make building RESTful APIs much easier.
Microframeworks
What if you donโt need the hand-holding or complexity of a full-stack framework? Many modern web apps require lots of moving parts, including database abstraction, form validation, and customized access control lists. But there are also plenty of web apps that donโt need any of that. For those kinds of projects, a microframework may be just whatโs needed.
These ultra-lightweight frameworks are designed to get dead simple web apps up and running as quickly as possible. Their feature sets are minimal by designโanything functionality you could get by installing another library is deliberately left out. The plus side of this minimalist approach is that your code can be cleaner and your website faster. This is at least partly because microframeworks are generally less abstracted than full-stack frameworks. The code you write will be much closer to actual HTTP functions than with a more beginner-friendly framework.
Flask is probably the most popular microframework for Python, and one of the most popular Python frameworks, period. Like Django, itโs designed to get web apps up and running as quickly and painlessly as possible. Despite its small size, Flask has been used by big companies, including LinkedIn and Pinterest.
However, thereโs a twist, which is that Flask is definitely suited to smaller, simpler projects than Django. Out of the box, you can expect a development web server, built-in unit testing, and support for Google App Engine. Now hereโs a taste of what you wonโt find in vanilla Flask: Thereโs no database abstraction layer, form validation, authentication, or upload handling, though all these features can be added through extensions. Some of the more common setups include Jinja2 for templating and CouchDB or SQLAlchemy for the database.
Some Python developers prefer Flask to Django because Flask is more โpythonic,โ in that it mostly sticks to the Python mantra of there being one way to do something and that code should be explicit about what itโs doing. If you value clean code and donโt mind coding closer to the metal, then Flask may be a good option.
Bottle is another popular microframework. It was originally designed for building web APIs, and thatโs still a good use case for it. Whatโs novel about Bottle is it tries to implement everything in one single file, which should give you an idea of how โmicroโ itโs designed to be. Out of the box it comes with routing, templating, utilities, and some basic abstraction over the WSGI standard. As with Flask, youโll be coding much closer to the metal than with a full-stack framework. Despite its small size, Bottle has been used by the Netflix team to build web interfaces.
Python vs. Ruby
First, the similarities
Both are high-level, server-side scripting languages focusing on simplicity and prioritizing rapid developmentโgetting things done fast, in fewer lines of code. These scripts eschew verbose code, strict hierarchy, and syntax correctness for more behind-the-scenes, object-oriented logic.
Theyโre used by entrepreneurs and startups alike to rapidly whip up web apps and prototypes, thanks to standard libraries, persistence support, and feature-packed frameworksโPythonโs Django framework, and Rubyโs Ruby on Rails. Both are interpreted scripting languages, which means they donโt require a compiler like Scala or C++ do. Compiled languages tend to run faster, though. Rule of thumb? What you get in speed of development, you lose in runtime speed.
Now, letโs dive into their differences, starting with Ruby.
Ruby & the Ruby on Rails framework
Created in 1995, Ruby is object-oriented to its core, influenced by languages like C++, Perl, and Java. Hereโs a look at Ruby, a language thatโs ideal for collaboration, speed, and businesses that want a programming language that thinks as fast as they do.
Preferred for: Web development, functional programming
Philosophy: โDo more with less.โ Developer freedom and flexibility, and more than one way to do thingsโsomething it inherited from Perl
Why developers love Ruby: Loose and creative coding, frequent updates, freedom and flexibility, and readable code thatโs never confusing
Python & the Django framework
Python is all about efficiency and supporting calculation-heavy applications used in the fields of data and science. Along with its Django framework, Python enables super fast development.
Preferred for: Academic and scientific programming. Python has a slew of libraries for data work.
Philosophy: โOne right way to do thingsโ
Why developers love Python: Stability over change, conservative code, fewer updates