Login
User Name:

Password:



Register
Forgot your password?
LOP Building Guide v1.0
Author: Hanaisse
Submitted by: Hanaisse
Reset Guide
Author: Hanaisse
Submitted by: Hanaisse
LOP 1.38r2
Author: Remcon
Submitted by: Remcon
LOP 1.37
Author: Remcon
Submitted by: Remcon
LOP 1.36
Author: Remcon
Submitted by: Remcon
Yahoo! Slurp, MSN Search

Members: 0
Guests: 2
Stats
Files
Topics
Posts
Members
Newest Member
369
3,185
15,632
526
Craty####
» SmaugMuds.org » Codebases » SmaugFUSS » Why g++?
Forum Rules | Mark all | Recent Posts

Why g++?
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #1 Jun 24, 2009, 5:53 pm
Go to the bottom of the page Go to the top of the page
Tonitrus
Fledgling
GroupMembers
Posts47
JoinedJun 24, 2009

I've noticed that Smaugfuss 1.9 uses g++ to compile.  I'm not overly thrilled about this, since I don't use C++ (related to the fact that I thoroughly despise it), nor do I particularly understand the error messages I receive.  I've skimmed around a few times looking for C++ code since I recall reading that Kayle's weather code only compiles under g++ (assuming that meant it was C++ code), and haven't seen any C++ specific syntax or the .cpp file extension.

So, why is g++ used for compiling, and how much trouble would it be to switch to gcc?

If I switch the Makefile to gcc, I see only errors in weather.h, and a few issues with mud.h.

Depending on why g++ is used and whether I intend to stubbornly ignore those reasons (likely), I'll probably just switch it to gcc and strip out all offending code, but, as a heads-up, I'd prefer to know how much trouble that's going to be before-hand.

Thanks, etc.
       
Post is unread #2 Jun 24, 2009, 6:27 pm
Go to the bottom of the page Go to the top of the page


Kayle
Nibelungen
GroupAdministrators
Posts885
JoinedMar 21, 2006
WWW

I'm sorry, I laughed at this. You thoroughly despise a language that is the same as the language you're using but with extra stuff added for ease of programming? Anyway, on to the serious answers.

Why g++? Because it's a stricter compiler and makes us write cleaner code, and with regards to the const stuff, proper code. As for how much trouble it will be to switch back? It's going to be a lot of trouble. Since we use operator overloading in several places and gcc isn't going to like that. Seeing errors in the headers is all you will see, until you make those errors go away, either by deleting the offending code, or by using some kind of hack to get around them. And then you're going to see a whole mess of issues pop up with it gets to actual lines of code where the overloaded functions come into play.

I seriously don't understand peoples aversion to C++ it's not like it makes it any slower or anything to compile under g++, if anything it's going to help you in the long run because it's not going to let you do things you shouldn't be doing in the first place. .........................
Owner/Coder                                                                    Coder
Malevolent Whispers                                                        Star Wars: The Sith Wars
{Development Phase - Not accepting players}                {Open Alpha - Players welcome, but with frequent changes to core systems.}
IMC2 Contact: Kayle@MW                                                IMC2 Contact: Kayle@SWTSW
       
Post is unread #3 Jun 24, 2009, 7:17 pm
Go to the bottom of the page Go to the top of the page
Tonitrus
Fledgling
GroupMembers
Posts47
JoinedJun 24, 2009

So I have been grepping for "overloading" syntax, which I know little about for previously mentioned reasons.  All the example code I've seen includes the text "operator", which returns nothing apparently related on grep.  Would you mind pointing out some example of where this occurs in the 1.9 fuss code?
       
Post is unread #4 Jun 24, 2009, 7:25 pm   Last edited Jun 24, 2009, 7:28 pm by Metsuro
Go to the bottom of the page Go to the top of the page
Metsuro
Apprentice
GroupMembers
Posts68
JoinedSep 2, 2006

http://www.cprogramming.com/tutorial/operator_overloading.html Ok this link is a bit easier for me to understand. I use cprogramming.com as an overall starting point for my C and C++ learning.
       
Post is unread #5 Jun 24, 2009, 7:31 pm
Go to the bottom of the page Go to the top of the page


