Explainer | Backend Code

by allsparkinfinite on 2024-12-28

I've talked about "magic" that happens on a server, in the backend. Let's understand the magic so sufficiently, it becomes indistinguishable from science.

Programming

No, I cannot teach you programming in this blog. But I can describe it for you, and you can learn it from other places.

Turing Machines And Binary Code

A Turing Machine, conceived by Alan Turing, is a machine that reads a series of 1s and 0s on a strip of tape, and manipulates them according to rules. This is a computer, at a very basic level, and every program is just a string of binary numbers when it is being run.

Assembly Language

One level of abstraction above, we have assembly language. This is a human-readable (debatable) version of the "rules" I mentioned above. If you remember x86 and ARM architectures, they have different rules, and thus different forms of assembly language.

High-Level Programming Language

Programming languages are built upon assembly and are more human-readable than assembly. Simple algorithms written in programming languages can often be understood by laypeople. Don't take any random code file and start reading it, though - you might as well cast your gaze upon Cthulu.

Abstractions

In programming, an abstraction is something that lets you access something else while also protecting you from the challenging details.
Babies first learn how to move one muscle intentionally, then a group of muscles, then ultimately learns how to walk (child development experts, don't say a word). 10 years later, you walk, skip, run, and jump without conscious thought to each muscle. You just think about how to move and the rest comes naturally.
Programming is the same. When you talk about 1s and 0s in binary, you don't care whether the 1s and 0s are physically stored as magnet orientations or charge levels. Code written in a programming language doesn't care which ruleset the CPU follows. And programmers love creating libraries to create an abstraction for something and then using that library as a deceptively simple component in other code.

Variables And Functions

Variables in programming languages are labels that refer to some data. This value could come in from user input, and manipulating these variables is how programmers do their magic.
Functions are labels too, but they refer to more code. They can take some variables as an input, and often provide an output. "Calling" a function with some variables as inputs (or "arguments") is a shorthand way of running that code with the provided variables.

Flow Of Control

Sometimes, you want to run some code in some cases, and other code in other cases. Manipulating this is called flow of control. Since only one command is "in control" at a time, you are manipulating how the control flows within the program.
Loops allow you to run the same set of commands over and over again, while conditional statements let you execute code if certain conditions are met.

Python

Python is, in my opinion, the best language to learn if one is looking to develop something quickly and not wide-reaching. It is slower than other programming languages (still blazing fast from a human's perspective), and easy to learn, write, and debug.

Web Servers

Flask, FastAPI, and Django are some examples of webserver libraries for Python.
You write code using these libraries by writing some functions in your code and attaching a path to some of them.
You run the code with a specified networking port, and the program listens on that port for REST API calls. When a call comes in, it takes a look at the path and runs its corresponding function.

Now go, learn programming and start developing web apps!
(If you want to)