Join 300,512 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,936 people online right now. Registration is fast and FREE... Join Now!
Alright so I finally worked up the nerve to start writing a private server with a couple of friends after a year and a half of tinkering with the idea. We know theoretically how the servers interact with each other and we know about the packet sniffing we will have to do. We are going to need to write server administration tools and other misc. tools. but those can be written in anything. We are deciding between C, C++, or Java for the server itself. Here are the pros/cons of each that we came up with:
C: server will be fast as shit and we have maximum control over it; C is reasonably simple and we would not have to spend as much time delving further into it (I already know the fundamentals). Problem is it may be unstable when the server reaches full size and it will require a lot more code than most other languages
C++: server will be fast and more structurally sound (OOP) and offer maximum control. Problem is that none of us know C++ and while i know the fundamentals and some more complex concepts, the learning curve for any other coders who join will be steeper.
Java: will be pretty easy to maintain and quicker to write. Problem is that it's not as fast as we want and it may cause server issues when the garbage collector gets going (at least that's what I've heard)
Server isn't going to be massive, probably a maximum of 30 people on at once but that's just a guesstimate. Can anyone offer some input as to which language we should use for this?
This post has been edited by xCraftyx: 19 May, 2009 - 11:52 AM
Speaking as someone who used to work with C and C++ and got into Java for a week or two but doesn't really remember any of them...go with the one you like best.
No, really - if you prefer the way that C gets stuff done, and you're better with C, use C - you'll get more done by just pushing ahead with what you already know(and hopefully like) than by learning an entirely new language just to accomplish the task that you've set out to do.
Someone with more knowledge of the differences between C and C++ will probably correct me here, but I seem to recall when I was learning C++ that they're not that different - C++ was just C with a little bit more OOP thrown into the mix(and some handy standard libraries).
I would recommend that you do it in C, if you already know that - you'll be able to get up and running far more quickly. If something goes horribly wrong and you later find that you absolutely have to switch languages, you'll be able to use all of your existing code as a base to code off of for your next attempt - and the knowledge you'll have gained writing your first server will be invaluable when you're writing the second one(and third, and fourth..).
Yeah I noticed that C and C++ are a lot similar than most people claim they are. I'm probably going to head in that direction but I'm still open to feedback. Thanks
Yeah I noticed that C and C++ are a lot similar than most people claim they are.
You can write C code in a C++ environment. However, if you're doing in right, the C++ can be so vastly different that anything comparable in C would be a convoluted nightmare. Thinking OO is just a different process. If you're a C programmer with little C++ experience, chances are you'll end up just writing C with maybe a few basic libraries and syntax quirks; at which point, why bother?
Don't sell Java short and don't get hung up on garbage collection. Java excels in the middle tier. The real challenge of any project is organization. In any project of significant size, it's not the platform that's going to be the bottleneck but the program itself. If you can write good clean code in Java, it's better than something in C where you end up spending so much time in memory management that you loose track of what the hell you're doing.
Unless you're looking for a learning experience, use the language you feel the most comfortable with. They should all work.
This project IS a learning experience, but not necessarily for the sake of learning the language. To be honest I'm actually most comfortable with Java (i feel i can actually say I'm competent in this language vs. C or C++) but I don't know how it will perform when dealing with a lower level of abstraction (packets, encryption, etc.) since it's contained inside of the JVM. . Plus I don't want my server to be easily reverse engineered. Am i misguided in basing my choice off of those factors? Also, I don't think it matters but the game that we are writing the server for is written in C/C++; would that mean writing the server in C++ or C would make interaction between the client and the server easier?
Found a Java bytecode obfuscator so nevermind about the reverse engineering
This post has been edited by xCraftyx: 20 May, 2009 - 03:13 PM
For a client server model, it doesn't matter if the paired components are written in the same language. They usually aren't. You're just passing packets. It's like saying does it matter if one program produces a text file and another reads it.
Speed under this model is governed more by network latency than anything else. Your server must be able to handle the load, of course. However, a fraction of second on the server side isn't going to be noticed versus variable network traffic speeds.
Depending on what you're trying to do, UDP will be more useful than TCP under heavy loads. TCP requires a complete handshake and recovers relatively slowing when one side of the conversation drops. UDP doesn't wait, but also doesn't guarantee anything. Most MMOs use UDP for actual game play. Sometimes they start with TCP and learn their lesson.
Crap looks like I still have a lot to learn before I start this. Would Java be able to handle so much network communication efficiently?
Sure. The limitation is not the language. It will be your server, both memory and cpu. Also, if it comes to it, your network card. The big MMOs use server farms. The database server is the "world server" and the many load balanced servers form the middle tier that the user talks to. If one box gets over burdened, the client is transparently redirected to another resource. That central data store provides world continuity.
Because of the way the game is set up I don't think i need to provide a world, just a database for character info and monster drop rates so that ought to lighten the load on the server. Plus my server isn't going to be that big so i don't think i'll have to resort to that. Thanks though I'll bookmark those
This post has been edited by xCraftyx: 20 May, 2009 - 06:18 PM