Monday, August 20, 2007

Java, C#, C++, why C++??

Last Sunday while boting, I noticed bot stopped with an "Unknown Errror" in the log. I do a catch on all exceptions in the main loop, and the unknown error is usually memory access exception (using memory that has been freed).

This was not a problem before, but since javascript is introduced, there are just many more ways for this to happen. Example, native code calls javascript code then call back to native code again, where some of the previous auto functions might became recurisive...

This bring up another interest question, why I didn't use C# at the begining? That will make all of memory access problems a NULL problem.

Well, in the very begining, I had 3 choices, Java (my previous favorite), C++ or C#.
Java is out because it is kinda slow (at least feels) and the bot uses too many windows APIs and JNI is a pain in the axx.
I almost pick C# but at the time I am not very familar with it and don't want spend time to find the invoke syntexs.
So I used C++ for testing and modeling, and what begins as an fun poking around habby turned out to be a full blown bot.
And now since all of the stuff already written, I don't want to convert any more.

After all, if I know the scope the current project is, I would not write it in the first place. They all comes small, like all my other proejcts, open source or not.

No comments: