The foundation nobody gives you

Computer Science
Foundations

This is not a curriculum. It's a map. Understand how a computer thinks and everything else — including AI — starts to make sense.

By Badar · Veyralabs

This guide does not aim to teach you everything. It aims to show you what exists, give you the basics, and spark curiosity so you can dig deeper on your own. At the end of each section you will see how it connects to artificial intelligence.

01

Computer Logic

What is this about?

A computer only understands true (1) and false (0). All the complexity of software is logic built on top of that. If you understand boolean logic, you understand the foundation of everything.

💡

Analogy

Think of a light switch. On = 1, Off = 0. Now imagine a billion switches working together in nanoseconds. That is a processor.

The 3 operations you need to know

OperationSymbolRuleReal example
AND&&True only if BOTH are trueDo you have an ID AND a car? → you can drive
OR||True if AT LEAST ONE is trueUmbrella OR hood? → you stay dry
NOT!Inverts the valueIf NOT raining → I go out without an umbrella
pseudocode — logic in action
// Decide whether to go for a run
if (notRaining AND freeTime) {
    goForRun()
}

// Open the fridge if hungry OR bored
if (hungry OR bored) {
    openFridge()
}

if (NOT haveHomework) {
    watchNetflix()
}

AI Connection

AI models like Claude make millions of logical decisions per second when generating text. Each neuron in a neural network applies variations of these operations on numbers.

To explore: "Boolean algebra", "Truth tables", "George Boole". He invented this 170 years ago without imagining it would bring computers to life.

02

Data and Binary Representation

Why binary?

Computers use electricity: there is current (1) or there is not (0). That is a bit. With 8 bits you have a byte. With bytes you can represent letters, numbers, images, video — anything.

📬

Analogy

Imagine you can only communicate with light bulbs: on or off. To say "hello" you need a code. That is ASCII — a table that says "the letter A is the number 65, which in binary is 01000001".

decimal → binary
// The number 13 in binary is 1101. Why?
// 1×8 + 1×4 + 0×2 + 1×1 = 8+4+0+1 = 13

position:  8    4    2    1
binary:    1    1    0    1    → decimal: 13

// Number 7:
position:  4    2    1
binary:    1    1    1    → decimal: 4+2+1 = 7

Storage units

UnitEqualsAnalogy
1 bitA 0 or a 1A switch
1 byte8 bitsA letter of the alphabet
1 KB~1,000 bytesA short text message
1 MB~1,000 KBA photo from your phone
1 GB~1,000 MBA movie in medium quality
1 TB~1,000 GBYour computer hard drive

AI Connection

Claude processes text as tokens — numbers. The phrase "hello world" becomes [15496, 31537] before the model processes it. Everything is binary under the hood: text, images, audio.

To explore: "Hexadecimal system", "ASCII table", "UTF-8 encoding". CSS colors like #E8602C are hexadecimal numbers (base 16) — each pair is one byte.

03

Algorithms and Programming Logic

What is an algorithm?

A sequence of steps to solve a problem. It does not have to be code. A cooking recipe is an algorithm. IKEA instructions too.

🍳

Analogy

Frying an egg: 1. Turn on heat. 2. Add oil. 3. If pan is hot → crack the egg. 4. Wait 2 min. 5. Remove and eat. Input (egg), process (steps), output (fried egg). That is an algorithm.

The 3 building blocks of any program

With these three structures you can build any software in the world:

1. SEQUENCE — steps in order
turnOnComputer()
openBrowser()
searchOnGoogle("how to program")
2. CONDITIONAL — decisions
if (grade >= 5) {
    show("Passed ✓")
} else if (grade >= 4) {
    show("You need the oral exam")
} else {
    show("Failed — back to studying")
}
3. LOOP — repeat
// Count from 1 to 10
for i from 1 to 10 {
    show(i)
}

// While not home, keep walking
while (NOT atHome) {
    walk()
}

AI Connection

Language models are essentially very sophisticated algorithms. Given an input (your prompt), they execute millions of steps (the neural network forward pass) to generate an output (the response). There is no magic — there are algorithms.

To explore: "Algorithmic complexity O(n)", "Sorting algorithms" — search "sorting algorithms visualized" on YouTube. Watching them move changes everything.

04

Hardware — How the Computer Works

🧠 CPU — The Processor

The "brain". Executes instructions. Takes data, processes it, and produces results. Speed is measured in GHz (billions of operations per second). Almost all modern processors have multiple cores.

👨‍🍳

Analogy

The chef in a restaurant. Only the chef cooks, but they are incredibly fast. Cores are like multiple chefs working in parallel.

💾 RAM — Working Memory

Temporary memory. When you open Chrome, the data goes to RAM. Fast but volatile — when you turn off the computer everything is erased. More RAM = more things open without slowing down.

🗂️

Analogy

