Advanced everything in Go & Rust, page 3
Rust Const Generics: Parameterize by Value, Not Just Type
Const generics let Rust types be parameterized by values, not just other types. This allows writing code generic over array sizes, like Matrix<T, const N: usize>, ensuring dimensions are checked at compile time.
Rust Procedural Macros: Code That Writes Code
Procedural macros are compile-time functions that write Rust code for you. They power common patterns like Serde's #[derive(Serialize)]. The main footgun is hygiene: generated code can clash with local variables, so authors must use absolute paths to be…
Go Execution Tracer: Pinpointing Concurrency Bottlenecks
Go's Execution Tracer creates a visual timeline of your program, capturing goroutine state changes, syscalls, and GC events. It's essential for diagnosing subtle concurrency issues like lock contention. The main footgun is misusing annotations for work.
Fuzz Testing in Rust with cargo-fuzz
Fuzz testing automatically finds bugs by feeding your code pseudo-random inputs. Use cargo-fuzz to stress-test parsers and APIs that handle untrusted data. The main footgun is assuming random bytes are enough; effective fuzzing needs structure-aware inputs.
Go Fuzz Testing: Automated Bug Discovery
Go's fuzz testing automatically generates strange inputs to crash your code, finding bugs you'd never think to test. It's ideal for stress-testing parsers or security-sensitive functions.
Foreign Function Interface (FFI): Calling Other Languages
Think of an FFI as a universal adapter, letting your program call functions written in another language. It's how modern code in Rust or Go can reuse battle-tested C libraries for tasks like graphics or system calls, avoiding a complete rewrite.
Go's `context` Package: Propagating Cancellation and Deadlines
Go's context package is a lifeline for requests, carrying cancellation signals, deadlines, and values across function calls and goroutines. It's essential for I/O-bound operations to prevent resource leaks.
Rust Build Profiles: Tune for Speed vs. Debugging
Rust build profiles are presets for the compiler, trading off compile time and debuggability for runtime speed. Use the dev profile for quick iteration and the release profile for production. The footgun is benchmarking without the --release flag.
Rust Cargo Features: Conditional Compilation & Dependencies
Cargo features are compile-time switches for conditional compilation and optional dependencies. They let you build tailored versions of a crate from one source, like an image library that only includes code for the formats you need.
Rust Build Scripts: Compiling More Than Just Rust
A build.rs script is a pre-compilation hook for tasks outside Rust's scope, like compiling C code or generating Rust modules. It's essential for FFI or code generation. A key footgun: cfg! checks the host, not the target, breaking cross-compilation.
Rust's Scoped Threads: Borrowing Across Threads Safely
Scoped threads let you borrow local variables from a parent thread without complex wrappers. The scope guarantees all spawned threads are joined before it exits, satisfying the borrow checker. Use it to parallelize work on stack data.
Go's Memory Model: Don't Be Clever
Go guarantees your program behaves predictably—as if on one CPU—if you prevent data races. Use channels or sync primitives to serialize access when goroutines share data. The footgun is relying on timing instead of explicit synchronization.
Send vs. Sync: Rust's Thread Safety Contracts
Send means a value can move to another thread; Sync means references to it can be shared. They are the compiler's contracts for preventing data races. The compiler checks them when you spawn threads.
Rust Marker Traits: Properties as Types
Marker traits are empty labels telling the Rust compiler about a type's capabilities, like being copyable or thread-safe. They have no methods; their presence is the signal. They're key for concurrency (Send/Sync) and memory (Copy/Sized) safety checks.
Rust Associated Types: One Trait, One Concrete Type
Associated types link a placeholder type to a trait, ensuring any implementation provides one specific type. This cleans up code, like in Rust's Iterator trait. The footgun: a type can only implement a trait with an associated type once.
Composable Error Types with `thiserror` in Rust
thiserror generates boilerplate for custom Rust error types, letting you define specific, matchable errors for a library. Use it when callers need to handle different failure modes. The footgun is using it for simple app errors where anyhow would suffice.
Rust's `panic!`: When to Crash Your Program Intentionally
Rust's panic! is an emergency stop for unrecoverable bugs, intentionally crashing the current thread. It's for impossible states where continuing is dangerous, not for recoverable errors like failed I/O—use Result for that.
Go's Panic/Recover: For Exceptional Errors Only
Go's panic/recover is a last-resort error mechanism, not a try/catch replacement. A panic unwinds a goroutine's stack until a recover in a defer'd function catches it. It's used to keep a server alive when one request fails catastrophically.
Rust's NLL: Smarter Borrows Based on Use, Not Scope
Non-Lexical Lifetimes (NLL) make Rust's borrow checker smarter. A borrow's lifetime ends after its last use, not at the end of its code block. This allows modifying data after a borrow is finished, even if the reference variable is still in scope.
Rust's Interior Mutability: Mutating 'Immutable' Data
Interior mutability lets you modify data through an immutable reference, moving Rust's borrow checks from compile-time to runtime. It's used in single-threaded code when the compiler can't verify safe access.
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