Programming Languages Compared: Compiled, Interpreted, Markup and Query (Tech+)
What you’ll know
The difference between compiled, interpreted, scripting, markup and query languages; what a compiler and an interpreter actually do; and where each kind is used at work. You will do the same tiny job (add up 1 to 5) in Python, C, Bash, PowerShell, HTML and SQL, and watch how differently each one runs and fails.
Words in this lesson
Hover (or tap and hold) a dotted word for a quick definition.
- Source code — the instructions a person writes, as plain text
- Machine code — the numbers a processor actually runs
- Compiler — translates all the source code into a program file before it runs
- Interpreter — reads the source code and runs it straight away
- Script — a short program, usually interpreted, that automates a task
Why it matters. In IT you’ll meet a different language almost every week: a PowerShell script from a colleague, a Bash script on a Linux server, a SQL query behind a report, the HTML of a broken web page. You don’t need to write them all. You need to recognize which kind you’re looking at and know how it runs.
Two ways to follow a recipe
A processor (the CPU, the chip that does the work) only understands machine codeIn plain words: Long lists of numbers that the computer’s chip understands. People almost never write it by hand.Technical: Binary instructions for one processor family, such as x86-64 (most PCs) or ARM (phones, newer Macs). A program built for one family won’t run on the other.. People write source codeIn plain words: The instructions a person types, in words a human can read.Technical: Plain-text program files, such as add.py or add.c, written in a programming language’s rules (its syntax).. Something has to translate between them, and there are two ways to do it.
Imagine a recipe written in Italian, and you only read English.
- Compiled: a translator rewrites the whole cookbook in English first. It takes a while, and a single mistake anywhere means no book at all, but afterwards you cook quickly with no help. That translator is a compilerIn plain words: A tool that translates a whole program into a ready-to-run file before you use it.Technical: Checks the source code for errors, then produces an executable file of machine code. gcc compiles C on Linux; the result runs without the compiler installed..
- Interpreted: a friend stands next to you and reads each line aloud in English as you cook. You can start straight away and change the recipe between lines, but it’s slower, the friend has to be there every time, and a typo on line 40 only shows up when you reach line 40. That friend is an interpreterIn plain words: A program that reads your code and carries it out on the spot, line by line.Technical: Parses the source, usually turns it into an in-between form called bytecode, and executes it immediately. python3, bash and powershell are interpreters, and each must be installed to run its scripts..
The five kinds the exam names
| Kind | How it runs | Examples | Where you’ll meet it |
|---|---|---|---|
| Compiled | Translated into a program file first, then that file runs. Fast. | C, C++, Go, Rust | Operating systems, games, drivers, apps you install |
| Interpreted | Read and run on the spot by an interpreter. Quick to change. | Python, JavaScript, Ruby | Web sites, data analysis, AI tools, security tools |
| Scripting | Interpreted, and built to automate jobs on a computer | PowerShell, Bash, Windows batch (.bat) | IT admin: create accounts, clean up files, check settings |
| Markup | Not run at all: it labels content so another program can display it | HTML, XML, Markdown | Web pages, documents, settings files |
| Query | You describe the data you want; the database works out how to get it | SQL | Reports, apps, anything that stores records |
Lines blur in real life. Python is “interpreted” but quietly compiles to bytecode first, and Java and C# compile to an in-between form that a runtime then runs. For the exam, remember the basic split: compiled means translated ahead of time into a file you run; interpreted means read and run on the spot.
HTML is not a programming language. I said this at a party once and lost three friends and a web designer. Still true. — Nyx
Try it: one job, six languages
The job is tiny on purpose: add up 1 + 2 + 3 + 4 + 5 (the answer is 15) and print the result. Because the job never changes, the only thing you’re comparing is the language.
Where to type. Python, C, Bash and SQL run in Ubuntu on WSL (Windows Subsystem for Linux, a real Linux that runs inside Windows). Click Start, type Ubuntu and open it. No Ubuntu? Microsoft’s setup is one command, wsl --install, in PowerShell opened with “Run as administrator,” then a restart (we didn’t re-run that, as our test PC already had it). A Mac works too: open Terminal and use the same commands, though we haven’t tested on a Mac. PowerShell and HTML run on Windows itself: here is how to open PowerShell.
Each copy box below creates the file for you: the cat > add.py << 'EOF' line means “save everything up to the word EOF into add.py.” Copy the whole box, paste it into Ubuntu with a right-click, and press Enter.
First, make a folder to work in:
$ mkdir -p ~/langs && cd ~/langs
1. Python (interpreted)
$ cat > add.py << 'EOF'
# add.py - add up the numbers 1 to 5
total = 0
for n in range(1, 6):
total = total + n
print("Python says the total is", total)
EOF
A # starts a comment: a note for humans that the computer ignores. Now hand the file to the Python interpreter:
$ python3 add.py
Python says the total is 15
No separate build step and no new file: the interpreter read add.py and ran it on the spot. Anyone you send this to needs Python installed too.
2. C (compiled with gcc)
$ cat > add.c << 'EOF'
/* add.c - add up the numbers 1 to 5 */
#include <stdio.h>
int main(void) {
int total = 0;
for (int n = 1; n <= 5; n++) {
total = total + n;
}
printf("C says the total is %d\n", total);
return 0;
}
EOF
C is stricter: you declare that total is an int (a whole number), every line ends with ;, and the program starts in a function called main. Now compile it with gcc (the GNU Compiler Collection), then look at what it made:
$ gcc add.c -o add $ ls -l add.c add $ file add $ ./add
-rwxr-xr-x 1 steven steven 15960 Nov 4 20:46 add -rw-r--r-- 1 steven steven 227 Nov 4 20:46 add.c add: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=1602d689fddb727c42c573c5d25a52670cc40803, for GNU/Linux 3.2.0, not stripped C says the total is 15
Three things to notice:
gccprinted nothing. With compilers, silence means success.- A brand-new file called
addappeared, 15,960 bytes from a 227-byte recipe. That’s the executable: machine code plus the extra information Linux needs to load it. filesays ELF (Linux’s program format) for x86-64 (the PC processor family). You could copyaddto another 64-bit Linux PC and run it with no gcc installed. You could not run it on Windows (which wants an.exe) or on a phone (an ARM processor) without compiling again for them.
No gcc? Ubuntu will tell you, and sudo apt install gcc installs it.
3. Bash (scripting, on Linux and Mac)
$ cat > add.sh << 'EOF'
#!/bin/bash
# add.sh - add up the numbers 1 to 5
total=0
for n in 1 2 3 4 5; do
total=$((total + n))
done
echo "Bash says the total is $total"
EOF
$ bash add.sh
Bash says the total is 15
Bash is the shell you’ve been typing into, so a Bash script is simply the commands you’d type, saved in a file. The first line, #!/bin/bash (say “shebang”), tells Linux which interpreter to use if you run the file directly. Bash is awkward for math ($((total + n))) but brilliant at gluing other commands together.
4. PowerShell (scripting, on Windows)
Switch to a Windows PowerShell window for this one. Make a folder and create the script:
PS> New-Item -ItemType Directory -Force $HOME\langs | Out-Null; Set-Location $HOME\langs PS> @' # add.ps1 - add up the numbers 1 to 5 $total = 0 foreach ($n in 1..5) { $total = $total + $n } "PowerShell says the total is $total" '@ | Set-Content add.ps1
Everything between @' and '@ is saved into add.ps1. Variables start with $, and 1..5 means “the numbers 1 to 5.” Now try to run it the obvious way:
PS> .\add.ps1
.\add.ps1 : File C:\Users\you\langs\add.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
That’s not a bug: it’s a safety feature called the execution policy. Windows blocks script files by default, because a script file someone sends you can do real damage the moment it runs. (Typing commands one at a time is still allowed.) To run just this one script, once, without changing any setting:
PS> powershell -ExecutionPolicy Bypass -File .\add.ps1
PowerShell says the total is 15
Only use Bypass on scripts you wrote yourself or fully trust. If your PC already ran .\add.ps1 without the error, someone (often a developer tool) has relaxed the policy before.
The execution policy is the bouncer that checks IDs at the door, then lets anyone in who says “Bypass.” It stops accidents, not attackers. Treat it that way. — Nyx
5. HTML (markup)
Still in the same PowerShell window, create a web page:
PS> @'
<!DOCTYPE html>
<html>
<head><title>Adding 1 to 5</title></head>
<body>
<h1>The numbers 1 to 5</h1>
<ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul>
<p>HTML can show the numbers, but it cannot add them up.</p>
</body>
</html>
'@ | Set-Content add.html
Now open File Explorer, go to your user folder (the one with your name, under This PC → Local Disk (C:) → Users), open langs and double-click add.html. It opens in your web browser as a heading and a list of five numbers.
HTML is a set of labels called tags: <h1> means “this is a main heading,” <ul> “a bulleted list,” <li> “one item in it.” Most tags come in pairs, an opening <p> and a closing </p>. Notice what’s missing: there’s no way to say “add these up.” HTML describes what content is; it can’t make decisions or do math. Real web pages hand that job to JavaScript, an interpreted language your browser runs.
6. SQL (query)
Back in Ubuntu. SQL (Structured Query Language) talks to databases, and SQLite is a small database that lives in one file, or here, only in memory. Check whether you have it:
$ sqlite3 --version
Command 'sqlite3' not found, but can be installed with: sudo apt install sqlite3
Type sudo apt install sqlite3, enter your Ubuntu password when asked (the screen shows nothing as you type; that’s normal), and press Y to confirm. sudo means “do this as the administrator.” Then create the query and run it:
$ cat > add.sql << 'EOF'
-- add.sql - add up the numbers 1 to 5
CREATE TABLE numbers (n INTEGER);
INSERT INTO numbers (n) VALUES (1), (2), (3), (4), (5);
SELECT 'SQL says the total is ' || SUM(n) FROM numbers;
EOF
$ sqlite3 :memory: < add.sql $ sqlite3 :memory: "SELECT 1+2+3+4+5;"
SQL says the total is 15 15
Look at what’s missing this time: no loop. SQL is declarative: you say what you want (“the SUM of column n”) and the database decides how. :memory: means “use a temporary database that disappears afterwards.” The || joins two pieces of text together. The data and databases lesson goes further with tables and keys.
Break it on purpose
The clearest difference between compiled and interpreted code shows up when there’s a mistake. These commands copy each file with one typo (x instead of n; sed is a find-and-replace tool), then try to run the copies:
$ sed "s/total + n/total + x/" add.py > broken.py $ python3 broken.py
Traceback (most recent call last):
File "/home/you/langs/broken.py", line 4, in <module>
total = total + x
^
NameError: name 'x' is not defined
$ sed "s/total + n;/total + x;/" add.c > broken.c $ gcc broken.c -o broken $ ls broken
broken.c: In function ‘main’:
broken.c:7:25: error: ‘x’ undeclared (first use in this function)
7 | total = total + x;
| ^
broken.c:7:25: note: each undeclared identifier is reported only once for each function it appears in
ls: cannot access 'broken': No such file or directory
- Python started running and crashed when it reached line 4. In a long script, everything before line 4 would already have happened, which is why interpreted errors are called runtime errors.
- gcc refused to build anything: no
brokenfile exists. The compiler checked the whole program first, so the mistake was caught before anything ran. That’s a compile-time error.
Peek under the hood (optional)
What did the compiler and the interpreter actually make? Ask them to show you:
$ head -c 16 add | od -A x -t x1z $ python3 -m dis add.py | head -8
000000 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 >.ELF............<
000010
0 0 RESUME 0
2 2 LOAD_CONST 0 (0)
4 STORE_NAME 0 (total)
3 6 PUSH_NULL
8 LOAD_NAME 1 (range)
10 LOAD_CONST 1 (1)
- The first line is the first 16 bytes of the compiled
addprogram, in hexadecimal (base 16, see the binary and hex lesson). Every compiled Linux program starts with7f 45 4c 46, which spells “.ELF.” Further in, after the loading instructions for Linux, sits the machine code your CPU runs directly. - The rest is Python’s bytecode: the interpreter quietly turned
total = 0(line 2) into two simpler steps, “load the number 0” and “store it in total.” Unlike theaddprogram, bytecode isn’t something you can hand to someone without Python: only the interpreter can run it.
What you learned
| Language | Kind | Needs to run it | A typo shows up… |
|---|---|---|---|
| Python | Interpreted | Python installed | When that line runs |
| C | Compiled | Nothing extra (once compiled for that OS and CPU) | Before anything runs |
| Bash | Scripting | A Linux or Mac shell | When that line runs |
| PowerShell | Scripting | PowerShell, plus an execution policy that allows it | When that line runs |
| HTML | Markup | A web browser to display it | Usually never: the browser guesses and shows something |
| SQL | Query | A database such as SQLite | When the database reads the query |
If someone asks which language is best, the honest answer is “for what?” Steven reaches for PowerShell to fix a PC, Python for anything with data, and SQL when the data lives in a database. — Nova
Where this fits
This is part of the free CompTIA Tech+ roadmap: computer basics in the order the exam teaches them. These topics are in the Tech+ practice test, scored by exam domain.
NextData and databases explained→
Go deeper
- Programming basics — variables, loops, functions and pseudocode
- Binary, hex and data sizes — for reading the ELF bytes above
- Install software safely — why Windows is careful about running files
- How to open Command Prompt and PowerShell — your first terminal
Explainer, written by StashGrid with AI help and checked against the CompTIA Tech+ (FC0-U71) exam objectives before publishing. Every command in a copy box was run on Nov 4, 2026, in Ubuntu 24.04 (WSL) and in Windows PowerShell 5.1 on Windows 11 as a normal user, and the outputs are from those runs (Python 3.12.3, gcc 13.3.0, SQLite 3.45.1). Not run: sudo apt install sqlite3, sudo apt install gcc and wsl --install (our test PC already had what it needed, and we ran the same SQLite 3.45.1 from Ubuntu’s package without installing it system-wide), opening add.html in a browser by double-clicking (we checked the file’s tags instead), and the Mac Terminal. StashGrid isn’t affiliated with CompTIA. Spotted an error? Tell us.