Your work desk. The larger it is, the more papers you can have open. At the end of the day (shutdown), you clear the desk.

Basic CPU cycle: Fetch → Decode → Execute
1. FETCH     → The CPU retrieves the next instruction from memory
2. DECODE    → It figures out what to do
3. EXECUTE   → It does it (add, compare, move data...)
4. Go back to step 1.

This happens billions of times per second.

AI Connection

AI models like Claude do not run on regular CPUs — they run on GPUs and TPUs, chips designed to perform thousands of matrix operations in parallel. A GPU can have thousands of small cores vs the 8-32 of a CPU. That is what makes modern AI possible.

To explore: "Von Neumann architecture", "What is a GPU and why does it matter for AI?". The GPU is the piece that changed everything.

05

Your First Real Code

Which language to learn first?

The honest answer: any of them works for learning concepts. But if I had to pick one today: Python. Clean, readable, used everywhere: web, data, artificial intelligence, automation.

🗣️

Analogy

Python is like English — fairly straightforward. C is like Latin — precise and powerful but hard. JavaScript is like the internet's lingua franca — it is everywhere. The concepts you learn in one transfer to the others.

Python — variables and functions
# Variable — a named box where you store a value
name = "Ana"
age = 22
passed = True   # True = yes

print("Hello,", name)  # → Hello, Ana

# Function — reusable block of code
def evaluate_grade(grade):
    if grade >= 9:
        return "Outstanding 🏆"
    elif grade >= 5:
        return "Passed"
    else:
        return "Failed"

grades = [6.5, 9.2, 4.5, 7.0]
for grade in grades:
    print(f"Grade: {grade} → {evaluate_grade(grade)}")

AI Connection

The Anthropic SDK for calling Claude from code is available in Python and JavaScript. With 20 lines of Python you can send a message to Claude and process its response. That is the next step after this guide.

To explore: Search "CS50 Harvard Python" on YouTube — it is the best free introductory course out there. Install Python and write your first print("Hello world"). The first code you run on your own is a moment you never forget.

06

Networks and the Internet

How does the Internet work?

The Internet is a huge network of computers that communicate using protocols — common rules for speaking the same language. Without protocols, computers could not understand each other.

📮

Analogy

When you send a letter you need: the recipient's address (IP), an envelope (TCP packet), and the post office as intermediary (router). The Internet works the same way but in milliseconds.

Essential concepts

ConceptWhat is it?
IPYour computer's address on the network. Like your house number.
DNSTranslates names (google.com) to IPs. The Internet's address book.
HTTP/HTTPSProtocol for the web. The S means it is encrypted.
PortLike the door of a house. 80 = HTTP, 443 = HTTPS, 22 = SSH.
What happens when you type 'google.com'?
1. Browser asks DNS: "What IP is google.com?"
2. DNS replies: "It is 142.250.184.14"
3. Your computer sends an HTTP request to that IP (port 443)
4. Google's server receives the request
5. It returns the HTML of the page
6. Your browser renders it on screen

All of this happens in under 200ms.

AI Connection

When you call Claude's API, your code does exactly this: an HTTPS request to api.anthropic.com, with your message in the body (JSON), and Claude responds with text. It is just a web request like any other.

To explore: "What is a REST API?", "How does HTTPS work?". Once you understand HTTP you will understand how the entire modern web works — and how to talk to Claude from code.

07

What to Explore Next

Computer science is vast. You do not need to learn everything now — you need to know what exists so you can find it when you need it.

Foundation

Data Structures

Arrays, lists, trees, graphs. How to organize information efficiently.

Foundation

Operating Systems

How does the computer manage multiple programs? Processes, memory, files.

Programming

Object-Oriented Programming

Organizing code into objects. The basis of Python, Java, C#.

Programming

SQL Databases

How to store and query data. Ubiquitous in the industry.

Web

HTML + CSS + JavaScript

The three languages of the web. With them you can build any app.

Key 2026

Artificial Intelligence

Machine Learning, neural networks. It is not magic — it is math.

Infra

Linux and the Terminal

Most servers run Linux. Learning the terminal means talking directly to the computer.

Infra

Git and Version Control

How to save the history of your code. The most used tool in development.

Suggested roadmap

W1

Install Python and write your first code

  • Download Python.org
  • Write your first variable, your first if, your first loop
  • Do not skip this — it is the foundation of everything
W2

Understand binary and logic

  • Convert numbers to binary by hand
  • Practice truth tables
  • Search "CS50 Harvard" on YouTube — it is free and excellent
W3

Basic algorithms

  • Implement the algorithms from this guide in Python
  • Search "sorting algorithms visualized" — watching them move changes everything
W4

HTML and the web

  • Create your first web page (it does not have to be pretty)
  • Understand what a server is, what a client is
  • Make an HTTP request by hand
+

