24 Oct, 2009, David Haley wrote in the 81st comment:
Votes: 0
Generally speaking, C strings are good when you mean a sequence of bytes; C++ strings are good if you are using them as a sequence of letters that you append to and otherwise think of as things humans will see. C strings, for example, are typically more suitable if you are building a buffer of some sort, although in many cases C++ strings work fine too.

That said, KaVir is correct that you shouldn't go through and replace all of the C strings with C++ strings just for the sake of it. For starters, unless you had a C++ shared string library, you would indeed be increasing memory usage, as he said, in addition to the increase due to the inherent object-related overhead per string. The conversion is also an awful lot of work.

In general, you shouldn't go through with these massive overhaul-it-all projects unless you have a clear reason to do so (generally there isn't one). If you want to refactor code, do it piece by piece as you're working on that section anyhow.
24 Oct, 2009, Mudder wrote in the 82nd comment:
Votes: 0
Well mostly I'm wanting to get a handle on memory and how it works. Also the system that the MUD currently is using. I figure what better way to learn all this than by breaking it and trying to fix it?

If I use std::strings do I have to new/free them separately? I think there was another thread that touched on this.

EDIT: By this I mean do I have to keep them out of the "recycle" system that the MUD already does?
24 Oct, 2009, David Haley wrote in the 83rd comment:
Votes: 0
std::string objects manage themselves, but other objects containing std::strings must be created and destroyed using new/delete and not malloc/free.

If your goal is really to learn stuff by breaking it, you might want to try a smaller system. As KaVir said, there is a lot of potential for seriously nasty bugs if you try to do this without knowing what you're doing.

There's no problem in starting on something small to understand how things work, and then moving on to the bigger MUD system. :smile:
25 Oct, 2009, Mudder wrote in the 84th comment:
Votes: 0
Smaller system like TinyMUD, or smaller as in another program that is not a MUD at all?
25 Oct, 2009, Runter wrote in the 85th comment:
Votes: 0
Mudder said:
Smaller system like TinyMUD, or smaller as in another program that is not a MUD at all?


The way I read it he was suggesting that if a MUD contained multiple systems–Some large, some small– that you should be starting on smaller systems before trying to tackle overarching infrastructure in this codebase.

But you know, there's nothing wrong with just starting with small exercises and stand alone programs. That's how I've always learned new languages.
25 Oct, 2009, Davion wrote in the 86th comment:
Votes: 0
Runter said:
Mudder said:
Smaller system like TinyMUD, or smaller as in another program that is not a MUD at all?


The way I read it he was suggesting that if a MUD contained multiple systems–Some large, some small– that you should be starting on smaller systems before trying to tackle overarching infrastructure in this codebase.

But you know, there's nothing wrong with just starting with small exercises and stand alone programs. That's how I've always learned new languages.


A good example of this is stuff from the RaM project. http://www.mudbytes.net/index.php?a=file... is a conversion of the ban code to std::string by Ghasatta
25 Oct, 2009, Mudder wrote in the 87th comment:
Votes: 0
…Right under my nose.

KaVir said:
Most Diku muds have their own shared string handling. Replacing it with std::string would require quite a lot of work, could result in some seriously nasty bugs if you get it wrong, and would actually increase the memory overhead of the mud.


If done correctly, would it increase memory usage, or simply if done wrong?

While I likely won't be spending all my time trying to do this, I certainly want to become confident with memory and how the codebase functions before I move forward spending lots of time on development, otherwise I'll be spending even more time fixing up all the crap I added without realizing I was doing things "the wrong way."
25 Oct, 2009, Runter wrote in the 88th comment:
Votes: 0
It would indeed increase memory usage. C strings are lighter weight than std::string. Decreasing memory usage is not a reason for using std::string over c-strings.
25 Oct, 2009, David Haley wrote in the 89th comment:
Votes: 0
I meant either small systems in a codebase, or an entirely separate small system, even one you construct specifically for the purposes of learning how things work. You typically don't want to start with something huge as you're just barely getting started.
80.0/89