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 134

Go & Rust2 min read

Go if err != nil versus Rust's ? operator

Go's explicit checks are verbose but make every error site visible; Rust's ? propagates concisely while still forcing the error into the type, reducing boilerplate.

Go & Rust2 min read

anyhow versus thiserror in Rust error handling

Anyhow gives one opaque dynamic error type for applications where you mostly propagate and report; thiserror derives concrete typed enums for libraries so callers can match on variants.

Go & Rust2 min read

Implicit Go interfaces versus explicit Rust trait impls

Go's implicit satisfaction enables decoupling and retrofitting but hides who implements what and risks accidental conformance; Rust's explicit impls aid discovery, refactoring…

Go & Rust2 min read

Go scheduler work-stealing and blocking syscalls

The GMP model runs goroutines (G) on OS threads (M) attached to logical processors (P); idle P's steal half of another P's run queue; on a blocking syscall the M detaches with its G.

Go & Rust2 min read

Cancellation and cleanup: Go context/errgroup vs Tokio

Go propagates cancellation via context.Context that goroutines must poll, with errgroup canceling siblings on first error; Tokio cancels by dropping futures, which stops them at await…

Go & Rust2 min read

cgo threading challenges with multi-threaded C libraries

Cgo calls run on a dedicated OS thread and detach the P; thread-local state and callbacks into Go are fragile; solutions include LockOSThread, minimizing crossings, and a dedicated…

Go & Rust1 min read

Design a graceful worker pool in Go

Buffered job channel, fixed worker goroutines, WaitGroup to await in-flight work, context cancellation to stop intake.

iOS & Swift2 min read

What is the difference between let and var in Swift?

This tests value semantics beyond syntax. A strong answer defines let as immutable and var as mutable, notes that let on a reference type only fixes the pointer, and cites clearer intent and compiler optimization.

iOS & Swift2 min read

What is an optional in Swift? Demonstrate two safe unwrapping methods.

This checks Swift type safety and nil-handling. A strong answer defines Optional as an enum, demonstrates if let binding, and shows the nil-coalescing operator ?? for defaults. Avoid suggesting force-unwrapping with ! as a safe pattern.

iOS & Swift1 min read

How does Swift's switch differ from C's switch?

Switches must be exhaustive, there is no implicit fallthrough between cases, and cases can match ranges, tuples, and bind values.

iOS & Swift2 min read

Explain the primary differences between a struct and a class in Swift

Tests value versus reference semantics and their impact on memory and mutation. Strong answers note structs copy on assignment and lack inheritance, while classes share heap instances via ARC. Red flag: claiming structs are always stack-allocated.

iOS & Swift1 min read

Why can't you subscript a Swift String with an Int?

Characters are extended grapheme clusters of variable byte width, so integer offsets are not O(1) or meaningful; String.Index is an opaque position you advance via the collection.

iOS & Swift1 min read

What is @autoclosure and when is it useful?

@autoclosure wraps an argument expression in a closure so it evaluates lazily only if used, enabling clean APIs like assert and the ?? operator.

Swift struct vs class: differences and when to choose each
iOS & Swift2 min read

Swift struct vs class: differences and when to choose each

Tests value vs reference semantics and let mutability. Strong answers contrast copy behavior with shared references, note allocation tendencies, and choose struct for value semantics or class for identity.

iOS & Swift2 min read

Explain protocols and how extensions provide default implementations

Tests behavior sharing without inheritance. A strong answer defines protocols as requirements, shows extensions injecting default implementations, and contrasts this with base-class inheritance.

iOS & Swift2 min read

What is a retain cycle in ARC with closures?

It tests reference counting and closure capture semantics. A retain cycle forms when a closure captures self strongly while self holds the closure; break it with weak if self can deallocate, or unowned if it will outlive the closure.

iOS & Swift2 min read

What are Swift generics, why useful, and write a swap function?

This tests parametric polymorphism and type-safe reuse. A strong answer defines generics as placeholder types for reusable code, then writes a swap<T> function using inout parameters. Red flag: confusing generics with Any or omitting inout.

iOS & Swift2 min read

What is a closure capture list? Explain [weak self] versus [unowned self].

Define capture lists, contrast [weak self] safe optionality against [unowned self] crash risk, and match each to lifetime guarantees.

Explain Copy-on-Write in Swift and implement it for custom structs
iOS & Swift2 min read

Explain Copy-on-Write in Swift and implement it for custom structs

Tests value semantics with reference storage and uniqueness checks. A strong answer explains CoW delays copy until mutation via isKnownUniquelyReferenced, lists custom steps: wrap, read, check, clone. Red flag: assuming structs are automatically CoW.

iOS & Swift2 min read

How does Swift async/await improve on completion handlers?

Tests structured concurrency mastery over callback control flow. A strong answer covers inversion of control, suspension points as yield locations, and Tasks as parent-child units.