Skip to content

The Development Environment

Writing code is, in its most basic form, writing text. A lot of text, with very strict rules. For this reason, developers tend to like a familiar environment centred around the text editing process, often with lots of personalisation. This section is not about that. It's also not about which text editor is best1. You can use any basic text editor, special development environments or swap and change to get a feel for a few.

This section is about how we develop python on Linux. This includes how the system knows what to do with Python files, how libraries are installed and maintained and also how we automate processes. Different languages and tools will offer different ways to do this, but the concepts are fairly similar regardless.

What is Python?

Python is a programming language. That might seem obvious, but some people like to call it a "scripting language". The difference between the two definitions isn't really clear, but usually a scripting language is light, small and not suitable for larger-scale development. Today, Python is one of the most popular languages and is used to build some very large software infrastructures. It's behind services like Youtube and also glues together Debian and its derivatives.

Python is also an interpreted language. Many languages require a compiler to turn source code into machine-specific instructions. Each CPU variant, OS, often even library versions, require a specific version of that machine-specific set of instructions. We say that the source code is turned into an executable binary. Python does not do this. Instead, the python interpreter reads the source code and executes it. This means the same python file can run on any system2.

Question

What do you think are the good and bad points of being an interpreted language compare to a compiled one, beyond those mentioned above?3

A python file usually ends with ~.py~. Technically, this is not required, but like with many file types, operating systems can use this to decide how to execute it. This applies to Windows and, in some circumstances, Linux. Even if that were not the case, it is very useful for a human to be able to identify a file by its extension.

Other than that, a Python file is just a text file.

To find out how to tell Linux how to execute a Python file, read Files and Execution.

Libraries

One of the things that makes Python so useful is the wide range of libraries available for it. These are called "modules" in Python and can be small and simple (providing easy coloured output, for example) or quite complex (such as implementing deep-learning artificial neural networks).

Libraries can be installed and maintained using the pip tool.

With Python being very common now, different libraries and versions can be required by different programs. Different operating systems have dealt with this kind of issue in different ways in the past,usually by trying to share libraries across the whole system4 but with modern development the goal is portability and ease of development rather than raw efficiency. Python programmers have the option of using Virtual Environments for their software projects, in which the libraries are installed specifically for their software, with exactly the right versions, and even the python interpreter is fixed and separate from the system-wide interface.

This is used a lot on this module. More information is available in the Virtual Environments section.

Automation

Development has many tasks that have configuration options and stages. Building documentation, running test suites, even building the virtual environment, all can have many options. Remembering the right order, combination and so on takes up valuable head-space for a developer and when you send your code to someone else, represents a lot of things to explain and/or document. It is useful, then, to automate these kinds of tasks. There are many ways to do this, but a common one is to use Makefiles.


  1. It's Emacs 

  2. Although whether it runs well is another matter. Cross-platform programming isn't as simple as picking a cross-platform language and then forgetting about it. 

  3. Think about: ease of deployment, security of your intellectual property, speed of execution and so on. 

  4. See "DLL Hell": https://www.drdobbs.com/windows/no-end-to-dll-hell/227300037