Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.
Scope and conventions
TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.
No comparison
Compare with Go
Compare with Rust
Compare with C++
Testing
Node’s built-in runner for JavaScript/compiled TypeScript, Go testing, Rust cargo test, and optional GoogleTest for C++. Excerpts assume a test body and named application functions unless marked as complete.
A useful failure says which input failed, what was observed and what was expected. Assert public behavior; avoid pinning incidental private details that are free to change.
Fragment
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
case: empty inputobserved: one itemexpected: no items
Use temporary directories, unique database names/keys, random free ports and explicit clocks/configuration. Restore global state in cleanup when isolation is impossible. Tests that run in parallel must not mutate the same process-wide state unsafely.
Fragment
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
test A → its own directory / namespacetest B → its own directory / namespace
A stub supplies answers, a fake implements simplified behavior and a mock verifies chosen interactions. Keep essential protocol semantics in the double; separately test the real adapter against the real dependency.
Fragment
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
core logic → fake clock/storageadapter test → real clock/storage boundary
Inject a clock/scheduler or use the runner’s documented fake-time facilities. Advance to an observable condition; sleeping a guessed duration creates slow and flaky tests. Real I/O and other threads may not use the fake clock.
Fragment
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
arrange a deadlineadvance the controlled clockassert the observable transition
Cover ordinary input, empty/min/max values, malformed input, duplicates, missing values and meaningful ordering. Derive cases from the contract rather than repeating the implementation’s branches.
Fragment
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
empty / one / manyjust below / at / just above a thresholdvalid / malformed / missing
Property testing checks a relationship over generated inputs and often shrinks a failure. The language’s test runner alone does not always supply a property framework. Define input constraints and preserve the failing seed/example.
Start the actual dependency with a known configuration, create isolated data, exercise one external contract and tear it down. Include serialization, error mapping, timeouts and authorization where they belong to that boundary.
Fragment
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
unit: business rule with fake storageintegration: real driver + disposable databaseend-to-end: supported user workflow
Coverage shows what ran under a selected instrumentation model. A high percentage does not prove correct assertions, all input combinations or absence of races. Inspect missing meaningful behavior rather than forcing a target number.
Fragment
main.ts
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
line / branch / function coveragecovered code can still have a wrong assertion