Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

4330 bites

Page 130

Go & Rust2 min read

How does a Go type satisfy an interface? Provide an io.Reader example.

This tests implicit structural typing in Go. A type satisfies an interface by implementing every required method with exact signatures; no declaration links them. A red flag is claiming you need an implements keyword or explicit conformance.

Go & Rust2 min read

What is the difference between defining a Rust trait and implementing it?

Define with trait and signatures; implement with impl Trait for Type and concrete bodies.

Go & Rust2 min read

Explain Go's empty interface, safe usage, and runtime risks

Interface{} (alias any) holds values; unpack with type switches or ok assertions; risks are panics from bare assertions and nil interface vs nil concrete value confusion.

Go & Rust2 min read

Static dispatch with impl Trait versus dynamic dispatch with Box<dyn Trait>

Tests monomorphization versus vtables. Note: static dispatch monomorphizes for zero-cost abstraction but bloats code; dynamic dispatch uses vtables for smaller binaries but adds indirection.

Go & Rust1 min read

Value versus pointer receivers and interface satisfaction

Value-receiver methods belong to both T and *T, but pointer-receiver methods belong only to *T, so a value of T may not satisfy an interface.

Go & Rust2 min read

Describe Rust's orphan rule and its ecosystem purpose

State that either trait or type must be local; explain this stops conflicting foreign impls; note crates.io would see silent impl collisions breaking downstream builds.

Go & Rust1 min read

Associated types vs generic type parameters in traits

Associated types fix one type per implementer; generics allow many impls; Iterator::Item is the canonical example.

Go & Rust2 min read

What is the fundamental difference between a goroutine and an OS thread?

This tests your grasp of Go's M:N scheduler. A strong answer notes that goroutines are runtime-managed, multiplexed onto OS threads, and use far less memory per unit, enabling thousands of concurrent tasks.

Go & Rust2 min read

How do Send and Sync prevent data races? Give a Send-but-not-Sync example.

Explain Send moves values and Sync allows shared references across threads; give Cell as Send but not Sync because it has interior mutability.

Go & Rust2 min read

Buffered vs unbuffered Go channels and deadlock scenario

Tests channel synchronization semantics. Unbuffered channels block until sender and receiver rendezvous; buffered channels block only when full or empty. Deadlock: goroutine sends on unbuffered channel with no receiver.

Go & Rust1 min read

Sharing mutable state: Go mutex vs Rust Arc Mutex

Go uses sync.Mutex by convention; Rust wraps data in Arc<Mutex<T>> so locking is mandatory, enforced by Send/Sync and the borrow checker.

Go & Rust1 min read

Rust async/await vs Go goroutines

Go schedules goroutines on a built-in runtime transparently; Rust futures are inert until polled by an external runtime like Tokio, and async colors functions.

Go & Rust2 min read

What is Go's context package and how do you use WithCancel?

This tests cancellation propagation. A good answer says Context carries deadlines, signals; derive a child with WithCancel, pass it to worker, then call cancel to unblock ctx.Done. Bad: storing context in structs, leaking cancel functions, or ignoring Done.

Go & Rust2 min read

Go select vs Rust select! fairness and determinism

This tests runtime fairness in concurrent primitives. Contrast Go's pseudo-random case selection with Tokio's randomized default and its opt-in biased; top-down mode. Red flag: claiming Go uses source order or that Rust randomization is unavoidable.

Go & Rust2 min read

When should Rust atomics replace a Mutex, and how do orderings work?

Atomics replace mutexes for counters; Relaxed is atomicity only, SeqCst adds global order, weaker ones skip fences on ARM.

Go & Rust2 min read

How do you initialize and manage Go dependencies?

Init with go mod init; use go get and go mod tidy; go.mod sets path and versions, go.sum stores checksums for verified builds.

Go & Rust2 min read

What is the difference between Cargo.toml and Cargo.lock?

Cargo.toml declares broad requirements; Cargo.lock pins exact resolved versions.

Go & Rust2 min read

What Go tool detects data races and how do you invoke it?

This tests Go's built-in race detector. A strong answer names the -race flag, notes it instruments memory accesses to catch concurrent unsynchronized reads/writes, and shows go test -race. A red flag is confusing it with static analysis or external tools.

Go & Rust2 min read

How does cargo differentiate unit and integration tests by location?

This tests Rust test layout conventions. Unit tests live inside src files in cfg(test) modules; integration tests go in top-level tests/ files as separate crates. Red flag: saying integration tests need cfg(test) or can use private APIs.

Go & Rust2 min read

Difference between go build and go install? Cross-compile for ARM64 Linux?

Tests Go toolchain artifact placement and native cross-compilation. A strong answer distinguishes go build (current directory) from go install ($GOBIN), then sets GOOS=linux GOARCH=arm64 for cross-compilation.