Skip to content
tezvyn:

Go & Rust

Go web services, Rust backends, systems programming

68 bites

Test yourself: Top 30 intermediate Go & Rust concepts questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Intermediate concepts in Go & Rust, page 3

intermediate2 min read

Go's pprof: Finding Your Code's Hotspots

pprof is a heat map for your code, revealing which functions consume the most CPU. It samples your program's call stacks to find performance hotspots. Use it to diagnose slow API endpoints or high-CPU background jobs. The footgun: profiling under no load.

intermediate2 min read

Go Memory Profiling with pprof

pprof takes a snapshot of your Go app's memory usage, showing which functions allocate the most. Use it to diagnose high memory consumption or find leaks. A common footgun is profiling total allocations (allocs) instead of current memory use (heap).

intermediate2 min read

Criterion: Statistical Benchmarking for Rust

Criterion isn't just a stopwatch; it's a statistical lab for your code. It provides stable performance metrics by running functions many times, letting you detect regressions and prove optimizations. The footgun is ignoring its statistical reports.

intermediate2 min read

Rust Mocking: Using Traits as Test Seams

Mocking in Rust uses traits as test doubles. You program a mock's behavior—what calls to expect and what to return—to isolate the code under test. The mockall crate's #[automock] macro generates mocks from traits. The footgun is over-specifying behavior.

intermediate2 min read

Go Reflection: Inspecting Types at Runtime

Go's reflect package lets your program inspect and manipulate variables of unknown types at runtime. This is the engine behind JSON marshaling and generic frameworks. Misuse leads to slow code and runtime panics; always prefer interfaces when possible.

intermediate2 min read

Rust Declarative Macros (`macro_rules!`)

Think of macro_rules! as 'find and replace' for your code's structure. It matches patterns at compile time and expands them into boilerplate you don't want to write. It's used for helpers like vec![].

intermediate2 min read

Rust's `unsafe` Keyword: Five Superpowers, Zero Guarantees

Rust's unsafe keyword lets you bypass certain compile-time memory safety guarantees for low-level tasks like OS interaction or FFI. The footgun is thinking it disables all safety; it only enables five specific 'superpowers,' making you responsible for…

intermediate2 min read

Rust Raw Pointers: When References Aren't Enough

Raw pointers (*const T, *mut T) are Rust's C-style pointers, bypassing the borrow checker. They're used for FFI or building low-level abstractions. The footgun is assuming they're safe; they can be null or dangling, requiring unsafe to dereference.

intermediate2 min read

Go's `unsafe` Package: Breaking the Rules for Performance

Go's unsafe package lets you bypass type safety, treating memory like C with raw pointers for performance gains. It's used for low-level optimizations and C interoperability. The footgun: its behavior isn't guaranteed across Go versions, making code fragile.

intermediate2 min read

Cgo: The Bridge Between Go and C Code

Cgo is Go's bridge to the C world, letting you call C functions and use C types from your Go code. It's for leveraging existing C libraries or low-level OS APIs. The footgun: cgo calls have high overhead and break Go's simple cross-compilation.

intermediate2 min read

Rust: Bridging C Strings with CStr and CString

CString and CStr are Rust's safe wrappers for C's nul-terminated strings. CString builds a C-compatible string to pass *out* of Rust; CStr interprets one coming *in*. Use them for any FFI calls.

intermediate2 min read

Rust: Expose Functions to C with `#[no_mangle]`

The #[no_mangle] attribute tells the Rust compiler not to alter a function's name, exposing a stable symbol for C code to call. Use it with extern "C" to create Rust libraries for other languages. The footgun is forgetting extern "C", causing crashes.

intermediate2 min read

FFI Error Handling: Translation and Unwinding

FFI error handling is a translation layer: foreign errors must become Rust Results before safe code sees them, or you risk UB. You do this in -sys wrappers around C libraries. The footgun: foreign exceptions unwinding across boundary without -unwind ABI is UB.

The C Application Binary Interface
intermediate2 min read

The C Application Binary Interface

An ABI is the contract a library exposes for in-process machine code access. You see this whenever a compiled program calls into a compiled library at the binary level.

Go's Worker Pool Pattern: Capping Concurrency
intermediate2 min read

Go's Worker Pool Pattern: Capping Concurrency

A worker pool caps concurrency by using a fixed number of goroutines to process jobs from a queue. Use it for rate-limiting API calls or processing files without spawning unlimited goroutines.

intermediate2 min read

Go's Functional Options Pattern for Flexible APIs

The functional options pattern uses functions to set optional struct fields, making APIs flexible and readable. It's common for complex constructors like servers or DB clients.

intermediate2 min read

Rust's Deref Trait: Smart Pointers Acting Like Data

The Deref trait lets a "smart pointer" type act like the data it contains, making wrappers transparent. It enables calling an inner type's methods directly on a wrapper, like using &str methods on a String. Its deref() method must never fail.

Terminal User Interfaces (TUIs): GUIs for the Console
intermediate2 min read

Terminal User Interfaces (TUIs): GUIs for the Console

A TUI is a graphical interface built from text, offering rich interactivity without leaving the console. Use them for system monitoring (btop), file management, or database clients. The footgun: don't confuse them with CLIs; TUIs are stateful apps.

intermediate2 min read

Rust Lifetimes: Preventing Dangling References

Lifetimes are Rust's compile-time guarantee that a reference never outlives the data it points to. The borrow checker uses them to prevent dangling pointers, a common source of bugs.

intermediate2 min read

Rust's Fearless Concurrency: Catch Bugs Before They Ship

Rust's "fearless concurrency" uses the ownership and type system to turn data races into compile-time errors. This allows you to safely use threads, message passing, or shared state without runtime surprises. The footgun is assuming this prevents all bugs.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles