Software Engineering
The CS fundamentals behind good engineering: data structures, algorithms, complexity, systems and networks.
A self-taught computer science curriculum for working developers. It starts with data structures, asymptotic analysis and the classic algorithms, then moves through complexity theory, design patterns, databases, networking, security, and how CPUs and operating systems run your code. Each subject links free references, mostly official documentation, open textbooks and Wikipedia.
The subjects follow the roadmap.sh Computer Science roadmap.
Every idea on this path is easier to learn when you implement it, so choose one language and stay with it. A language with manual memory or explicit pointers (C, C++, Rust) shows what data structures cost; a higher-level one (Python, Java, Go, C#) lets you move faster through algorithms.
Readable syntax, a big standard library (collections, heapq, bisect) and an interactive REPL make it the quickest way to try out an algorithm. Its slowness and hidden costs are worth measuring rather than ignoring.
Close to the machine: pointers, manual malloc/free, structs and arrays with no bounds checks. Writing a linked list or hash table in C teaches exactly what the abstractions in other languages hide.
C with classes, templates and the STL (vector, map, unordered_map, priority_queue, <algorithm>). The default in competitive programming because it is fast and the library covers most classic structures.
Statically typed, garbage-collected and verbose but explicit; the Collections Framework (ArrayList, HashMap, TreeMap, PriorityQueue) maps cleanly onto textbook data structures.
Small language with slices, maps, goroutines and channels built in. Good for the concurrency and systems topics later in the path; generics arrived in 1.18.
Managed .NET language with value types, generics and LINQ; List<T>, Dictionary<TKey,TValue> and PriorityQueue<TElement,TPriority> cover the common structures.
Systems language with ownership and borrowing instead of a garbage collector. Building linked structures fights the borrow checker, which itself teaches a lot about aliasing and lifetimes.
Ways of laying out data in memory so that the operations you need are cheap. For each one, know the cost of access, search, insert and delete, how it uses memory and cache, and which built-in type in your language implements it.
A contiguous block of same-sized elements, so index i is one address calculation away: O(1) access, cache-friendly scans, but O(n) inserts in the middle. Dynamic arrays double their capacity to make appends amortised O(1).
Nodes that point to the next (and, when doubly linked, the previous) node. Splicing is O(1) once you hold a node, but finding one is O(n) and pointer chasing is slow on modern caches.
Last in, first out: push, pop and peek in O(1). The call stack, undo history, expression parsing and iterative DFS all rely on it.
First in, first out: enqueue at the back, dequeue at the front, usually as a ring buffer or linked list. Deques allow both ends; BFS and task schedulers depend on queues.
Maps keys to buckets with a hash function for average O(1) lookup. Collisions are handled by chaining or open addressing, and the table is resized when the load factor grows; a bad hash degrades it to O(n).
A complete binary tree stored in an array where every parent is ordered against its children. Gives O(1) min/max and O(log n) insert and extract — the usual priority queue.
A hierarchy of nodes with one root and no cycles, where each node has children. Trees model file systems, the DOM and syntax trees, and their ordered variants give O(log n) search when kept balanced.
Every node has at most two children, left and right. The base shape for search trees, heaps and expression trees.
Keys in the left subtree are smaller and keys in the right are larger, so search, insert and delete follow one path. That path is O(log n) when balanced and O(n) when fed sorted input.
No node has exactly one child: internal nodes always have two. Huffman trees and arithmetic expression trees are naturally shaped this way, and such a tree with n leaves has n−1 internal nodes.
All levels are full except possibly the last, which fills left to right. That property lets it live in an array with children at 2i+1 and 2i+2, which is how heaps are stored.
Subtree heights stay within a bound, so height is O(log n) and every operation stays logarithmic. Self-balancing trees rotate nodes on insert and delete to keep it that way.
A tree whose height has drifted far above log n, often from inserting sorted keys into a plain BST. In the worst case it is a linked list and searches become linear.
Visit the node, then the left subtree, then the right. Useful for copying a tree or serialising it so it can be rebuilt in the same shape.
Left subtree, node, right subtree. On a binary search tree this yields keys in sorted order, which makes it a quick validity check.
Left, right, then the node itself — children are finished before their parent. Used to free memory, evaluate expression trees and compute subtree sizes.
Vertices joined by edges, optionally weighted or directed. Road maps, social networks, dependency graphs and state machines are all graphs, and choosing the right representation decides how fast the algorithms on them run.
Edges have a direction, so A → B does not imply B → A. Build systems, package dependencies and web links are directed; acyclic ones (DAGs) can be topologically sorted.
Edges are symmetric connections, like friendships or two-way roads. Connected components, cycles and spanning trees are the usual questions asked of them.
A subset of edges that connects every vertex with no cycle, so it has exactly V−1 edges. The minimum spanning tree, found by Kruskal or Prim, is the cheapest such set in a weighted graph.
A V×V grid where cell [u][v] holds the edge or its weight. O(1) edge checks but O(V²) memory, so it suits dense or small graphs.
Each vertex keeps a list of its neighbours. Memory is O(V+E) and iterating neighbours is fast, which is why most sparse real-world graphs use it.
A language for how an algorithm's time or memory grows as the input grows, ignoring constant factors and small inputs. It lets you compare approaches before writing them, though constants and cache behaviour still matter in practice.
An upper bound: f(n) is O(g(n)) if it grows no faster than a constant times g(n) for large n. In everyday use it describes the worst case.
A tight bound: the function is squeezed between two constant multiples of g(n). Merge sort is Θ(n log n) in every case, so Theta is the honest description.
A lower bound: the function grows at least as fast as g(n). Comparison sorting is Ω(n log n), meaning no comparison sort can beat it.
A strict upper bound: f(n) grows strictly slower than g(n), so f/g tends to zero. For example n is o(n²) but not o(n).
A strict lower bound: f(n) grows strictly faster than g(n), so f/g grows without limit. n² is ω(n) but not ω(n²).
A handful of growth rates cover almost every algorithm you will meet. Recognising them from the shape of the code — a single loop, nested loops, halving, branching recursion — is the practical skill.
O(1): the work does not depend on input size, like indexing an array or pushing onto a stack. Amortised O(1) means occasional expensive steps averaged out.
O(log n): each step throws away a constant fraction of the input, as in binary search or walking a balanced tree. A billion items need about 30 steps.
O(n): touch every element a constant number of times, such as a single scan for the maximum. Often the best possible when every input must be read.
O(n^k) for a fixed k, typically from k nested loops; O(n²) and O(n³) are the common cases. Polynomial time is the usual line between tractable and intractable problems.
O(2^n) and similar: work doubles with each extra element, as in trying every subset or naive recursive Fibonacci. Only feasible for tiny n unless memoisation or pruning helps.
O(n!): enumerating every ordering, as brute-force travelling salesman does. Even n = 20 is around 2.4 × 10¹⁸ permutations.
The recurring techniques — recursion, searching, sorting, graph traversal, greedy choice and backtracking — that most interview and real-world problems reduce to. Learn each by implementing it and tracing it by hand on a small input.
The recursive call is the very last action, so nothing remains in the frame afterwards. Languages with tail-call elimination (Scheme, some C compilers at -O2) turn it into a loop; Python and Java do not.
Work happens after the recursive call returns, as in n * fact(n - 1) or tree traversals, so every frame stays on the stack. Deep inputs can overflow it; convert to an explicit stack when that is a risk.
Check elements one by one until a match: O(n), no preconditions, and often fastest for small or unsorted arrays.
On sorted data, compare with the middle and discard half each step for O(log n). Off-by-one bugs in the bounds are notorious, so learn one loop invariant and stick to it.
Putting items in order is a building block for searching, deduplication and merging. Compare algorithms on time, extra memory, stability (equal keys keep their order) and behaviour on nearly sorted input; production libraries use hybrids like Timsort and introsort.
Repeatedly swap adjacent out-of-order pairs until a pass makes no swaps. O(n²) and only useful for teaching.
Find the smallest remaining element and swap it into place, n times. Always O(n²) comparisons but only O(n) swaps, which matters when writes are expensive.
Grow a sorted prefix by sliding each new element left into place. O(n²) worst case but near O(n) on almost-sorted data, so hybrid sorts use it for small runs.
Split in half, sort each half recursively, then merge the two sorted runs. Guaranteed O(n log n) and stable, at the cost of O(n) extra memory; the natural choice for linked lists and external sorting.
Pick a pivot, partition smaller and larger elements around it, recurse on both sides. Fast in practice and in place, but O(n²) with bad pivots, so use random or median-of-three pivots.
Build a max-heap in the array, then repeatedly move the root to the end and sift down. O(n log n) worst case with O(1) extra space, though not stable and less cache-friendly than quicksort.
Traversal and shortest-path algorithms answer reachability, distance and routing questions. Which one to use depends on whether edges are weighted, whether weights can be negative, and whether you have a heuristic for the goal.
Explore level by level with a queue, marking vertices as visited. Finds shortest paths by edge count in unweighted graphs and runs in O(V+E); on trees it is level-order traversal.
Follow one branch as deep as possible before backtracking, via recursion or a stack. The basis for cycle detection, topological sort and connected components.
Greedily settles the closest unvisited vertex using a priority queue, giving single-source shortest paths in O((V+E) log V). Breaks with negative edge weights.
Relaxes every edge V−1 times to find shortest paths even with negative weights, in O(VE). A further pass that still improves a distance reveals a negative cycle.
Dijkstra guided by a heuristic estimate of the remaining distance, ordering by g + h. With an admissible heuristic (never overestimates) it still finds the optimal path; used in games and maps.
Make the locally best choice at each step and never revisit it. When a problem has the greedy-choice property this gives the optimal answer cheaply; when it does not, greedy gives a fast approximation, so you need a proof or a counterexample.
Build a prefix-free code by repeatedly merging the two least frequent symbols, so common symbols get short bit strings. Still a stage inside DEFLATE (zip, gzip, PNG).
Sort edges by weight and add each one unless it would close a cycle, checked with a union-find structure. Builds a minimum spanning tree in O(E log E).
Grow a minimum spanning tree from one vertex, always adding the cheapest edge that leaves the tree, using a priority queue. Tends to beat Kruskal on dense graphs.
Computes maximum flow by pushing flow along augmenting paths in the residual graph until none remain. Using BFS to find paths (Edmonds–Karp) bounds it at O(VE²).
Build a solution one choice at a time and undo the last choice as soon as it cannot lead anywhere valid. It is exhaustive search with pruning; good constraint checks and move ordering decide whether it finishes in time.
Find a path that visits every vertex exactly once. Backtracking extends the path with unvisited neighbours and retreats on dead ends; the problem is NP-complete in general.
Place N queens on an N×N board so none attack each other. Place one per row and track used columns and diagonals in sets so each conflict check is O(1).
Walk from start to exit, marking cells and stepping back from dead ends. DFS-style backtracking finds a path; BFS finds the shortest one.
Move a knight so it lands on every square exactly once. Plain backtracking is slow; Warnsdorff's rule of trying the square with the fewest onward moves first makes it nearly linear.
A cache keeps a small, fast copy of data that is expensive to fetch. When it is full an eviction policy decides what goes, and the right policy depends on the access pattern of your workload.
Evict the entry that was used least recently. A hash map plus a doubly linked list gives O(1) get and put; Python ships it as functools.lru_cache.
Evict the entry with the fewest accesses, keeping long-term favourites. Needs per-key counters and often some ageing so stale popular items eventually leave.
Evict the most frequently used entry, on the theory that heavily used items have probably served their purpose. Rarely the right choice, but it helps to know it exists.
Finding a pattern of length m in a text of length n is everywhere: editors, grep, search engines, DNA analysis. Naive search is O(nm); the classic algorithms preprocess the pattern or the text to get close to O(n + m).
The general problem: report every position where a pattern occurs in a text, possibly with wildcards or many patterns at once (Aho–Corasick). Pick the algorithm by alphabet size and how often the text or pattern changes.
Locating one string inside another, as str.find or indexOf do. Library versions use tuned hybrids, so reach for them before writing your own.
Try the pattern at every offset and compare character by character. O(nm) worst case but simple and fine for short patterns.
Precomputes a failure table from the pattern's own prefixes and suffixes so the text pointer never moves backwards. O(n + m) in the worst case.
Compares from the end of the pattern and uses bad-character and good-suffix tables to jump ahead by many positions. Sublinear on typical text, which is why grep-like tools use variants of it.
Slides a rolling hash over the text and only compares characters when hashes match. Expected O(n + m) and naturally extends to searching many patterns of the same length.
A sorted array of every suffix's starting index. After building it once, any pattern can be found by binary search in O(m log n); combined with an LCP array it answers many substring questions.
IEEE 754 numbers store a sign, exponent and fraction, so most decimals like 0.1 cannot be represented exactly and 0.1 + 0.2 != 0.3. Compare with a tolerance, beware of cancellation when subtracting close values, and use integers or decimal types for money.
The order in which the bytes of a multi-byte value are stored in memory or sent over a wire. It only bites when bytes cross a boundary — file formats, network protocols, binary serialisation — so convert explicitly there.
The most significant byte comes first, the way we write numbers. It is network byte order, so TCP/IP headers use it and C code converts with htonl/ntohl.
The least significant byte comes first. x86-64 and, by default, ARM run little-endian, so in-memory integers on almost every machine you use are stored this way.
Text is numbers: an encoding maps characters to code points and code points to bytes. Mismatched encodings produce mojibake, and string length, slicing and sorting all depend on whether you count bytes, code units, code points or user-visible characters.
A 7-bit encoding of 128 characters: English letters, digits, punctuation and control codes like \n. Every byte below 0x80 in UTF-8 is plain ASCII, which keeps old tools working.
One code point for every character in every script, encoded as UTF-8 (the web default), UTF-16 or UTF-32. Watch for combining marks, normalisation forms and emoji built from several code points.
&, |, ^, ~, << and >> act on individual bits. They pack flags into one integer, test powers of two with x & (x - 1), compute hashes and masks, and appear throughout low-level and performance code; know how your language handles signed right shifts.
Named, reusable solutions to recurring design problems. They give teams a shared vocabulary; use one because it removes real duplication or coupling, not to decorate simple code.
The 23 creational, structural and behavioural patterns catalogued by the "Gang of Four" in 1994: factory, builder, singleton, adapter, decorator, observer, strategy and more.
Patterns at the scale of a whole system, such as layered, MVC, event-driven, microservices and hexagonal architecture. They decide how components are split and talk to each other.
A component receives its collaborators from outside — through the constructor, usually — instead of creating them. Swapping implementations and faking them in tests becomes trivial; frameworks like Spring and NestJS automate the wiring.
Instead of returning null, return an object with the same interface whose methods do nothing sensible-by-default. Callers lose their scattered null checks.
Model "kinds" of things as data objects rather than subclasses, so a new monster or product type is a config entry instead of a new class. Common in games and data-driven systems.
UML is a standard notation for sketching software structure and behaviour. Few teams use all of it, but a handful of diagram types are handy for design discussions and documentation; tools like Mermaid and PlantUML generate them from text.
Boxes for classes with their fields and methods, and lines for inheritance, association, aggregation and composition. The most widely used UML diagram.
Actors (users or external systems) connected to the goals they achieve with the system. Useful early on to agree on scope, not on implementation.
Flowcharts with forks, joins and swimlanes that show a workflow or algorithm step by step, including parallel branches.
The states an object can be in and the events that move it between them, with guards and actions on transitions. Great for order lifecycles, protocols and UI flows.
Participants as vertical lifelines with messages between them in time order. The clearest way to explain a request flow across services or an auth handshake.
Discrete maths underpins analysis of algorithms: counting how many cases there are and how likely each one is. Logarithms, sums, induction and modular arithmetic come up constantly too.
Events, conditional probability, independence and expected value. Needed for randomised algorithms (quicksort pivots, hashing), load estimates and A/B tests.
Counting arrangements: permutations, combinations, the pigeonhole principle and inclusion–exclusion. It tells you how big a search space is before you try to brute-force it.
Problems are grouped by how much time or space any algorithm needs to solve or verify them. Knowing the classes tells you when to stop looking for a fast exact algorithm and reach for approximations or heuristics instead.
Decision problems solvable in polynomial time by a deterministic machine — sorting, shortest paths, primality testing. Informally, the "efficiently solvable" ones.
Problems whose "yes" answers can be checked in polynomial time given a certificate, such as a proposed Sudoku solution. Every problem in P is also in NP.
Problems whose "no" answers have short, checkable proofs — the complements of NP problems, such as deciding that a formula is never satisfiable.
At least as hard as every problem in NP, via polynomial-time reductions, but not necessarily in NP itself; the optimisation versions of TSP and the halting problem are examples.
The open question of whether every quickly checkable problem is also quickly solvable. Most researchers believe not; a proof either way carries a Clay Millennium Prize.
A prefix tree where each edge is a character and each path from the root spells a key. Lookup costs O(length of key) regardless of how many keys are stored, which makes tries ideal for autocomplete, spell checking and IP routing tables; compressed variants (radix trees) save memory.
Problems that are both in NP and NP-hard: a polynomial algorithm for any one of them would solve all of NP. When you recognise one, switch to exact methods for small inputs, dynamic programming on special cases, or approximation and heuristics.
Find the shortest tour that visits every city once and returns home. Held–Karp dynamic programming is O(n²2ⁿ); in practice solvers and heuristics like 2-opt handle large instances well.
Choose items with weights and values to maximise value under a capacity. 0/1 knapsack has an O(nW) dynamic programming solution, pseudo-polynomial because W can be huge.
Find the longest simple path in a graph. NP-hard in general, yet linear on a DAG via topological order — the basis of critical-path scheduling.
Search trees that restructure themselves on every insert and delete so height stays logarithmic. They back ordered maps (std::map, TreeMap), database indexes and file systems; the variants trade rotation cost, memory and disk-friendliness.
Keep the heights of every node's two subtrees within one of each other, fixing violations with single or double rotations. Strictly balanced, so lookups are slightly faster than red-black trees.
Colour each node red or black and enforce rules that keep the longest path at most twice the shortest. Fewer rotations on writes than AVL; used by std::map, Java's TreeMap and the Linux scheduler.
Nodes hold one or two keys with two or three children, and every leaf sits at the same depth. Inserts split overfull nodes upwards; red-black trees are a binary encoding of them.
Like 2-3 trees but nodes may hold up to three keys and four children, which allows top-down splitting in a single pass. Equivalent to red-black trees.
A tree where each node has up to k children. Higher fan-out means shallower trees — the idea behind B-trees and d-ary heaps.
A wide, shallow balanced tree whose nodes are sized to a disk page and hold many sorted keys. Almost every relational database and many file systems index data with B-trees or B+ trees.
A binary tree that splits k-dimensional points on alternating axes. Speeds up nearest-neighbour and range queries in low dimensions, but degrades towards brute force as dimensions grow.
Layered linked lists where each node is promoted to higher "express" levels at random, giving expected O(log n) search with simple code. Redis sorted sets use them.
Turning requirements into an architecture that handles load, failure and change. It is about trade-offs between latency, throughput, consistency, cost and complexity, made explicit with rough capacity numbers.
Vertical scaling buys a bigger machine — simple, but capped and a single point of failure. Horizontal scaling adds more machines, which needs stateless services, load balancing and partitioned data.
A group of machines acting as one system for capacity or availability, with membership, health checks and failover. Active-active clusters share load; active-passive keep a standby.
Spreads requests across servers with round robin, least connections or consistent hashing, and removes unhealthy ones. Layer 4 balancers route on TCP, layer 7 on HTTP paths and headers.
Storing results closer to the reader — browser, CDN, in-process, Redis — to cut latency and load. The hard parts are invalidation, TTLs, stampedes on expiry and stale reads.
A network of edge servers that caches static assets and sometimes dynamic responses near users. Reduces latency and origin traffic; control it with Cache-Control headers and purges.
An intermediary for traffic. A forward proxy acts for clients; a reverse proxy sits in front of servers to terminate TLS, cache, compress and route — NGINX, HAProxy and Envoy are common.
Message queues and logs (RabbitMQ, SQS, Kafka) decouple producers from consumers, absorb bursts and enable retries. Design for at-least-once delivery with idempotent consumers and a dead-letter queue.
Broad shapes for a system: monolith, microservices, event-driven, serverless, client-server, peer-to-peer. Start simple and split only where team or scaling needs justify the extra operational cost.
Resource-oriented HTTP APIs: nouns in URLs, standard methods and status codes, stateless requests and cacheable responses. Simple and widely understood, but can need many round trips for nested data.
A typed query language where the client asks for exactly the fields it needs from one endpoint. Removes over- and under-fetching but makes caching, rate limiting and N+1 queries your problem.
RPC over HTTP/2 with Protocol Buffers schemas and generated clients, supporting streaming in both directions. Efficient for service-to-service calls; browsers need a proxy such as gRPC-Web.
Proven solutions for distributed systems in the cloud: retry with backoff, circuit breaker, bulkhead, CQRS, saga, sidecar, strangler fig. Each addresses a specific failure or scaling problem.
Systems that store data durably and answer queries about it safely under concurrency. Learn to model data, write SQL, and understand indexes and transactions well enough to predict how a query behaves.
Relational databases offer schemas, joins and strong transactions. NoSQL stores (document, key-value, wide-column, graph) trade some of that for flexible schemas or easier horizontal scaling; choose by access pattern.
Describe a domain as entities, their attributes and the one-to-one, one-to-many or many-to-many relationships between them, before turning it into tables and foreign keys.
Normal forms remove duplicated data so each fact lives in one place and updates cannot disagree. Denormalising on purpose (copies, summary columns) trades write complexity for faster reads.
Data Definition Language: CREATE, ALTER, DROP and TRUNCATE for tables, indexes and schemas. In PostgreSQL DDL is transactional, so migrations can roll back cleanly.
Data Manipulation Language: INSERT, UPDATE, DELETE and upserts like INSERT … ON CONFLICT. Always check the WHERE clause before running an update.
Data Query Language: SELECT with joins, filters, grouping, window functions and CTEs. The largest and most used part of SQL.
Data Control Language: GRANT and REVOKE privileges on objects to roles. Give applications the least privilege they need.
Extra structures, usually B-trees, that let the database find rows without scanning the table. They speed reads but slow writes and cost space; use EXPLAIN to see whether one is used.
A saved query that can be selected from like a table, used to hide complexity or restrict columns. Materialised views store the result and must be refreshed.
Code that runs inside the database, called with CALL or as functions. Saves round trips and enforces logic close to the data, at the cost of harder testing and versioning.
A group of statements that commits or rolls back as one unit with BEGIN/COMMIT/ROLLBACK. Isolation levels decide which anomalies — dirty reads, lost updates, write skew — concurrent transactions can see.
Atomicity, Consistency, Isolation and Durability: the guarantees a transactional database makes so that partial writes, concurrent interference and crashes cannot corrupt data.
Row and table locks stop concurrent transactions from clobbering each other. Pessimistic locking uses SELECT … FOR UPDATE; optimistic locking checks a version column; both must be designed to avoid deadlocks.
Once one database server is not enough, data has to be copied or split across machines, and the guarantees change. These models describe what you give up in return for availability and scale.
Basically Available, Soft state, Eventually consistent: the looser contract many distributed stores offer, accepting temporary disagreement between replicas in exchange for availability.
During a network partition a distributed store must pick between consistency (refuse or delay) and availability (answer, maybe stale). Without a partition both are possible.
Extends CAP: if Partitioned, choose Availability or Consistency; Else, choose Latency or Consistency. It captures the everyday trade-off that synchronous replication adds latency.
Keep copies of data on several nodes for read scaling and failover. Leader-follower is common; synchronous replication avoids data loss, asynchronous avoids latency but allows replica lag.
Split one dataset across servers by a shard key, by range or by hash. Scales writes, but cross-shard queries and transactions get hard and a poor key creates hot spots.
Split databases by function — users in one, orders in another — so each is smaller and can scale independently. Joins across them move into the application.
How bytes get between machines: layered protocols for addressing, routing, reliable delivery, naming and security. Being able to reason down the stack is what makes timeouts, slow requests and certificate errors debuggable.
A seven-layer reference model from physical to application. Real networks follow TCP/IP, but "layer 4" and "layer 7" in load-balancer and firewall talk come from OSI.
The four layers the internet actually runs on: link, internet (IP), transport (TCP, UDP) and application. TCP adds ordering, retransmission and congestion control on top of best-effort IP.
The distributed directory that turns names into IP addresses through resolvers, root, TLD and authoritative servers, with caching governed by TTLs. Know the A, AAAA, CNAME, MX and TXT records and use dig to debug.
The request-response protocol of the web: methods, status codes, headers, caching and cookies. HTTP/2 multiplexes streams over one connection; HTTP/3 runs over QUIC on UDP.
TLS encrypts and authenticates a connection using certificates signed by trusted authorities; HTTPS is HTTP inside it. TLS 1.3 cut the handshake to one round trip.
The OS API for network endpoints: socket, bind, listen, accept, connect, send, recv. Every networking library ultimately sits on top of it.
The client asks the server for updates on a fixed interval. Trivial to build, but wasteful and laggy, since most requests return nothing new.
The server holds each request open until it has data or a timeout passes, then the client immediately reconnects. Near real time over plain HTTP, but each waiting client ties up a connection.
An HTTP upgrade to a persistent full-duplex connection, so both sides can send messages any time. Suited to chat, games and collaborative editing; you handle reconnects and scaling of sticky connections.
Server-Sent Events: a one-way stream of text events over a long-lived HTTP response, consumed in the browser with EventSource, which reconnects automatically. Simpler than WebSockets when only the server pushes.
Protecting confidentiality, integrity and availability. Engineers need the cryptographic building blocks, when to use each, and the common ways web applications are attacked.
Each party has a public key anyone can use and a private key kept secret. It enables key exchange and digital signatures (RSA, elliptic curves) and is the basis of TLS, SSH and code signing.
Encoding (Base64, URL encoding) only changes representation and hides nothing. Encryption is reversible with a key. Hashing is one-way and fixed-length, used for integrity checks and password storage.
SHA-256 and SHA-3 for integrity; MD5 and SHA-1 are broken for security use. Passwords need slow, salted algorithms such as Argon2id, scrypt or bcrypt, never a plain fast hash.
A regularly updated ranking of the most critical web application risks, such as broken access control, injection and security misconfiguration. A useful checklist for reviews and threat modelling.
From transistors and logic gates up to a CPU running your compiled program. A working model of the hardware explains why memory layout, branches and cache misses dominate performance.
Logic gates combine into adders and an arithmetic logic unit that work on binary numbers; negative integers use two's complement so the same adder handles subtraction.
Registers are a few dozen tiny, fastest storage slots inside the CPU; RAM is gigabytes of addressable memory hundreds of cycles away. Programs constantly shuttle values between the two.
A program is a sequence of machine instructions from the CPU's instruction set — load, store, add, compare, jump. Compilers translate source code into them; disassemblers and Compiler Explorer show the result.
The fetch-decode-execute cycle, made fast by pipelining, branch prediction and out-of-order execution. A mispredicted branch flushes the pipeline, which is why predictable code runs faster.
Small, fast L1/L2/L3 memories that hold recently used 64-byte lines. Sequential access and compact data hit the cache; random pointer chasing and false sharing between cores miss it.
The operating system shares CPUs and memory among many programs at once. Understanding processes, threads, scheduling and synchronisation explains concurrency bugs and how to use multiple cores safely.
A process has its own address space and resources; threads inside it share memory and file descriptors. Threads are cheaper to create and communicate faster, but one bad write can corrupt everything.
On Unix, fork() clones the calling process (copy-on-write), and the child often calls exec to run another program. Shells start every command this way.
Virtual memory gives each process its own address space mapped to physical pages by the MMU, with paging to disk when RAM runs out. Within a process, the stack holds frames and the heap holds dynamic allocations.
A mutex lets one thread at a time into a critical section; a semaphore is a counter allowing up to N. Misused, they cause deadlocks, priority inversion or contention — keep critical sections short and lock in a fixed order.
Threads on different cores really run in parallel, so data races, memory ordering and cache-line contention appear. Atomics, locks and message passing are the tools; Amdahl's law limits the speedup.
How the OS decides which runnable thread gets a CPU next: FIFO, round robin with time slices, priority queues and fair-share schedulers like Linux's CFS and its successor EEVDF.
Signals from hardware (a timer, a network card) or software that make the CPU pause, run a handler in the kernel and resume. Timer interrupts are what let the scheduler preempt a running thread.