1/92
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
[Typing] Static type checking (definition)
Types are checked before execution (compile time); many type errors caught early.
[Typing] Dynamic type checking (definition)
Types are checked during execution (runtime); type errors occur when code runs.
[Typing] Static typing: 2 advantages
Early error detection; better tooling/optimisation.
[Typing] Static typing: 2 disadvantages
More upfront type constraints; some dynamic patterns are harder.
[Typing] Dynamic typing: 2 advantages
Flexible prototyping; fewer upfront annotations.
[Typing] Dynamic typing: 2 disadvantages
More runtime errors; harder refactors without tests.
[Typing] Type inference (definition)
Compiler deduces types from usage (often still statically checked).
[Typing] Is Haskell statically typed?
Yes; static typing with strong inference.
[Typing] C type checking (one line)
Mostly static (declared types checked), but casts/UB can bypass safety.
[Typing] Python type checking (one line)
Dynamic at runtime; names can be rebound to different types.
[Typing] Strong vs weak typing (safe phrasing)
Strong: fewer implicit unsafe coercions; weak: more coercions—use examples.
[Typing] maplist definition in paper (what it does)
Maps a list of functions over a list of values elementwise.
[Typing] Type of maplist (from paper)
maplist :: [a -> b] -> [a] -> [b]
[Typing] Why maplist is partial
Missing cases for mismatched list lengths; pattern match can fail.
[Typing] Compile-time vs runtime error
Compile-time caught before running; runtime occurs during execution.
[Typing] Example dynamic type error (Python)
"3" + 4 raises a TypeError at runtime.
[Typing] What is a type error?
Applying an operation to incompatible types under language rules.
[Scoping] Lexical/static scope (definition)
Name resolution depends on program text structure (nearest enclosing definition).
[Scoping] Dynamic scope (definition)
Name resolution depends on call chain at runtime (most recent binding).
[Scoping] Static scoping: 2 pros
Predictable from code; supports modular reasoning.
[Scoping] Dynamic scoping: 2 cons
Harder to reason; depends on call path and can cause accidental capture.
[Scoping] C: how to create a new scope
Use blocks { } (functions, if/for/while blocks create lexical scopes).
[Scoping] Haskell: how to create a new scope
let/in, where, lambda parameters, pattern bindings.
[Scoping] Classic scope-difference pattern
Global x; f prints x; g defines local x then calls f—static prints global, dynamic prints g’s x.
[Scoping] Why outputs differ in that pattern
Static binds f’s x to global; dynamic binds to latest active x in call stack.
[Parameters] Call-by-value (definition)
Argument value copied into parameter; callee assignment doesn’t affect caller.
[Parameters] Call-by-reference (definition)
Parameter aliases caller variable; callee updates affect caller (aliasing).
[Parameters] Call-by-result (definition)
Copy-out only; final parameter value copied back to caller at return.
[Parameters] Call-by-value: 2 pros
No aliasing side effects; simpler reasoning.
[Parameters] Call-by-value: 2 cons
Copy cost for large values; cannot directly modify caller variable.
[Parameters] Call-by-result: key pitfall
If same variable passed twice, copy-out order can change result (aliasing ambiguity).
[Parameters] C: inc by value vs reference (effect)
By value leaves caller unchanged; by reference (pointer) changes caller.
[Parameters] Haskell parameter passing (exam-safe phrasing)
Call-by-need (lazy with sharing); values are immutable, so no reference-style mutation.
[Memory] Manual memory management (definition)
Programmer explicitly allocates/deallocates memory (e.g., malloc/free).
[Memory] Automatic memory management (definition)
Runtime automatically reclaims unreachable memory (garbage collection).
[Memory] Manual management: 2 advantages
Fine control; potentially predictable performance (no GC pauses).
[Memory] Manual management: 2 disadvantages
Leaks/dangling/double-free risk; higher programmer burden.
[Memory] Automatic management: 2 advantages
Fewer memory-safety bugs; simpler development.
[Memory] Automatic management: 2 disadvantages
GC overhead/pauses; less control of reclamation timing.
[Memory] Stack vs heap (one line)
Stack: frames/locals, automatic; heap: dynamic objects, manual free or GC.
[Memory] How to allocate in C
Heap allocation via malloc/calloc/realloc; locals typically on stack.
[Memory] How to deallocate in C
free(p) for heap; stack memory is automatic on return.
[Memory] How to allocate in Java
Objects allocated with new on heap (managed by JVM).
[Memory] How to deallocate in Java
GC reclaims unreachable objects; no explicit free.
[Memory] Memory leak (definition)
Allocated memory is never freed and becomes unusable; memory consumption grows.
[Memory] Dangling pointer (definition)
Pointer refers to memory that has been freed (use-after-free risk).
[Memory] Double free (definition)
free called twice on same pointer; undefined behaviour.
[Memory] Segmentation fault (typical cause)
Invalid memory access (NULL/dangling/out-of-bounds).
[Memory] Minimal leak pattern (C)
malloc then lose pointer / return without free.
[Memory] Minimal use-after-free pattern (C)
free(p) then dereference p.
[Memory] Buffer overflow (definition)
Write past allocated bounds; can corrupt memory and crash/exploit.
[OOP] Inheritance (definition)
Class derives behaviour/state from another; supports reuse via specialization.
[OOP] Encapsulation (definition)
Hide internal state; expose operations through controlled interface.
[OOP] Polymorphism (general definition)
Same interface, different implementations depending on type.
[Polymorphism] Inclusion polymorphism (definition)
Subtype polymorphism: subtype usable where supertype expected (dynamic dispatch).
[Polymorphism] Parametric polymorphism (definition)
Generic code works uniformly for many types (e.g., Java generics).
[Polymorphism] Inclusion poly: Java example
List
[Polymorphism] Parametric poly: Java example
static
[Polymorphism] Overriding (definition)
Subclass replaces superclass method implementation with same signature.
[Polymorphism] Why overriding matters for inclusion poly
Base reference calls method; runtime dispatch picks subclass override.
[Polymorphism] Dynamic dispatch (definition)
Method chosen at runtime based on object’s actual class.
[Polymorphism] Multiple inheritance (definition)
Class inherits from more than one parent class.
[Polymorphism] Diamond problem (definition)
Ambiguity when inheriting same member along two paths from a common ancestor.
[Polymorphism] Java vs diamond problem
Java avoids MI of classes; uses interfaces and requires disambiguation for default method conflicts.
[Polymorphism] Python vs diamond problem
Python supports MI and resolves via MRO (C3 linearization); method lookup follows MRO.
[Prolog] Declarative programming (one line)
Specify what should hold (relations), not step-by-step control flow.
[Prolog] Fact vs rule vs query
Fact: basic assertion; rule: derived relation; query: ask what satisfies relations.
[Prolog] Unification (definition)
Make two terms equal by binding variables (constraint solving).
[Prolog] Backtracking (definition)
Prolog explores alternatives; on failure it tries the next possibility.
[Haskell] Pure function (definition)
No side effects; output depends only on inputs (referential transparency).
[Haskell] Immutability (definition)
Values don’t change; “updates” create new values.
[Haskell] Lazy evaluation (definition)
Evaluate only when needed; results are shared (call-by-need).
[Compare] Prolog relations vs Haskell functions
Prolog relations can generate/check via unification/backtracking; Haskell functions compute results and must explicitly enumerate alternatives.
[Compare] Pattern matching vs unification
Pattern matching decomposes values one-way; unification binds variables to make terms equal (often bidirectional).
[Prolog/Haskell] Prolog split using append
pairs(L,A,B) :- append(A,B,L). Generates all (A,B) via backtracking.
[Prolog/Haskell] Haskell generate all splits idea
Enumerate n and return (take n xs, drop n xs) for n=0..length xs.
[Prolog/Haskell] Haskell remove-all (idea)
Recurse; if x==n skip else keep x.
[Prolog/Haskell] Prolog remove-all (idea)
Two recursive rules: drop head if equals N; otherwise keep head.
[Rust] Ownership (definition)
Each value has one owner; when owner goes out of scope, value is dropped.
[Rust] Borrowing rule (core)
Many immutable references OR one mutable reference at a time (enforced at compile time).
[Concurrency] Data race (definition)
Two threads access same memory concurrently, at least one write, without synchronisation.
[Rust] Why Rust prevents data races
Borrow checker prevents unsynchronised shared mutable aliasing; safe sharing requires sync types.
[Rust] Channels (definition)
Message passing; ownership of messages moves from Sender to Receiver.
[Compare] Rust channels vs Java threads
Rust: ownership + message passing reduces shared-state races; Java: shared memory common and must be synchronised.
[Java] Threads (definition)
Concurrent execution units sharing memory; correctness depends on synchronisation.
[Haskell] Why data races are “not a problem” (core idea)
Pure code + immutability means no shared mutable state in ordinary functions; concurrency evaluates expressions safely.