When comfortable → Claude

  • You now have the foundation to understand how AI works
  • Continue with the certification roadmap →
08

How Large Language Models Work

Everything you just learned, in one machine

Binary (§02), algorithms (§03), hardware (§04), networks (§06) — a language model uses all of it. Understanding the steps below is not optional if you want to work seriously with AI. It is the difference between a user and an engineer.

Step 1 — Tokenization: text becomes numbers

A model cannot read text. It only processes numbers. The first thing it does is split the input into small fragments called tokens and assign each one a numeric ID. Tokens are not words — they are fragments, sometimes smaller, sometimes larger.

text → tokens → IDs
"artificial intelligence"
→ ["artif", "icial", " intel", "ligence"]
→ [  8043,   1748,   intel_id,   ligence_id ]

// One word can be 1 token (English) or 3 tokens (Spanish/rare words)
// The context window limit is in tokens, not words
// "128k tokens" ≠ 128k words — it is fewer
🔢

Analogy

You can only communicate with your friend using a codebook where each page has a number. Before every conversation, you convert your words to page numbers. That is tokenization. The model never sees text — only numbers.

Step 2 — Embeddings: numbers get meaning

Token IDs are arbitrary — like primary keys in a database. The ID for "cat" has no mathematical relationship with the ID for "dog". The model needs the opposite: numbers that are close when concepts are close. So each token ID gets converted into a vector of hundreds of dimensions.

token IDs → semantic vectors
"cat"  → ID 4953  → [0.23, -0.81,  1.52, 0.04, -0.33, ...]
"dog"  → ID 39041 → [0.21, -0.79,  1.48, 0.06, -0.31, ...]
"bank" → ID 8821  → [0.91,  0.44, -0.20, 0.77,  0.12, ...]

// cat and dog: nearly identical vectors — they appear in similar contexts
// bank: completely different — different meaning cluster

// Math that actually works on embeddings:
king - man + woman ≈ queen   // not a metaphor, real vector arithmetic

These vectors are contextual: "bank" in "I went to the bank" gets a different vector than "bank" in "sitting on the river bank". The meaning is not fixed — it depends on context.

Step 3 — Attention: every token sees every other token

The breakthrough paper (2017) was literally titled “Attention is All You Need.” For each token, attention calculates: how much should this token pay attention to each other token in the context? The result is a weight matrix.

attention weights — 'it had hunger'
Sentence: "The cat drank the milk because it was hungry"

Processing "it":
  The      → 0.02
  cat      → 0.71  ← high weight (refers to cat)
  drank    → 0.08
  the      → 0.01
  milk     → 0.06
  because  → 0.04
  it       → 0.05
  was      → 0.02
  hungry   → 0.01

// The model learned "it" refers to "cat" — no rules, just statistics

All tokens are processed in parallel — that is why Transformers can be trained on GPUs with massive datasets. Cost is O(n²): doubling the context quadruples the computation.

Lost in the middle: With long contexts the model remembers the start and end well, but buries information in the middle. Design rule: put critical instructions at the beginning of your prompt. Repeat the most important at the end. The middle is a dead zone.

Step 4 — Generation: probabilities, not truth

After attention, the model converts the final vector into scores for every token in its vocabulary (~100,000 options). These raw scores are called logits. Softmax converts them to probabilities that sum to 1. Then one token is picked.

logits → softmax → token chosen
// Question: "The capital of France is..."
logits (raw scores):
  "Paris"    →  8.92
  "Lyon"     →  4.11
  "Europe"   →  3.87
  "the"      →  1.23
  "cat"      → -2.41

after softmax (probabilities):
  "Paris"    →  73%   ← chosen
  "Lyon"     →  12%
  "Europe"   →   9%
  ...
// This repeats token by token until the response is complete
TemperatureEffectUse case
0.0 – 0.3Always picks highest probability. Predictable.Structured output, SQL, JSON
0.5 – 0.8Some variation. Balanced.Chat, summaries, explanations
1.0 – 1.5Lower-probability options get more chance. Creative.Brainstorming, creative writing

The key insight: the model has no internal truth-checker. No component says “this is correct” or “this is false.” It only asks: given everything seen, what token is most probable next? If the most probable token is wrong — it picks it anyway, with full confidence. That is where hallucinations come from.

AI Connection

Prompt caching (Anthropic) exploits the KV Cache: attention results for tokens already processed are stored. If you send the same system prompt on every request, Anthropic can reuse that computation and charge ~10% of normal token price. Same architecture detail, direct cost saving.

To go deeper: “Attention is All You Need” (Vaswani et al., 2017) — the original paper. 3Blue1Brown's “But what is a GPT?” on YouTube — the best visual explanation that exists. Once you watch it, everything in this section clicks.

Next step

Ready to build on it?

The Claude certification roadmap takes you from these foundations all the way to passing the Anthropic exam.