We use privacy-friendly product analytics (no session recording, PII masked) to improve OpenStem. Load analytics? Privacy Policy
Software: explore STEM content (page 8 of 25) · openstem
Explore STEM Content
Search the community's STEM library — free to study, yours to make your own.
Software
Programming, algorithms and systems on openstem — flashcards, notes, quizzes, sketches and flowcharts shared by the community. Study free, or clone anything into your library.
JSX is syntactic sugar for `React.createElement(type, props, ...children)` (or the new JSX transform's `_jsx`). The compiler converts angle-bracket syntax into nested function calls.
What does this print and why is it surprising?1 / 9
Prints `[1]` then `[1, 2]`. Default mutable arguments are evaluated ONCE at function definition, not per call — the same list persists across calls. Fix: use `def add(x, lst=None): if lst is None: lst = []`.
Why won't a surrounding try/catch catch an error thrown inside an async callback?1 / 10
The callback runs later on a separate stack after try/catch has already exited, so the throw escapes it; errors must be handled via the callback's error argument or an 'error' event.
A record is a transparent, immutable data carrier: the compiler generates a canonical constructor, private final fields, accessors, and value-based equals/hashCode/toString from the component list. It is ideal for DTOs and value objects.
Same Goal, Different Tools All synchronization primitives exist to keep concurrent access to shared state correct, but they differ in how many threads they let through at once, whether they track ownership, and whether they block or spin wh
Software
Software · L2 · Concurrency: Choosing a Synchronization Primitive
When Git Can't Auto-Merge A conflict means two branches changed the same lines and Git needs a human to decide the outcome. It marks the disputed section directly in the file rather than guessing. Staging a file with `git add` after editing
Software
Software · L2 · Git & Dev Workflow: Resolving a Merge Conflict
What is TypeScript and what problem does it solve?1 / 10
TypeScript is a statically typed superset of JavaScript that compiles to plain JS. It catches type errors at compile time rather than runtime, makes refactoring safer, and improves IDE support through autocompletion and inline docs.
What is the difference between INNER JOIN and LEFT JOIN?1 / 10
INNER JOIN returns only rows with matches in both tables. LEFT JOIN returns all rows from the left table, with NULLs for unmatched right-side columns. Use LEFT JOIN to keep rows that have no match.
What problem does the Raft consensus algorithm solve?1 / 10
Raft achieves consensus in a distributed cluster — agreement on a replicated log even when some nodes crash or are slow. It elects a leader via randomized election timeouts, and the leader serializes all writes, replicating to a majority quorum before committing.
What is the difference between @Controller and @RestController?1 / 10
@Controller returns view names (for server-side templates). @RestController = @Controller + @ResponseBody, so methods return data serialized directly to JSON/XML in the response body — the standard for REST APIs.
Hoare Triples A Hoare triple {P} C {Q} states partial correctness: starting from any state satisfying precondition P, IF command C terminates, the resulting state satisfies postcondition Q. Partial correctness is deliberately silent on term
Software
Software · L5 · Hoare Logic & Program Verification
Intermediate operations like `map` and `filter` are lazy and only build a pipeline; processing happens when a terminal operation (e.g. `collect`, `forEach`) is invoked.
Without an index, a query does a full collection scan (O(n)). Indexes (B-tree) let MongoDB locate matching documents quickly. Index fields used in query filters and sorts. Like any DB, indexes speed reads but slow writes and use memory.
Each isolate has its own memory heap and event loop and shares no mutable state with other isolates. They communicate only by passing messages over ports, which avoids data races and locks.