Compiler
41 bites tagged Compiler — interview questions with model answers, and 60-second explainers.
Angular Ivy: The Tree-Shakable Compiler
Angular's Ivy engine compiles components like separate puzzle pieces, making apps smaller and faster. This enables effective tree-shaking for smaller bundles and faster rebuilds.
Why Svelte Skips the Virtual DOM
Svelte skips the Virtual DOM, treating it as runtime overhead. It acts as a compiler, generating precise JavaScript to update the DOM directly. This avoids the 'diffing' step of frameworks like React, leading to smaller bundles and faster updates.
Svelte: A Compiler, Not Just a Framework
Svelte is a compiler that turns your component files into efficient, imperative vanilla JavaScript at build time. This avoids shipping a large runtime, leading to smaller bundles. The footgun is thinking of it as just a runtime; its power is in the build step.
Triple-Slash Directives: Compiler Hints in Comments
Triple-slash directives are compiler instructions inside comments, telling TypeScript about file dependencies. They're mostly seen in older projects or for global types, as modern `import` statements are preferred.
TypeScript's Module Resolution Strategy
TypeScript's `moduleResolution` is the compiler's search plan for finding files behind `import` statements. It's crucial when mixing module types (ESM/CJS) or targeting Node.js vs. the browser. The footgun is assuming the default `node` works for modern ESM.
Go Assembly: A Semi-Abstract Instruction Set
Go's assembler isn't a direct mapping to machine code; it's a semi-abstract instruction set. A `MOV` might become a `clear` or `load`. This is what you see with `go tool compile -S`. The footgun is assuming your assembly maps 1:1 to the final machine code.
Rust Procedural Macros: Code That Writes Code
Procedural macros are compile-time functions that write Rust code for you. They power common patterns like Serde's `#[derive(Serialize)]`. The main footgun is hygiene: generated code can clash with local variables, so authors must use absolute paths to be…
Go Linker Flags: Injecting Data at Build Time
Go's `-ldflags` lets you inject data into your program at build time. This is perfect for embedding version numbers or git commit hashes into variables without hardcoding them. The main footgun is that the target variable must be a top-level string.
Rust Build Profiles: Tune for Speed vs. Debugging
Rust build profiles are presets for the compiler, trading off compile time and debuggability for runtime speed. Use the `dev` profile for quick iteration and the `release` profile for production. The footgun is benchmarking without the `--release` flag.
Rust's NLL: Smarter Borrows Based on Use, Not Scope
Non-Lexical Lifetimes (NLL) make Rust's borrow checker smarter. A borrow's lifetime ends after its last use, not at the end of its code block. This allows modifying data after a borrow is finished, even if the reference variable is still in scope.
Rust's Lifetime Elision: When You Can Skip 'a
Lifetime elision lets you omit explicit lifetimes (`'a`) in function signatures. The compiler infers them from common patterns, like a function taking one reference and returning one.
Rust's Module-to-Filesystem Mapping
Rust's module system maps directly to your file system. A `mod foo;` statement tells the compiler to look for `foo.rs` or `foo/mod.rs`. This is how you organize any multi-file Rust project.
Go's Entry Point: The `main` Package and Function
A Go program's entry point is `package main`. The compiler finds this package and its `main()` function to create a runnable binary. The footgun is naming a library `main`; this name is reserved for executables and will cause build confusion.
Rust Modules: Your Code's File System
Think of Rust modules as a file system for your code, grouping logic and hiding details. You declare them with `mod`, and Rust finds the code in corresponding files. The footgun: items are private by default, so you must use `pub` to expose them.
Rust's Turbofish (`::<>`): When the Compiler Needs Help
The turbofish (`::<>`) is your tool to resolve ambiguity when Rust's compiler can't infer a type or trait. Use it when a type implements multiple traits with same-named methods, forcing the compiler to pick the one you specify.
Go vs. Rust: Variable Mutability by Default
Rust variables are immutable by default; Go's are mutable. Rust forces you to opt-in to changeability with `mut` for compile-time safety. Go prioritizes convenience, trusting the developer.
Rust's Borrow Checker: Memory Safety at Compile Time
Rust's borrow checker is a compiler-time accountant that prevents memory bugs by enforcing ownership rules. It ensures you never access invalid data or have conflicting writes. The main footgun is assuming references are mutable by default; they aren't.
Get Compiler bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.