Kayle
Nibelungen
GroupAdministrators
Posts885
JoinedMar 21, 2006
WWW

Might have meant function overloading. I don't know. Technical terms always escape me. Anyway example:

Code:
/*
 * Removes the tildes from a string.
 * Used for player-entered strings that go into disk files.
 */
void smash_tilde( char *str )
{
   for( ; *str != '\0'; str++ )
      if( *str == '~' )
         *str = '-';

   return;
}

const char* smash_tilde( const char *str )
{
    static char buf[MAX_STRING_LENGTH];
    mudstrlcpy( buf, str, MAX_STRING_LENGTH );
    smash_tilde( buf );
    return buf;
}

char* smash_tilde_copy( const char *str )
{
    char* result = strdup(str);
    smash_tilde(result);
    return result;
}


There were other places as well. one_argument comes to mind. .........................
Owner/Coder                                                                    Coder
Malevolent Whispers                                                        Star Wars: The Sith Wars
{Development Phase - Not accepting players}                {Open Alpha - Players welcome, but with frequent changes to core systems.}
IMC2 Contact: Kayle@MW                                                IMC2 Contact: Kayle@SWTSW
       
Post is unread #6 Jun 24, 2009, 8:10 pm
Go to the bottom of the page Go to the top of the page
Tonitrus
Fledgling
GroupMembers
Posts47
JoinedJun 24, 2009

Kayle said:
Technical terms always escape me.


I have a similar problem.

one_argument and smash_tilde would agree with what gcc is saying about conflicting declarations.

Thanks for the help.
       
Post is unread #7 Jun 24, 2009, 8:32 pm
Go to the bottom of the page Go to the top of the page


Kayle
Nibelungen
GroupAdministrators
Posts885
JoinedMar 21, 2006
WWW

Just to be clear, Are you ripping these out and going back to gcc, or are you keeping it in g++? .........................
Owner/Coder                                                                    Coder
Malevolent Whispers                                                        Star Wars: The Sith Wars
{Development Phase - Not accepting players}                {Open Alpha - Players welcome, but with frequent changes to core systems.}
IMC2 Contact: Kayle@MW                                                IMC2 Contact: Kayle@SWTSW
       
Post is unread #8 Jun 24, 2009, 9:13 pm
Go to the bottom of the page Go to the top of the page
Tonitrus
Fledgling
GroupMembers
Posts47
JoinedJun 24, 2009

For the moment, I have it set back to g++.  I'm pretty much going to follow the path of least resistance.  If I try to compile something and I don't understand the g++ message, I switch it to gcc and see what it says.  Sometimes nothing.  I have no opinion regarding g++ whatsoever, I just don't understand the error messages I get when compiling.  So if it keeps confusing me, then I'll see about switching it (permanently) to gcc.
       
Post is unread #9 Jun 24, 2009, 9:29 pm
Go to the bottom of the page Go to the top of the page


Kayle
Nibelungen
GroupAdministrators
Posts885
JoinedMar 21, 2006
WWW

You could always, ask on here. That's what the community here is for. Getting help. .........................
Owner/Coder                                                                    Coder
Malevolent Whispers                                                        Star Wars: The Sith Wars
{Development Phase - Not accepting players}                {Open Alpha - Players welcome, but with frequent changes to core systems.}
IMC2 Contact: Kayle@MW                                                IMC2 Contact: Kayle@SWTSW
       
Post is unread #10 Jun 24, 2009, 10:10 pm
Go to the bottom of the page Go to the top of the page


Samson
Scaly but Handsome
GroupAdministrators
Posts3,347
JoinedJan 1, 2002
WWW

You'll be going against the grain by insisting on trying to switch back to gcc. Future development is never going to regress backward, only push forward.

The error messages in g++ are no more or less weird than some things I've seen in gcc. Google usually has something somewhere if you look. Failing that, coming here with the compiler's error output and asking "WTF" is a pretty quick and easy way to work through it. .........................
PDNS-Admin | Top MUD Sites | Arthmoor MUD Hosting Services | The Truth About Medievia: A Saga of Code Theft.

"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
       
Post is unread #11 Jun 24, 2009, 10:20 pm
Go to the bottom of the page Go to the top of the page


