Hacker News new | past | comments | ask | show | jobs | submit login

You can instruct the Nim GC to not do that using GC_ref (http://nim-lang.org/docs/system.html#GC_ref,string).



That's what I figured. So not "trivial".


You are right, this situation is not trivial. But it is also quite rare in practice


Are you aware of any language's whose FFI is that trivial?


Do I have to be aware of some other language with such a trivial FFI in order to question the claim that Nim has such a trivial FFI?

(C++ has such a trivial FFI, as well as non-GC languages which compile to C code... there may be more as well)


Sorry, it wasn't my intention to imply that. I'm genuinely curious, I haven't used many language's FFI to know which is best.

You mention non-GC languages. Are there any GC languages that do? :)


The example for Go looks pretty straight-forward:

https://golang.org/cmd/cgo/

Not an expert on these things by far but I remembered painless use of C in that language and it's GC'd. Thoughts?


There are various restrictions on passing pointers between Go and C, see the "Passing pointers" section of your link.


Yeah, that does start getting complicated enough to change the code on either side.


I don't think so. I think by virtue of having a GC language you pretty much have to manually anchor pointers before calling code which knows nothing of the GC.

But if anyone knows of counter examples, I would be interested in them as well.


> you pretty much have to manually anchor pointers before calling code which knows nothing of the GC.

Which I'd still consider trivial...


I wouldn't. Trivial to me means a call to a C routine looks and feels like a call to a native routine.

Manually managing the memory that the GC "owns" doesn't fit the bill in my definition.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: