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.
std::array<T, N> has a fixed size; vector<T> is growable. at checks bounds and throws; [] requires a valid index. pop_back removes without returning a value and requires a nonempty vector.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
unordered_map is hash-based; map orders keys. find checks without insertion. operator[] inserts a default value for a missing key. contains is available from C++20.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.cpp
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
#include <unordered_map>#include <string>std::unordered_map<std::string, int> scores;scores["north"] = 24;auto it = scores.find("north");if (it != scores.end()) { int score = it->second;}
unordered_set uses hashing/equality; set uses ordering. insert returns information about whether insertion happened. contains is C++20; find/end can also test membership.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.cpp
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
#include <unordered_set>#include <string>std::unordered_set<std::string> labels;labels.insert("north");bool found = labels.contains("north");labels.erase("north");
span<T> is a non-owning contiguous view (C++20). subspan takes an offset and count. The storage must outlive the view and remain valid; a vector reallocation can invalidate it.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.cpp
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
#include <span>#include <vector>std::vector<int> values{2, 5, 8};std::span<int> all{values};auto part = all.subspan(1, 2);part[0] = 9; // values[1] is now 9
std::sort mutates a range. Its comparator returns true when the first value precedes the second, not a numeric difference. std::stable_sort preserves equivalent-element order. Comparators must satisfy the ordering contract.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.cpp
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
#include <algorithm>#include <vector>std::vector<int> values{12, 2, 5};std::sort(values.begin(), values.end(), [](int a, int b) { return a < b; });
C++20 range adaptors can compose lazy views with |. Constructing a view does not execute a full eager pipeline. Referenced source storage must remain valid while the view uses it.
Fragment
Fragment: imports and type/function declarations at file scope; usage statements inside a function.
main.cpp
Follow appearance
✓GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
#include <ranges>#include <vector>std::vector<int> values{2, 5, 8};auto result = values | std::views::filter([](int n) { return n > 3; }) | std::views::transform([](int n) { return n * 2; });