Quixadhal
Conjurer
GroupMembers
Posts265
JoinedMar 8, 2005

It's also a good idea to learn more about the tools you're using, rather than taking the easiest path.  C++ is a more complex language than C, but it also makes life simpler once you learn enough to work with it instead of against it.

In the smash_tilde example, the same function is overloaded by argument type, so that you don't need two different names for something that does the same thing, but takes const or non-const strings.  That's a plus, since it makes your code easier to read.  It's not legal in C, however, hence the conflicting function prototype errors.

I resisted C++ for many years, and have paid the price in having to struggle with modern development tools (Visual Studio) which have evolved and moved on beyond C.  I also resisted graphical desktops for years before that, and still feel clumsy with GUI editors compared to good old vi.  Had I the ability to redo the past, I would have been less stubborn and stopped using stone knives and bear skins in the 1990's. :)

In short, just enjoy learning.  The alternative is to become a vegetable and watch TV all day, and considering the quality of TV shows these days, I wouldn't wish that on my worst enemy!
.........................
http://i302.photobucket.com/albums/nn96/quixadhal/EVEBanner.png
       
Post is unread #12 Jun 25, 2009, 7:25 am
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts830
JoinedJan 29, 2007
WWW

If you go to gcc, it's worth noting that you're likely to get a lot less support, because a lot of people (as you can see) view it as somewhat akin to shooting oneself in the foot and then complaining about difficulty walking. :wink: More seriously, people tend to support what's there, not some weird thing hacked together by somebody who didn't happen to like g++.

The codebase doesn't use C++ features -- for now -- and going forward you will only make your life difficult if you refuse to use any. In fact, you basically won't be able to follow development for anything that throws in an inkling of C++ without rewriting it yourself in C. There will eventually be C++ stuff in the codebase, even if it shows up slowly. .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Post is unread #13 Jun 25, 2009, 11:19 am
Go to the bottom of the page Go to the top of the page
Tonitrus
Fledgling
GroupMembers
Posts47
JoinedJun 24, 2009

That's two comments now related to support and my code being similar to stock fuss.

Do people typically maintain code similar to the fuss tree?

I've been messing with this code for about a week, and I've already made it so that I'd have to hand edit snippets in order to include them.  And, honestly, even adding snippets has always been a chore for me, since I always have to fix the snippet to work with my code.

I can't help but wonder what the point is in maintaining a similar codebase.  Support, obviously, but maintaining a similar codebase implies a loss of control on what you can code, and doesn't that take away the point of programming?

Anyway, the only reason I grabbed 1.9 instead of re-using 1.8 is that 1.8 wouldn't compile at the time and I was lazy.  I'm not looking much for further development, especially if that means C++ features.  The only other thing I know of that I'd like to have out of the box is the overland code, which I probably won't be adding this time around as it's a bit disagreeable.

(I may or may not have created a bug the last time I put it in that let people be in multiple rooms at a time.  If that sounds hilarious, it is.  If it sounds cool, it (sadly) isn't.)
       
Post is unread #14 Jun 25, 2009, 11:37 am
Go to the bottom of the page Go to the top of the page


Kayle
Nibelungen
GroupAdministrators
Posts885
JoinedMar 21, 2006
WWW

Tonitrus said:
Do people typically maintain code similar to the fuss tree?


Yes, because we fix things as we find them.

Tonitrus said:
I've been messing with this code for about a week, and I've already made it so that I'd have to hand edit snippets in order to include them.  And, honestly, even adding snippets has always been a chore for me, since I always have to fix the snippet to work with my code.

Always has been this way, and always will be.

Tonitrus said:
I can't help but wonder what the point is in maintaining a similar codebase.  Support, obviously, but maintaining a similar codebase implies a loss of control on what you can code, and doesn't that take away the point of programming?

Maintaining similarities allows you to easily apply any bugfixes that are found in the core of what your code originated as. My code hasn't look identical to SmaugFUSS in forever, but it has remained similar enough that anytime a bug is found, I can easily adapt that fix to fit in my code and do the same thing it does in SmaugFUSS.

Tonitrus said:
Anyway, the only reason I grabbed 1.9 instead of re-using 1.8 is that 1.8 wouldn't compile at the time and I was lazy.
 
It wouldn't compile because GNU is cracking down on poor programming techniques and trying to make everyone learn to do things properly. Which I commend, and at the same time hate because it causes a hell of a lot of work in keeping this base running.

Tonitrus said:
I'm not looking much for further development, especially if that means C++ features.

I'm sorry, I'm going to have to laugh again. Why are you so afraid of C++ and the features it adds to C? I mean this in all seriousness. I would really like to know why people have such an aversion to the updated version of the language they're so intent on using. Are you just afraid of change? Afraid you're going to like what you find?

I mean, yes, the STL can look daunting, but once you get the hang of it, life becomes easy as hell. Let's take a look at one of my favorite members of the STL. Firstly, in Smaug with flags, you're limited to either 32 via a bitvector, or 128 with an extended bitvector. I dunno about you, but I don't like being limited to specific values. Now, in SmaugFUSS because we compile in g++ (thus making everything about SmaugFUSS technically C++ even if we're not employing the STL or any of the advanced features of the language) you gain access to std::bitset. Which in regards to a MUD environment, seriously has no limit. You could have a set of 13,568 flags if you wanted to. Not to mention strings in C++ are a helluva lot easier to work with if you update to std::string.

