[MUD-Dev] New Beginings

Lars Duening lars at bearnip.com
Tue Jun 4 13:27:22 CEST 2002


David B. Held wrote on Monday, June 03 2002, 14:29:55:

> I don't buy that Java or Python are "often within 5% of the
> performance of C++", unless you hand-pick the worst C++ coders you
> can find.  I also reject the claim that they are "better at memory
> management".  GC != "better memory management".  In fact, RAII is
> very nearly optimal usage of memory in most cases, is easy to make
> exception-safe, and doesn't stall your application while the GC
> thread kicks in.  And if you really feel you need the crutch of
> GC, you can always use a GC lib in C++.

I am sorry, but I have to wear my language designer's hat for a
moment: GC is not a crutch. On the contrary, it is one of the most
widely used techniques in large-scale programming, even if most of
the time the programmers don't even realise it.

Every time a programmer uses a tracking mechanism for memory
allocations - and this includes manually managed reference counters
- he or she is using a GC. So for a complex program like a MUD
engine, the question is not whether to use GC or not, but rather
where to use it and how to give it optimum efficiency.

For my own LDMud driver I am reaching the point where the simple
manual reference counting for the complex data structures is no
longer sufficient. While switching from C to C++ as implementation
language would help a bit (the reference counting code could be
wrapped into assignment operators, thus greatly reducing the change
of miscounts), the need to adjust the counters would still slow down
every pointer assignment. Furthermore, when freeing deeply nested
datastructures there is always the chance of the driver running out
of stack space and crash (it did happen!). I could (and most likely
will have to) avoid this by checking the stack usage on every free
operation, but it will reduce the speed advantage of the manual
reference counting even further - and I'd introduce a memory leak
every time this situation happens.

Would I want to switch to Java? No. But that is not because Java has
an integrated GC, but because the GC is integrated badly into the
language.

--
Lars Duening; lars at bearnip.com
PGP Key: http://www.bearnip.com/lars/pgp-lars.asc

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list