[MUD-Dev] Programming Languages.
Kwon J. Ekstrom
justice at softhome.net
Fri Jul 4 10:15:37 CEST 2003
MIKE MacMartin wrote:
> I'm using C++ for mine, mostly 'cause its the language I know
> best.
> Java and C both have large amounts of problems - Java with the
> fact that you're never guaranteed to have an object go away, or a
> destructor called (limiting what you can do with your objects) and
> C
This is inaccurate, you're 100% guaranteed that the garbage
collector will pick up any object and run it's finalize method if
you remove all references to an object. You're not guaranteed when
this will happen.
Now, because it's quite easy to lose a reference somewhere., what I
do is have a set of ints to keep track of things. instances,
destroys, and finalizations. If destroys != finalizations then you
still have some objects waiting to be gc'd.
Additionally, this is the purpose of the java.lang.ref package.
It's to allow you to reference objects in a major that doesn't
prevent garbage collection.
Another trick (I've used this with pools) is to use the finalize
method to create a new reference (putting the object back in the
pool if it's below "threshold"). You're guaranteed that there
aren't any references to it if the GC picked it up. (not sure about
java.lang.ref based references) This prevents the GC from
deallocating the memory.
> comparing against 0). They're both useful, and could do a good
> job, but as I see it, it's easier to write it in a language where
> the correct paradigm is already there for you (for example, my
> library uses extensive use of map<string, int> and map<string,
> string> so that I don't proscribe a system to the people using
> it.)
I find it's easier to write in a language you know well.
Since you stated that C++ is the language you know best, then go for
it. Of course, Java is the language I know best.
-- Kwon J. Ekstrom
_______________________________________________
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