I used to be wary of C++ too. And then I actually grew a pair and plunged in. I've never looked back since. Besides, if you can write C code. You can write C++ code. Mainly because they're the same damn language. The difference between them is that C++ opens up new avenues like object oriented programming, and gives you the STL to make your life easier.

So.. I pose to you a serious question. The year (last I checked) is 2009. Why are you hiding in the 90's? .........................
Owner/Coder                                                                    Coder
Malevolent Whispers                                                        Star Wars: The Sith Wars
{Development Phase - Not accepting players}                {Open Alpha - Players welcome, but with frequent changes to core systems.}
IMC2 Contact: Kayle@MW                                                IMC2 Contact: Kayle@SWTSW
       
Post is unread #15 Jun 25, 2009, 11:51 am
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts830
JoinedJan 29, 2007
WWW

Well, if you have no desire to add future features and want to fork your own tree off, you can do whatever floats your boat with nary a care as to what happens in the stock tree.

There are many different kinds of people who use FUSS. Some use it as a springboard and do their own thing from then on without looking back -- you appear to be in this category. Other people aren't so interested in making huge changes, although of course they'll make small changes and of course they'll have to merge those by hand one way or the other.

So I guess I'm not sure what exactly you're asking. If you intend to do your own thing and not follow the stock development, then do whatever you feel like, knowing that you're less likely to be able to get quick help the more you diverge. If you want to stick with the FUSS base a bit more, and be able to more easily incorporate future fixes and features, you need to minimize very disruptive changes. .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Post is unread #16 Jun 25, 2009, 11:59 am   Last edited Jun 25, 2009, 1:29 pm by Tonitrus
Go to the bottom of the page Go to the top of the page
Tonitrus
Fledgling
GroupMembers
Posts47
JoinedJun 24, 2009

(Edit: I suppose I should have bothered to quote)

Kayle said:
So.. I pose to you a serious question. The year (last I checked) is 2009. Why are you hiding in the 90's?


If it's a serious question, I think it's ugly.  I don't think it's the same as C at all.  I've written code in it after a friend constantly bugged me to use it for about 6 months.  I don't like it, the syntax makes me twitchy.

I don't like function overloading, I consider it a poor man's polymorphism.  I don't like operator overloading, it allows things to do things other than what they appear to.  I like the flexibility of cout, cin, cerr, but I despise the stream syntax.
<<, >>, etc makes me angry.

I have no particular aversion to classes, but I despise "::" and most other doubling of characters.

I also don't like Java, nor do I particularly care for Ruby, Python, or any other high level language.  I do, however, like Object-Orienting Programming (except inheritence, which I dislike), but that can be done in C as well.

I've tried a number of times to like Objective-C, but its syntax is really bizarre.

Anyway.  C++ may or may not make things easier, but it doesn't do what I want.

Windows is supposed to be easier than Linux, but it doesn't do what I want.

MS Word is supposedly easier to use than vim, but it doesn't do what I want.

