Comment by warangal

3 years ago

I write most of my code in Nim language, and it generally involves wrapping up some C codebase, or calling DLLs routines and working with raw pointers. Although Nim has it own GC or ARC to handle memory management for its native data-structures, i find it really helpful to define a `destructor` for any arbitrary objects/structs. Since language can track lifetime of any object/struct during compilation and can call corresponding `destructor` for that object, which generally is just a `free()` or `some dll exposed routine`. I end up using language to handle all the manual memory management even for existing C codebase. With new ARC, all destructor calls are inserted with compilation and hence no extra GC based runtime to deal with, and even works flawlessly with GPU programming stuff too ! I haven't used many programming languages, but personally find it really useful to use any language as an assistant to help solve issues outside of their intended context.

I also have written about patterns i find useful when dealing with existing C codebases at https://ramanlabs.in/static/blog/raw_memory_management_with_...

Nim is a sleeper, plenty of GC options from ORC to manual and great C FFI.

Wish the big corps had backed it, or Zig, over drab stuff like Go.