Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

[language troll] D vs C++ vs C# vs Objectve C

Name: Anonymous 2005-10-19 2:37

ITT we post our opinions on which language is better at (performance || being object oriented || portability || whatever) and is the proper successor to C.

Name: Anonymous 2005-10-25 6:50

Last time I was badmouthing C I was told there were some good string libraries out there. Apparently IBM has one.

Coincidentally I started hacking on one last night. Mine focusses more on safety and ease of use than efficiency though. It's just a struct that wraps an int and a char* and a bunch of operations for writing to it while doing bounds checking and auto-expanding. Which I guess is the same as yours, except you use a clever trick so that it can still be accessed with array syntax. I might rip that off, heh.

Where they both fall down is needing to malloc/realloc, which for a string-heavy program is going to be slow. It might be necessary to write a custom memory manager specifically to try to reuse strings as much as possible to avoid allocating new memory for every single string. I have no fucking clue how to do that though, it might be necessary to sneak a peak inside Python or something to see how it does it.

I would recommend that you grow your arrays exponentially rather than linearly, for speed. If you double the size of your strings every time they get full, you will only need a logarithmic number of reallocs. On the memory side of things, your strings will never be less than half full - which is good compared to, say, linked lists which never use /more/ than half their memory for data.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List