So I use an updated (in '91) version of an editor that originated in 1976, on an operating system that's a clone ('84 (GNU),'91 (Linux)) of an operating system that originated in 1969, using a language that originated in 1972.

For reference, I was born in 1982.

Perhaps I'm mad, possessed, stupid, afflicted by a gypsy curse, or I swore on the grave of my dead brother that I'd never use anything invented after 1993.

Ultimately, what difference does it make?

C's pretty much just assembler in a pretty dress.

But I like the dress.
       
Post is unread #17 Jun 25, 2009, 12:11 pm
Go to the bottom of the page Go to the top of the page


Kayle
Nibelungen
GroupAdministrators
Posts885
JoinedMar 21, 2006
WWW

Well, you've sated my curiosity, and I find your reasons mostly absurd and pointless. But, to each his own. If people want to limit themselves I'm not going to force them not to. .........................
Owner/Coder                                                                    Coder
Malevolent Whispers                                                        Star Wars: The Sith Wars
{Development Phase - Not accepting players}                {Open Alpha - Players welcome, but with frequent changes to core systems.}
IMC2 Contact: Kayle@MW                                                IMC2 Contact: Kayle@SWTSW
       
Post is unread #18 Jun 25, 2009, 12:14 pm
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts830
JoinedJan 29, 2007
WWW

I don't really understand your position. You think that overloading is poor man's polymorphism (what would "rich man's polymorphism" be like?), but you don't like inheritance. You like flexibility, but you don't like operator overloading. (The flexibility of streams would be impossible, by the way, without various C++ features.) You also dislike high level languages, which is where flexibility comes from. It just seems a little self-contradictory to me.

I'm not trying to convince you to use C++ -- frankly I don't really care and it's your boat to float, of course :smile: -- but I do think that your preference is a little irrational, or if you think that that is a harsh term (it's not meant to be), it is a preference based purely on matters of opinion and not matters of fact. In other words, it's not a decision based on technical strengths and weaknesses.

Anyhow, hopefully your question has been answered in one way or another. If you don't want to leave a strictly C world, you won't be able to follow the codebase development. If that's not something you care about, then everybody can leave the table satisfied. :smile: .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Post is unread #19 Jun 25, 2009, 12:33 pm
Go to the bottom of the page Go to the top of the page
Tonitrus
Fledgling
GroupMembers
Posts47
JoinedJun 24, 2009

To clarify about function overloading, I don't like compile-time (or whatever the term is) polymorphism.

If I wanted polymorphism, I'd want it to be runtime.  I.e., calling methods that don't exist without compile errors or crashes,
unless that is what I want.

My position is not one related to the strengths or weaknesses of the language, (although I don't particularly consider
syntactic sugar to be a strength) but rather one of aesthetics.  I don't particularly expect other people to understand,
nor do I mind (or particularly care) what languages other people choose to use.

And to be honest, the way C is normally written bugs me, so feel free to assume that I'm just naturally pissy.
( Hint ): I am.

For example, I don't like the way that structures in smaug are declared in mud.h where everything can point to them.
If Risk has taught me anything, it's that too many points of entry are bad.  (Hi, Australia)

At the moment, I'm stripping out all these for loops through affects and replacing them with functions, as well as all references to affect->whatever and replacing those with functions as well, so that if something breaks, it'll break everything, which is a lot easier to find than one typo in one of the 70,000 for loops through affects in the rest of the code.

If that works, I'll probably do the same to every other structure, assuming I don't get bored first.

Then I'll derereference some null pointers and cause some stack corruption, loads of fun for everyone.
       
Post is unread #20 Jun 25, 2009, 12:36 pm
Go to the bottom of the page Go to the top of the page


David Haley
Sorcerer
GroupMembers
Posts830
JoinedJan 29, 2007
WWW

Quote:
My position is not one related to the strengths or weaknesses of the language, (although I don't particularly consider syntactic sugar to be a strength)

But you like C as just a dress over assembly, so surely not all syntactic sugar is bad. :wink: .........................
David Haley
Head Coder, Legends of the Darkstone
BabbleMUD Project
http://david.the-haleys.org
       
Pages:<< prev 1, 2 next >>