Hasty Briefsbeta

Bilingual

Rust, C++, and the Tradeoffs Behind Safe Low-Level Code

9 hours ago
  • #Game Development
  • #Systems Programming
  • #Programming Languages
  • Nikita Lisitsa suggests learning Rust and C++ in parallel due to shared concepts like low-level programming and RAII, though each has unique complexities like borrow checking or duck-typed templates.
  • For parallel programming, Rust is effective at preventing data races but may hide underlying complexity; Java might be cleaner for basics, while C++ offers deeper low-level insights.
  • C++ remains a strong systems programming choice, but the "best" language depends on the task, with alternatives like C, Rust, Go, and others being suitable in different contexts.
  • C++'s growing complexity, with features like modules and coroutines, is seen as justified for empowering programmers, though some prefer using only a subset of the language.
  • Memory safety isn't the most common bug in C++; tools like smart pointers and ASAN help, but logic errors dominate, so focus might shift to contract-based programming or proof-based languages.
  • Allocations and ownership are orthogonal in C++ and Rust; avoiding allocations is sometimes overemphasized, with performance analysis being more critical than blanket rules.
  • Rust could compete with C++ in game development but faces challenges due to strictness in experimental tweaking and lacks decades of tooling and platform support that C++ enjoys.
  • Engine vs. game-specific code boundaries are based on code quality and generality, with examples like a deferred renderer staying unused while a simple 2D painter class is frequently utilized.
  • In physics simulations, decisions on preserving invariants depend on gameplay interaction and cost; stability is key for soft-body spaceships, while water simulations prioritize local mass conservation over energy conservation for real-time performance.
  • Nikita avoids generic renderer backends, preferring to rewrite rendering engines per project to avoid over-abstraction, though switching APIs like OpenGL to Vulkan is manageable with minimal code changes.
  • Shipping Costa Verde reinforced the value of ECS (Entity-Component-System) after using generation-based handles for object management, highlighting a need for proper implementation in future projects.
  • C++ and Rust are expected to coexist peacefully with competition, with Rust gaining traction in safety-critical areas and potentially replacing C, but unlikely to fully supplant C++ due to its entrenched ecosystem.