3 ms·
I don't know if the problem is that you don't know OCaml or that you don't know C, but yes, it is considerably harder; in OCaml you cannot embed objects in othe
by kragen 7y ago
I don't know if the problem is that you don't know OCaml or that you don't know C, but yes, it is considerably harder; in OCaml you cannot embed objects in other objects as you can in C (and C++, and Golang), because OCaml uses the Lisp memory model, as described in http://canonical.org/~kragen/memory-models http://canonical.org/~kragen/memory-models. Consequently you end up with things which are perhaps conceptually a single object potentially strewn around the heap at random, however the allocator and the garbage collector choose to arrange them, and linked together by pointers. There's a lot of payoff for this — it's safe and trivially easy to write parametrically polymorphic code in OCaml, while it ranges from fiddly and error-prone to overwhelming to impossible in different languages in the C family — but it's a major fundamental difference, and it does have some runtime efficiency costs.