0 Members and 6 Guests are viewing this topic.
I don't want some careless scripter crashing my PC and messing with anything else I got running.
All I can say is... this is pathetic.LORD KILLA, please, make your own game in C++ first. I know you haven't done it. I also know that you have no programming experience and that you don't probably know what a debugger is.In short; someone lock this topic for good.Quote from: CuM DuMsTeR on December 30, 2009, 10:14:00 am2) structs != classes. A struct is slightly similar to a class, except it has no methods (functions) and all members (variables) are public. Other than that, they are not interchangeable and the only reason c++ has them is to support older C libraries that people might want.Otherwise good, but the only difference between struct and class is the fact that all the members of a struct are public by default. For class they are private by default. Keeps the backwards compatibility that way. So you could replace all the classes with structs if you wanted to, as long as you keep the access levels compatible. Same vice versa.
2) structs != classes. A struct is slightly similar to a class, except it has no methods (functions) and all members (variables) are public. Other than that, they are not interchangeable and the only reason c++ has them is to support older C libraries that people might want.
(Forget to deallocate some dynamic memory in C and you could crash your OS - I know I have ).
The problem is NOT the programming language. It's the PROGRAM. If your houre collapses, you blame the builder and the architecture, not the tools used.
This is rubbish - I can't be bothered to give a proper argument, but if the tools had no effect on the programmer, we'd all still be f**king around with punched cards and binary or assembly.
It would be neat if the server was extensible by dynamic libraries, but there would be absolutely no point forcing people to use C++.
Voted yes, but not c++ please. Java is awesome. .
Quote from: Neosano on January 10, 2010, 06:14:54 amVoted yes, but not c++ please. Java is awesome. .Yes, but not Java please. Google's programming language - Go is awesome. :p
Quote from: Clawbug on January 10, 2010, 06:58:37 amQuote from: Neosano on January 10, 2010, 06:14:54 amVoted yes, but not c++ please. Java is awesome. .Yes, but not Java please. Google's programming language - Go is awesome. :pAre you kidding?? What is this s**t? WHY?? Java is stable and ok.
Quote from: ramirez on January 03, 2010, 05:35:06 amIt would be neat if the server was extensible by dynamic libraries, but there would be absolutely no point forcing people to use C++. And is there any point forcing me to use pascal? That's just a pain in my balls. Thank you for clearing that I deserve it. You're a real sadist.
The topic is about C++, which is fairly safe as long as the PROGRAMMER knows what he/she is doing. E.g. stay away from pointers and use smart pointers when really needed(shouldn't even happen really), use constructors only to initalize variables, don't use exceptions etc.
Where did you get the "don't use exceptions"? The only way constructor can really tell that something went wrong, is to throw an exception (and this is the preferred way to do things in C++). Maybe you're thinking destructors; destructors should never throw exceptions, but there's absolutely nothing wrong with a constructor throwing an exception.
void this(){ MyObject* SomeObj = new MyObject(); that(); delete SomeObj; }
void this(){ MyObject* SomeObj = new MyObject(); if (that() == -1) return; // oops! forgot to delete something? delete SomeObj; }
void this(){ MyObject* SomeObj = new MyObject(); try { that(); } catch (...) { delete SomeObj; throw; // re-throw } delete SomeObj; }
void this(){ std::auto_ptr<MyObject> SomeObj = new MyObject(); that();}
That isn't the fault exceptions, that is just faulty design. Exceptions make error management much cleaner and simpler, and you should use them. I could just as well as make an argument that "what if the programmer forgets to delete the object?" (eg. remove that last line from the function). Because that's what really is happening there; the programmer is forgetting to delete the object in one of the return paths. On one hand it can show that the programmer is inexperienced, but on the other hand even good programmers can make mistakes like this, that's why it's good to code in a way that you don't have to pay attention to stuff like that (more on that later).Even without exceptions, you could easily write the code incorrectly like this:Code: [Select]void this(){ MyObject* SomeObj = new MyObject(); if (that() == -1) return; // oops! forgot to delete something? delete SomeObj; }Basically that is the very same thing, the fault is completely the programmer's. In a situation like that, the proper way to do deal with the situation is catching the exception and re-throwing it:Code: [Select]void this(){ MyObject* SomeObj = new MyObject(); try { that(); } catch (...) { delete SomeObj; throw; // re-throw } delete SomeObj; }However since this kind of design becomes quite ugly and messy fast if you have multiple exit paths, it's recommended that you use a pointer object that deals with freeing the memory when the pointer goes out of scope (since when an exception is thrown, the stack is unwound normally, so the pointer object's destructor still gets called). You don't always need a smart pointer for this, something like auto_ptr that is included in the current standard library is often sufficient:Code: [Select]void this(){ std::auto_ptr<MyObject> SomeObj = new MyObject(); that();}If that() throws, auto_ptr will free SomeObj at that time. Please note that auto_ptr is *not* smart pointer though, it does not reference count (it can transfer ownership though, but that's irrelevant in this situation). Its purpose it to simply ensure that a pointer is deallocated upon exiting a scope. That being said, even if you don't use exceptions if your function has many exit paths it's generally a good idea to use auto_ptr (or some smart pointer), because you can just as easily make the mistake of not freeing some object without exceptions.Anyway, exception handling is something that any good programmer should use. It makes the application design that much better. You can easily catch fatal errors in one place and give a nice error to user, and you can properly clean up the program instead of having to ugly stuff like exit(); on fatal errors. And no need to check if function return error codes (ugh!), you can just trust that if a function returns something, it's what it's supposed to return. When people don't use exceptions, most people just completely ignore error checking and reporting because it's just plain gruesome and major pain in the ass to do. Exceptions let you code in a way that you don't have to be concerned about whether every second function returns a valid value, or an error code, while still properly dealing with exceptional cases when they do occur.EDIT. And going back to constructors, since they can't return anything, the only other way than using exceptions would be to have a like an additional member object that marks the object as valid or invalid, and then each method of the class would need to check that value before using it. Not only is that more inefficient, but it's pretty tiresome to write code like that. Basically read this: http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.2
What the hell? Ever heard of garbage collection? No need to blow your ass doing this s**t. Cmon It's 2010, do you know when C came out?