~/talk

C# and Rust: combining managed and unmanaged code without sacrificing safety

Talkat NDC Oslo 2019 · 2019-06-17..06-21· [rust]
links:none on file
slides:none on file

Seq replaces its Windows ESENT-backed storage engine with a Rust engine and stitches it into an existing C# codebase using C-style FFI and P/Invoke stubs so .NET GC and thread semantics stay correct. Safety gets rebuilt with concrete types: DBResult thread-local last_result for errors, ref/out wrappers for fixed pointers, and handle_shared/handle_exclusive plus deferred cleanup and SafeHandle on the C# side to avoid races. Build trade-offs show up: C# debug builds ~3s, Rust ~2min, and runtime calls are dominated by disk I/O so the FFI overhead is acceptable; example repo (sled-based) proves it works.

AI-written summary · about

  1. 0:00Introduction to hybrid apps
  2. 2:46Use case: Seek database
  3. 4:48Defining hybrid applications
  4. 6:14Trade-offs and language choices
  5. 8:28Rust as advanced C# types
  6. 10:34Structs and ownership
  7. 12:21Sharing data: References
  8. 14:03Lifetime management
  9. 16:49Safety through the compiler
  10. 18:50C# ecosystem benefits
  11. 20:54Stitching languages together
  12. 25:06FFI and PInvoke
  13. 28:22FFI error management
  14. 32:14Pointers and reference safety
  15. 36:34Out parameters in FFI
  16. 39:23Safe handle implementation
  17. 43:23Thread safety: Send and Sync
  18. 50:30Handling thread-local data
  19. 52:10Example walkthrough
  20. 56:22Future of hybrid apps
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.