High-Level and Low-Level Programming
Undergraduate Mechatronics Engineering Student
Faculty of Graduate Studies & Research
University of Alberta
Abstract - The rise in the popularity of programming has raised debate about the benefits of low-level and high-level programming languages. This article explains the difference between a high-level language like Python and a low-level language like C in simple terms and why they both have a place in the world of coding.
When referring to something as either high-level or low-level, many people would assume that low-level refers to the basics while high-level refers to something complex. In the case of programming languages, the language is the tool that the programmer uses to direct the computer. It turns out that using a high-level language means that the language does much of the heavy lifting for the programmer, making writing code much more straightforward. A low-level language requires the programmer to consider more factors when writing code and to write more lines of code for a similar function. This makes coding in a low-level language more challenging and time-consuming. Low-level languages do have their own unique benefits which will be explained in this article.
Python is a popular high-level language that is becoming increasingly popular in industries that would typically not use coded solutions. Python is known to be very easy to learn due to its simple syntax and intuitive operations.
The first difference between a language like C and a language like Python is the capabilities that are natively available. In both C and Python, programmers can import modules that allow them to do certain operations. Python modules are used for complex operations like the machine learning module PyTorch, the high-level math module NumPy, the graphical user interface module Tkinter, or the game development module Pygame. The Python standard library includes most general operations like simple math or input/output.
C has no-built in functions which means you need to import a library just to “printf(“Hello world!\n);”. A good example that shows the difference between C and Python is sorting a list. If a list named my_list has the integers [5, -4, 0, 8, -3], both languages can be used to sort this list from lowest to highest. Figure 1 demonstrates the implementation of this code in Python.
Line 1 creates the list, line 2 sorts the list, and line 3 displays the list to the user. This program is really as simple as sorting a list could be. Figure 2 shows how this same code is implemented in C.
The first 3 lines import some functions that enable this to work. “.sort()” does not exist in C so one of many possible sorting algorithms is used to sort the list by repeatedly comparing each number in the list with the number next to it. Lists cannot be printed in C so another function is used to individually print each number in the list on one line. Lastly, the main function initalizes the list, calculates the length of the list, sorts the list using bubble sort, and then prints the list to the user. When comparing the 3-line Python code and the 38-line C code it is easy to see how writing in C is significant more tedious than in Python. This small-scale example is amplified in the millions of lines of code that make up polished programs.
III. BENEFITS OF LOW-LEVEL PROGRAMMING
High-level languages like Python require multiple levels of computation to happen before execution. Python cannot be directly compiled into an executable that your computer can run as a program. This is because the development environment is doing a lot of behind-the-scenes work for the programmer. While the memory usage of most Python programs will be minimal on any modern computer, every bit of memory matters when the program is something that runs continuously. Unlike high-level languages, low-level code can directly be compiled into machine code that the computer can run. The low-level program will only load data that is important for the program to run, making it highly efficient. This is why operating systems like Windows, Mac OS, Chrome OS, Linux, Unix, iOS and Android are all written in C or its direct derivates (C++, Objective C).
One example of a low-level program is the game RollerCoaster Tycoon. The game was released on Windows in 1999 and was written 99% in x86 assembly code and 1% in C . Assembly code is the lowest level of code, but would not be considered to be a realistic option for writing a program for most programmers. For context, the line print(‘Hello World!’) would be written in up to 25 lines in assembly code.
RollerCoaster Tycoon was written by one single developer, took two years to develop, and would be considered torture by modern standards. In the early 2000s, most middle-class families did not have high-speed computers that could run large games without occasionally freezing or crashing. RollerCoaster Tycoon was a complex game for its time with fully customizable roller coasters and hundreds of tracked “AI” characters walking around the map. Because the game was written in assembly code, it ran perfectly on even the slowest devices. This led to its popularity among many young families as it was cheaply available and ran on the devices they already had.
C is the most popular language for embedded systems. Embedded systems include things like calculators, digital cameras, or even digital alarm clocks. The price of memory has been decreasing each year, but it is still a significant cost when manufacturing a product with an embedded system. When manufacturing thousands of units of the same product, the price of memory adds up. Optimized C programs use very little memory, making the product cheaper to manufacture. The initial struggle of writing in a low-level language greatly pays off in the long run.
IV. USES OF HIGH-LEVEL PROGRAMMING
Programming purists tend to despise high-level programming languages but their benefits are undeniable. Python is the perfect language for automating small tasks on a small scale like customized smart home solutions, Discord/Twitter bots, or automating calculations that are part of larger workflows. Many “old school” companies that typically used programs like Excel to process their data are slowly making the shift to a high-level language like Python. Python is perfect for creating customized solutions because it could take as little as an hour or two to get your program up and running. One of the biggest challenges of writing code in low-level languages is accounting for small things like variable data storage, or minor syntax errors like forgetting a “;” after each line. Python takes away these challenges by adapting to the way the program was written.
V. CLOSING REMARKS
Python is becoming increasingly popular as the first language that programmers learn, but this has its own pros and cons. While Python is easy to learn, many programmers struggle to learn complex low-level languages after getting comfortable with the simplicity of Python. For this reason, it is best that programmers who plan to learn additional languages do not learn Python first. A language like C is difficult to learn but if someone can understand C, they will easily pick up any C-derived language. For a programmer who only wants to use one language for simple applications, Python is the perfect language to learn.
 C. Sawyer, “About Chris Sawyer & Game Development,” Chris Sawyer Software Development, 2003. [Online]. Available: http://www.chrissawyergames.com/faq3.htm. [Accessed: 20-Oct-2022].