06 Mar, 2007, Darmond wrote in the 1st comment:
Votes: 0
ok I have noticed people saying that G++ is generaly better then GCC and that one should switch over to it instead of using GCC

now I have gotten ust to useing GCC since its what I have always worked with so I have to ask what are the major diferances between the two and how would this affect my code are they so difernt that it would make continueing my work difacult and I would have to relearn ?
06 Mar, 2007, Omega wrote in the 2nd comment:
Votes: 0
G++ puts you into the realm of working with C++, and having the full usage of the stl libraries.

Overloading functions, better memory management through new/delete apposed to calloc/free(or malloc if your being really icky)

basicaly, g++ gives you more options, not-to-mention the compiler is alittle bit more picky about code, so something that works in gcc, (but could be considered bad code) by g++, it'll let you know, by erroring out, it could be something that has always worked, but when they made g++ they considered that piece of code volitile, where-as it could break easily.

If you honestly want to know the difference, compile your mud in g++, take a gander at afkmud2, and see all its usage of stl.

and heres a point.

inside of your char_data or pc_data, you have int learnedG++ puts you into the realm of working with C++, and having the full usage of the stl libraries.

Overloading functions, better memory management through new/delete apposed to calloc/free(or malloc if your being really icky)

basicaly, g++ gives you more options, not-to-mention the compiler is alittle bit more picky about code, so something that works in gcc, (but could be considered bad code) by g++, it'll let you know, by erroring out, it could be something that has always worked, but when they made g++ they considered that piece of code volitile, where-as it could break easily.

If you honestly want to know the difference, compile your mud in g++, take a gander at afkmud2, and see all its usage of stl.

and heres a point.

inside of your char_data or pc_data, you have int learned[MAX_SKILL}; in some variation, most muds do.

if max-skill is big, your memory allotment for said structure will skyrocket, and your mud will eat more memory.

with g++, you could use stl's map system.

sorta like this..

std::map<int, int>learned;

and with alittle re-working, the skill system goes uber cool, and you can parse your skills faster then rotating through the entire skills list.

its things like that, they help optimize and maximize your ability to code.
06 Mar, 2007, Davion wrote in the 3rd comment:
Votes: 0
Darmond said:
ok I have noticed people saying that G++ is generaly better then GCC and that one should switch over to it instead of using GCC


A common misconception. g++ -is- gcc. They're all the GNU C Compiler. G++ is simply a wrapper for gcc to use the C++ language. There are some slight differences with the language, however, but you should notice them at compile time. What would you have to re-learn? Absolutely nothing. The only thing using g++ does for you is allow you to use the C++ language. If you don't know C++ and you don't want to learn it, then porting to g++ is meaningless, however, if you want to open up your mind to C++ go for it! You can go out a buy a C++ book or you can scour the internet for free tutorials, and even free C++ books. There's tons of people out there willing to help (freenode's ##c++ channel for instance, good place to start. Lots of links in the topic to free books, stl references and the like.)
06 Mar, 2007, Guest wrote in the 4th comment:
Votes: 0
Even if you never learn a lick of actual C++ concepts like OO programming, classes, inheritence, the STL, etc, you can still use g++ as the compiler. Since it's generally more strict in what it will accept, it can be good as a later stage of code cleanup. Especially in combination with certain compiler flags designed to bring forth more warning messages. Used in this capacity, g++ is more like an advanced gcc.
06 Mar, 2007, kiasyn wrote in the 5th comment:
Votes: 0
It may be worth noting that if you are not a confident programmer the warning/error messages from stl can be quite intimidating.
06 Mar, 2007, Guest wrote in the 6th comment:
Votes: 0
Using g++ as the compiler doesn't require using the STL. And you shouldn't see any errors from that unless you've specifically tried to use it.
06 Mar, 2007, Justice wrote in the 7th comment:
Votes: 0
kiasyn said:
It may be worth noting that if you are not a confident programmer the warning/error messages from stl can be quite intimidating.


Heh, I'd say that competance is more important. I've known many "confident" programmers who never managed to get their code to work.
06 Mar, 2007, Justice wrote in the 8th comment:
Votes: 0
You shouldn't need to learn much to use G++ over GCC. You'll probably find a few extra errors and warnings, but for the most part they'll be easy. If you need help interpreting them, I'm sure there are plenty here who'll be willing to help (including myself).

Now, it's more than worth it to learn a little C++. You don't need an in-depth understanding of OOP to make use of STL or classes (but it helps). Most of the snippets I've submitted for SmaugFUSS had a little C++ in them.
06 Mar, 2007, Darmond wrote in the 9th comment:
Votes: 0
mmmm this actualy sounds good all in all now that I know this I will probobly try to switch over I know some of the ideas I have will likely take up a lot of memory so saveing memory is always good. I will defintly look into converting now could help out a lot any ways thanks for takeing the time to answer
06 Mar, 2007, Omega wrote in the 10th comment:
Votes: 0
i mentioned before the skill system, using std::map for it.

normaly, when you parse through your skills, you do something like this.

for(x = 0; skill_table[x].name != NULL; x++)
{
if(ch->pcdata->learned[x] > 0)
do_something;
}


with the map, this is how my skills save, no more parsing the entire skill-list.
for(SkillsMap::iterator skill_iter = ch->pcdata->learned.begin(); skill_iter != ch->pcdata->learned.end(); ++skill_iter)
{
// don't save-it so it won't load!
if(skill_table[skill_iter->first].rating[ch->Profession] <= 0)
continue;

fwritef( fp, "Sk %d '%s'\n", skill_iter->second, skill_table[skill_iter->first].name );
}


its VERY fast for saving, you save milliseconds, but when you add up all the calls, and changing
all the functions that check skills to this instead of checking all the skills, then, your pretty much
speeding up the mud.

This is just one little example of how c++ conversion can be quite a big help.

Case and point, sandstorm was 500,000+ lines of code, the use of c++ with stl has caused
a significant drop in lines of code. with me tidying it up beyond that of what was originaly
required todo c++ and optimizing using stl in places that it could, we've cut almost 50k worth
of lines, just from the c++ conversion.

Its worth it. It really is.
06 Mar, 2007, Conner wrote in the 11th comment:
Votes: 0
Ok, looks like my understanding of this was right, g++ is gcc with C++ compiling turned on, so the only advantage to using g++ over gcc is if you intend to utilize C++ or convert to it.

As for confidence vs. competence regarding error messages, I think confidence would be more of the factor involved in what Kiasyn was saying because if you're competent those error messages are meaningful and not really a problem, where a programmer who lacks confidence in his/her ability might find the same error messages daunting and disturbing.
07 Mar, 2007, Omega wrote in the 12th comment:
Votes: 0
i remember when i converted to g++

all my ->class variables had to be changed, i was sooo distrot… BUT… good news! I found out what classing was..

HAHAHAHAHAHA. I originaly started my port to g++ so that i'd have a more picky compiler choice, because it picks up on bad coding allot easier. atleast in my opinion, cuz it just won't leave me alone ;)

