Sign in to follow this  
canned

Client / Server Languages

Recommended Posts

I'm curios as to what languages people are using for their client / server systems. I assume most clients (game-wise anyway) are written in C++. But with that in mind, do most people program a server for a C++ client in C++? Or is Java at all popular? Obviously sticking with C++ for both the client and the server provides the benefit of code reuse. But is it easier to get a distributed server built out of Java? Or are there other benefits to Java? Or do people just stick with C++? Thanks for the input!

Share this post


Link to post
Share on other sites
Our server and client are both written in C.
While there are MMORPGs written in Java (at least for the client) you can do much more, graphic wise, in C/C++.

Share this post


Link to post
Share on other sites
Most people who don't know how to write java to the same level they know C will tell you that C and C++ can do "lots of things" that java cannot. In general, that's mere ignorance (and people who haven't learnt to keep their mouths shut when they don't know what they're talking about).

In general (again, must stress that), since java has direct access to native memory (including to the graphics card over the AGP bus) you can do anything in java that you can do in C++. This is no surprise if you think about it: java is just like C++ in that it compiles down to native assembler, although there are advantages to each in the particular implementations.

On the server side, the fact that java is 100% cross-platform makes life much easier: you can develop on anything, windows, unix, etc and then deploy on anything (including deploying on systems you don't have in the office, e.g. Solaris).

Further, java has in-built optimizations which are not possible in a C++ compiler that make any application run faster after the first few minutes, speeding up continuously for up to several days...which really helps when writing server code (servers should be online for months without rebooting.

Similarly, the extensive hot-swapping of live code in java makes it easy to keep that server running (don't restart the process) and patch in updates.

On the flipside, the market for java client engines (graphics, physics, etc) is woefully immature compared to C++. Many people write the server in java and the client in C++ - it's easier - although you do lose out that C++ is much more bug-prone and takes longer to write code to do the same task.

Share this post


Link to post
Share on other sites
Quote:
Original post by redmilamber
On the server side, the fact that java is 100% cross-platform makes life much easier: you can develop on anything, windows, unix, etc and then deploy on anything (including deploying on systems you don't have in the office, e.g. Solaris).



Hmm. Just realised, you probably don't know why this is so important: there is no standardization in the I/O libraries used in networking code across OS's. Java has a single unified library that is guaranteed to work on all platforms, whereas C does not. Unfrotunately, since java's lib is relatively young (released about 4 years ago, gold for the last 3 years), it still has bugs - although you get similar problems when coding in C with OS I/O libs (windows, linux and OS X all have infrequently encountered yet annoying OS bugs in this area that continue to cause me grief :( ).

Share this post


Link to post
Share on other sites
Quote:
Original post by redmilamber
Most people who don't know how to write java to the same level they know C will tell you that C and C++ can do "lots of things" that java cannot. In general, that's mere ignorance (and people who haven't learnt to keep their mouths shut when they don't know what they're talking about).

In general (again, must stress that), since java has direct access to native memory (including to the graphics card over the AGP bus) you can do anything in java that you can do in C++. This is no surprise if you think about it: java is just like C++ in that it compiles down to native assembler, although there are advantages to each in the particular implementations.

On the server side, the fact that java is 100% cross-platform makes life much easier: you can develop on anything, windows, unix, etc and then deploy on anything (including deploying on systems you don't have in the office, e.g. Solaris).

Further, java has in-built optimizations which are not possible in a C++ compiler that make any application run faster after the first few minutes, speeding up continuously for up to several days...which really helps when writing server code (servers should be online for months without rebooting.

Similarly, the extensive hot-swapping of live code in java makes it easy to keep that server running (don't restart the process) and patch in updates.

On the flipside, the market for java client engines (graphics, physics, etc) is woefully immature compared to C++. Many people write the server in java and the client in C++ - it's easier - although you do lose out that C++ is much more bug-prone and takes longer to write code to do the same task.



1. Java cannot acess hardware exept through its api.
2. Java is jit compiled, and 'native asm' is ~= BS.
3. Since when could you hot swap java code?
4. C++ isn't bug-prone, the coder is. (tho you do make a somewhat decent point there, C# is better at this)

From,
Nice coder

Share this post


Link to post
Share on other sites
Quote:
Original post by redmilamber
Most people who don't know how to write java to the same level they know C will tell you that C and C++ can do "lots of things" that java cannot. In general, that's mere ignorance (and people who haven't learnt to keep their mouths shut when they don't know what they're talking about).

In general (again, must stress that), since java has direct access to native memory (including to the graphics card over the AGP bus) you can do anything in java that you can do in C++. This is no surprise if you think about it: java is just like C++ in that it compiles down to native assembler, although there are advantages to each in the particular implementations.

On the server side, the fact that java is 100% cross-platform makes life much easier: you can develop on anything, windows, unix, etc and then deploy on anything (including deploying on systems you don't have in the office, e.g. Solaris).

Further, java has in-built optimizations which are not possible in a C++ compiler that make any application run faster after the first few minutes, speeding up continuously for up to several days...which really helps when writing server code (servers should be online for months without rebooting.

Similarly, the extensive hot-swapping of live code in java makes it easy to keep that server running (don't restart the process) and patch in updates.

On the flipside, the market for java client engines (graphics, physics, etc) is woefully immature compared to C++. Many people write the server in java and the client in C++ - it's easier - although you do lose out that C++ is much more bug-prone and takes longer to write code to do the same task.




Hmm, Java sounds like the best language EVER!
It is as fast if not faster than C++ (which by some accounts it is faster than Assembly), it is cross platform unlike C++, and, of coruse, you just can't have bugs in Java.
I wonder why doesn't everyone use it for everything. I think people should uninvent all the other programming languages and just sue Java!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
FASTER THAN ASSEMBLY?!

Who reinvented the computer while I was in engineering college?

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
FASTER THAN ASSEMBLY?!

Who reinvented the computer while I was in engineering college?


It was sarcasm, of course.
But I ddi hear stuff such as:
"C is faster than assembly because the compiler does optimizations you don't know how to do"
"C++ is faster than C because [...]"
"Java can be faster than C++ because of the JIT optimizations"
So Java is faster than ASM :)

Share this post


Link to post
Share on other sites
I definitely didn't want this to turn into a war of the languages, though I should have seen it coming as anytime the two languages are mentioned in even the same city, sides are instantly formed and words are thrown like weapons.

So maybe a better way to approach this is in the form of a poll. Instead of asking what people think is best, how about, what have people done and to what success?

So the new question: In building a client / server game (MMO prefered, but any other form of client / server system works as well), if your client was written in C++, was your server also written in C++ or Java instead?

Thanks for the input!

Share this post


Link to post
Share on other sites
If you ask such a question, it's normal to get a holly language flame war :D
Many people will claim that Java is good for servers, but I am curious how many here actually wrote a MMO server in Java.
Mine is built in C, and works very nicely.

Share this post


Link to post
Share on other sites
There is no language that's designed exclusively for client/server systems.

The popular contenders are C++, C, Java and C#. There are also some hobbyist projects using Visual Basic, but I'd recommend against it.

It really comes down to what you want to do on the client, where you want to port, and what you're most comfortable with. Making the server and client use the same language is usually a good idea, because you can get excellent code re-use and, thus, lower impact of protocol bugs.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Nice Coder
1. Java cannot acess hardware exept through its api.


It's called NIO, it's more than 4 years old, and you shouldn't declare other people wrong when you don't know what you're talking about :P. It makes you look foolish.

Quote:

2. Java is jit compiled, and 'native asm' is ~= BS.


JVM's stopped using what is known as JIT circa 8 years ago (although that term is sufficiently vague to be slightly meaningless these days). Nowadays they use feedback-directed optimization.

Quote:

3. Since when could you hot swap java code?


Since java 1.1, at least - i.e. almost 10 years now.

Look, I answered the poster's questions from a position of knowledge. If you want to add in your own knowledge, fine, but please don't sit there declaring your ignorance.

Quote:

4. C++ isn't bug-prone, the coder is. (tho you do make a somewhat decent point there, C# is better at this)


IMHO, Java and C# both seem to have about the same effect here - and it's very noticeable compared to C++ projects.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Raduprv
Hmm, Java sounds like the best language EVER!
It is as fast if not faster than C++ (which by some accounts it is faster than Assembly), it is cross platform unlike C++, and, of coruse, you just can't have bugs in Java.
I wonder why doesn't everyone use it for everything. I think people should uninvent all the other programming languages and just sue Java!


Thanks for the sarcasm and deliberate corruption of my statements. But the fact of the matter is that I've built large clusters from scratch and the above is taken from personal experience.

Right now, I'm overseeing the development of a cluster to handle peak load of 1 billion hits a day, using 2 incompatible DB systems, a Zeus load-balancer, and a proprietary fine-grained caching system to keep the thing ticking over at high-performance. We're using at least 4 different languages, but the main one is java because none of the others could cope AND because we couldn't use windows for the servers (which put .NET out the window, otherwise it would have been a strong contender).

I never said java was the perfect language, but it's trivially much much better for server development than C++ is. That doesn't mean it's always the best choice in a given situation, of course. But e.g. if you've ever built a server where you really care about getting it compromised (and in any production environment you really should care! Or do you like giving away CC details and having game accounts stolen?) you'll know what a difference java's security and protection systems make.

Share this post


Link to post
Share on other sites
You can design a car with a roll cage, 5-point harness belts, air bags and a crumple zone, but if you drive it 150mph into a brick wall, you're going to get hurt.

The point being, security at the language level only gets you so far. If you build a credit card processing server, what good is the language-level security if your code allows a hand-crafted URL to penetrate a hole in your code's logic and steal CC information? Java is just as susceptible to this form of attack as any other language.

As for the speed of Java compared to C++, I've never seen quantative data to support this. Yes, I've seen a few of those "unbiased" benchmark websites -- the code they're using to compare the two languages is laughable at best.

Robert Simpson
Programmer at Large

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
I never said java was the perfect language, but it's trivially much much better for server development than C++ is. That doesn't mean it's always the best choice in a given situation, of course. But e.g. if you've ever built a server where you really care about getting it compromised (and in any production environment you really should care! Or do you like giving away CC details and having game accounts stolen?) you'll know what a difference java's security and protection systems make.


It happens that I am the project leader and founder of an indie MMORPG that is relatively successful (as in, the record being of over 500 connections at the same time). It is written in C (not C++) and except for ONE mistake, which allowed items duplication, we didn't have any security hole. And that mistake was a programming mistake, didn't check for some values, and it could have been done in any other language, really.
As for the CC details, we are not using CCs directly, we'd rather do it via a 3rd party, as the majority of the people do it.
But anyway, I am interested in how exactly is Java more secure than C.

Share this post


Link to post
Share on other sites
To add fuel to the fire here, I use Java hot-swapping fairly frequently, maybe I can shed some light on that for you?

The way I use it(simply copying class files over top of older versions), as long as the client is not currently actively using that class, when they next go to use it(without recompiling the main class, without restarting the application) it will use the newer version, error free.

Additionally, although this could be completely due to experience in the languages, I've found Java much less bug prone. But then, 2 years of Java against 1 month of C++...

Share this post


Link to post
Share on other sites
Quote:
Original post by Revelations
To add fuel to the fire here, I use Java hot-swapping fairly frequently, maybe I can shed some light on that for you?

The way I use it(simply copying class files over top of older versions), as long as the client is not currently actively using that class, when they next go to use it(without recompiling the main class, without restarting the application) it will use the newer version, error free.


And you really don't think that doing that in a complex MMORPG server might have some undesired side effects?

Share this post


Link to post
Share on other sites
Quote:
Original post by Raduprv
And you really don't think that doing that in a complex MMORPG server might have some undesired side effects?


You sound like my wife :) He was merely explaining how he used hot-swapping. I didn't read anything where he said he was for or against any particular use of hotswapping outside of his own example.

Robert

Share this post


Link to post
Share on other sites
Since here are a lot of people using java for server, one question:
How do you use "stop" to stop the thread with the socket, or do you let it only run for a time and than if a flag is not set restart it?

I ask because "stop" is depreciated.

Share this post


Link to post
Share on other sites
Quote:
Original post by rmsimpson
You sound like my wife :) He was merely explaining how he used hot-swapping. I didn't read anything where he said he was for or against any particular use of hotswapping outside of his own example.

Robert


Sure, but this was in the context of MMO servers, and I just wanted to make it clear that this technology, in the MMO server context, will do more harm than good.

Share this post


Link to post
Share on other sites
Just for the record the OP (to my knowledge) did not actualy say an MMORPG, just a distributed client->server model...

Also, FOR THE RECORD, I have used hot-swapping aswell (2 years java.. 8 years C++ btw...) and you CAN use it for some classes on an active server. You must use carefull design decisions though, namely some sort of way to "pause" the clients in-game if its actively used, or use a factory class that can optionaly not create a class if an update is going on.

Share this post


Link to post
Share on other sites
Quote:
Original post by PaulCesar
Just for the record the OP (to my knowledge) did not actualy say an MMORPG, just a distributed client->server model...

He didn't explicitely say MMOs, but he implied it in his post.

[/quote]
Also, FOR THE RECORD, I have used hot-swapping aswell (2 years java.. 8 years C++ btw...) and you CAN use it for some classes on an active server. You must use carefull design decisions though, namely some sort of way to "pause" the clients in-game if its actively used, or use a factory class that can optionaly not create a class if an update is going on.[/quote]

Of course it CAN be used, but I am not sure it's a good idea. From my practical experience with two MMO servers, many things can go wrong even when you don't hot swap. And the problem is, in an MMO a mistake can propagate fast. For example, if you make a mistake that will increase the attack of some player too much, he or she can go and PK everyone.
If you make a mistake where the quantity of an item is changed by mistake, this can have huge implications in the whole economy. And so on.
Things like that happened to us even though we didn't use hot swapping. I don't even want to think about what would happen if we did :D
Besides, hot swapping can be done very well in C, it's just harder to implement.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
Quote:
Original post by Nice Coder
1. Java cannot acess hardware exept through its api.


It's called NIO, it's more than 4 years old, and you shouldn't declare other people wrong when you don't know what you're talking about :P. It makes you look foolish.

Quote:

2. Java is jit compiled, and 'native asm' is ~= BS.


JVM's stopped using what is known as JIT circa 8 years ago (although that term is sufficiently vague to be slightly meaningless these days). Nowadays they use feedback-directed optimization.

Quote:

3. Since when could you hot swap java code?


Since java 1.1, at least - i.e. almost 10 years now.

Look, I answered the poster's questions from a position of knowledge. If you want to add in your own knowledge, fine, but please don't sit there declaring your ignorance.

Quote:

4. C++ isn't bug-prone, the coder is. (tho you do make a somewhat decent point there, C# is better at this)


IMHO, Java and C# both seem to have about the same effect here - and it's very noticeable compared to C++ projects.


[lol] :-)

You mean This nio? (from sun)

Hmmm, so it has buffers, some functions for unicode conversion, and some functions which allow you to use the win32/other kernal api.
Nothing particularly special, nor does it disprove my point.

Java doesn't have anything near direct acess to native memory (no pointers. Case in point) nor can it acess the graphics card without an api. (which, you really shouldn't do unless you happen to be a vidio driver...)

2.
Quote:

JVM's stopped using what is known as JIT circa 8 years ago (although that term is sufficiently vague to be slightly meaningless these days). Nowadays they use feedback-directed optimization.


Hmm, so the magical faries from javaland go and turn jvm opticodes into maxhine code using the magical process of feedback directed optimisation.

Hmm, now doesn't that seem a little silly? it does to me.

Link of Feedback driven optimisation from harvard.

In theory, it could be a bit faster.
In reality, it won't be.
(and your abuse of terminology is idiotic. "Native asm"...)

Quote:

Quote:

3. Since when could you hot swap java code?


Since java 1.1, at least - i.e. almost 10 years now.

Look, I answered the poster's questions from a position of knowledge. If you want to add in your own knowledge, fine, but please don't sit there declaring your ignorance.


Seems berkley disagrees with you not that it can't be done, just that it takes a lot of redesigning, and compared to the effort of just restarting your game at midnight when noones playing....

Quote:

IMHO, Java and C# both seem to have about the same effect here - and it's very noticeable compared to C++ projects.

:-) finaly something we can agree on. Although i like lisp better then both C# and Java.

From,
Nice coder

Share this post


Link to post
Share on other sites
This really isn't the forum for language debates. Sorry for letting this thread go on for so long.

If you want to discuss specific performance or design of specific networking or multiplayer libraries/APIs, feel free to start new threads.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this