In anycase, after i got exposed to the demon :evil: stl, i just couldn't stop… i wanted more… MORE… MOOOORRREEEEE! And now my mud is more stable then it ever has been, which is saying something cuz i am quite the sloppy coder when it comes to sandstorm, I try every new idea i can find. which always ends up with me doing some daunting task. BUT, its always worth it in the end, i learn.


most of what i've learned is going into rocs, which tehe, will be c, and c++ in due-time :P

but yeah, c++ 4eva!
07 Mar, 2007, Kayle wrote in the 13th comment:
Votes: 0
Now I feel a need to hybridize MW inot a C/C++ Hybrid with eventual full conversion.. damn you people and being Informative. :tongue:
07 Mar, 2007, Omega wrote in the 14th comment:
Votes: 0
we try, we try…

personaly, its all worth it :)
07 Mar, 2007, Justice wrote in the 15th comment:
Votes: 0
So yeah, I agree that C++ allows you to reduce the code by allowing you to reuse it.

I think my ranged search code is a good example of this. Basically I have code that searches the surrounding rooms, and you simply write an object to handle each individual room. I thought about making it a function, but using an interface allows you to store information. Other parts of C++ that save time/code are templates, and operator overloading. Although with operator overloading you should be careful that it makes sence. I've used that with my coordinates by allowing you to add directions to create an offset coordinate.
07 Mar, 2007, Omega wrote in the 16th comment:
Votes: 0
i completely agree with that statement justice. I really do, as it stands, C++ is a great method of expansion, and it opens you up to a higher range of coding skills if you take the time to learn what C++ has to offer.
08 Mar, 2007, Davion wrote in the 17th comment:
Votes: 0
Justice said:
Other parts of C++ that save time/code are templates, and operator overloading. Although with operator overloading you should be careful that it makes sence. I've used that with my coordinates by allowing you to add directions to create an offset coordinate.


Operator overloading is awesome! Another use is it allows you to totally rewrite a core class, but not necessarily have to update the entire codebase. The first thing I ported to C++ when I got ROM to compile under G++ is a much more dynamic exit code. I overloaded operators so that the class acted as an array requiring me not to update what code was already in place (for a rom it was about 120k lines of code, so it saved lots of time!). It was basically just another layer between myself and the core of exit data.

I've also found much love for methods, inheritance and templates. These are some tools a programmer should never live without!
08 Mar, 2007, Justice wrote in the 18th comment:
Votes: 0
Yeah, several of my snippets were ported to SmaugFUSS from some C++ code I have. It makes heavy use of operator overloading and templates. I have several naming conventions that the templates are based on, this allows me to reuse the code by composition instead of inheritance. I've emulated the IO libraries by overloading << and >> for passing events down channels. Everything in the code is event driven and things are chained on each other… uh, it would be hard to explain unless you were familiar with GroundZero, but it's my version of it.
0.0/18