PHP/Rails/Django/ASP websites should have been written in C++? - c#

I was looking at a SO member's open source project. It was a web framework written in C++.
Now you are all probably ready to respond about how C++ is a horrible language to do websites in, and that in websites, the bottleneck is in the database.
But... I read this post:
http://art-blog.no-ip.info/cppcms/blog/post/42
and in there he makes the case that in a large site such as Wikipedia, the database servers only make up 10% of all servers. Therefore C++ would be better than languages like PHP Python Ruby C#.
Are his points valid?

The problem with the article you link to is that the author clearly doesn't really know what he's talking about when he asks where the "bottleneck" is; the fact that someone has more web servers than database servers doesn't mean "the database can't be where the problem is". What's generally meant by "the database is the bottleneck" is the same thing that's been learned by everyone who ever does run-time profiling of a web application.
Consider an application which takes half a second to return a full response. Suppose you sit down and profile it, and find that that half second of processing time breaks down as follows:
Parsing incoming request: 50ms
Querying database: 350ms
Rendering HTML for response: 50ms
Sending response back out: 50ms
If you saw a breakdown like that, where database queries constitute 70% of the actual running time of the application, you'd rightly conclude that the database is the bottleneck. And that's exactly what most people find when they do profile their applications (and, generally, the database so completely dominates the processing time that the choice of language for the rest of the processing doesn't make any difference anyone will notice).
The number of database servers involved turns out not to matter too much; the famous quote here is that people like the author of the post you've linked are the types who hear that it takes one woman nine months to have a baby, and assume that nine women working together could do it in one month. In database terms: if a given query takes 100ms to execute on a given DB, then adding more DB servers isn't going to make any one of them be able to execute that query any faster. The reason for adding more database servers is to be able to handle more concurrent requests and keep your DB from getting overloaded, not to make isolated requests go any faster.
And from there you go into the usual dance of scaling an application: caching to cut down on the total time spent retrieving data or rendering responses, load-balancing to increase the number of concurrent requests you can serve, sharding and more advanced database-design schemes to keep from bogging down under load, etc., etc.
But, you'll note, none of this has anything whatsoever to do with the programming language in use because, once again, the amount of time spent or saved by other factors grossly outweighs the amount of time gained or lost by a "fast" or a "slow" language (and, of course, there's really no such thing; so much depends on the problem domain and the skill of the programmer that you just can't have a meaningful general comparison).
Anyway, this is getting kind of long and rambling, so I'll just wrap it up with a general guideline: if you see someone arguing that "you should build in Language X because it runs faster", it's a dead giveaway that they don't really know anything about real-world performance or scaling. Because, after all, if it just came down to "write in the fastest language", they'd be recommending that we all use assembly :)

Servers are a one-time fixed cost of a few grand. Programmer time costs a lot more than that. Sure, writing websites in C++ would reduce hardware costs, but would greatly slow down development. So if you can shave one man-month of time off your development by using Ruby instead of C++, that pays for an extra server.
Better means a lot more than "faster".

There are so many more problems that you face when writing in compiled, statically typed languages like C++, and these can all affect development. Some of the primary reasons scripting languages like Ruby or PHP have been invented is so that us a programmers can get more efficiency out of the language and toolsets we work in.
Yes, websites would be faster if they were written in a language such as C++. Yes, they could serve more people, be more scalable and be more efficient. But is this good enough reason to lose out on all the benefits that interpreted languages give us? Programmer happiness, development time, ease of use, portability, and so many more I can't mention.
The right tool for the right job, and for C++, website development isn't one of them.

I would be reluctant to say that servers are a one time cost of a few grand since some cost hundreds of thousands and I would venture to say millions. A number of sources will suggest that the biggest cost to the IT industry is hardware, not manpower. But for a comparison of the languages we need to compare them, not hardware.
The idea behind languages like Ruby, Python, PHP, and Groovy is essentially Rapid Application Development (RAD). The frameworks, Ruby on Rails, Django, CakePHP, and Grails are there to better facilitate RAD. The languages are easy to use and enable developers to setup and develop with little cost and the timeline involved is reduced in comparison to other languages or setups.
Is it right or wrong? It's all personal opinion but in the end the needs of the project will define which tool set is best suited. If your application has low traffic and you want to have it developed and live in a few months then it would be ideal to use one of the previously mentioned languages and/or framework.
But what about C++, .Net, and J2EE? Theres a place for everything. These tend to have higher up front costs associated with the time and energy to architect the project, setup the development environment, and do the actual development. But the languages and frameworks built from them are better suited for scalability to accommodate heavy traffic or computations.
Look at Facebook as an example. The original site was prototyped and deployed as a PHP application and the user base was relatively small. As the site grew into the monster we know it as today they scaled their application by implementing J2EE on the back end while using the existing PHP scripting for the front end.
As someone with experience in J2EE development and Python/PHP there is a very apparent set of advantages and disadvantages. I can build a blog with PHP in a few days ready for public access but the same project in J2EE may take much longer.
Forgive my terminology but Enterprise languages (J2EE, .Net) require a significant amount of configuration and deployment efforts. Ruby, PHP, and Python do not, you simply open Notepad, write your code and save it with the correct extension and you're ready to upload.
Does that help?

Programmer happiness, development time, ease of use, portability, and so many more I can't mention
In fact... it is not so horrible and slow process to develop in C++, given right tools.
The Wiki that this project runs was written and up in few days (and yes, in C++)... Not bad for horrible C++ language ;-)
Take a look:
First Commit According to SVN Logs: 24/10/2008 http://cppcms.svn.sourceforge.net/viewvc/cppcms/wikipp/trunk/Makefile.am?view=log
First Pruduction page according to history: 30/10/2008 http://art-blog.no-ip.info/wikipp/en/changes/9
I think this is not a slow process for work at evenings to create such wiki: http://art-blog.no-ip.info/wikipp/en/page/main

No, his points aren't valid. It isn't that one is better than the other, but take C# and java for instance, they're just more advanced modern languages that have been designed with C++'s problems in mind.
It doesn't make any sense to bother with things like garbage collection if you don't have to. Also the various web framework languages have so many components, controls, modules, and many other pieces, open source or otherwise, already written for them by other developers, you would be reinventing wheels that exist in other languages, all over the place.
I'll always have a place in my heart for C++, but it's kind of idiotic or troll-worthy to suggest your better off writing websites in C++.
(EDIT: Maybe if C++ is the only language you know, or you have a lot of self-made components in C++ for the web, but your still probably better off learning a C++ descendent language for websites development, which are pretty easy to learn once you know C++/C)

His points are NOT valid for 99% of web applications. Web applications benefit from rapid iteration and friendly interfaces, both of which are better achieved with languages like PHP, Python and Ruby. If you are good or lucky enough to develop a highly used service, you will have little trouble engineering it to scale.

last I checked, php, Ruby, and Python are all written in C. Doesn't that count?

Related

Where/When do C# and the .NET Framework fail to be the right tool?

In my non-programming life, I always attempt to use the appropriate tool for the job, and I feel that I do the same in my programming life, but I find that I am choosing C# and .NET for almost everything. I'm finding it hard to come up with (realistic business) needs that cannot be met by .NET and C#.
Obviously embedded systems might require something less bloated than the .NET Micro Framework, but I'm really looking for line of business type situations where .NET is not the best tool.
I'm primarly a C# and .NET guy since its what I'm the most comfortable in, but I know a fair amount of C++, php, VB, PowerShell, batch files, and Java, as well as being versed in the web technologes (JavaScript, HTML, and CSS). But I'm open minded about it my skill set and I'm looking for cases where C# and .NET are not the right tool for the job.
I choose .NET and C# because I'm comfortable with it, but I'm looking for cases where it isn't appropriate.
C# and the .NET Framework might not be the best choice for a hard real-time application. Your application will hose on the first garbage collection, and real-time systems often have memory constraints that make the full-blown .NET framework unsuitable.
That said, there are ways around these problems, see here: http://www.windowsfordevices.com/c/a/Windows-For-Devices-Articles/Adding-Realtime-to-Windows-Embedded/
C# might not be a good choice for complex algorithms, especially those benefitting from parallelism, that would be better expressed using a functional language like F#.
See: https://stackoverflow.com/questions/141985/why-should-a-net-developer-learn-f
There isn't, really, all that much difference between the problem domains served by different programming languages. Rather, the choice usually comes down to
What languages do you/your team already know you can be productive in?
What is available in the libraries (built-in or available from elsewhere) for the language?
The answer to this question will therefore depend on you. For example, if I personally was doing a quick text processing task I'd whip it up in Perl, because I know Perl well and can do that sort of task efficiently: if you asked me to do it in C# I'd say that was the wrong tool for me, because I can do it quicker in Perl.
If you are looking to learn and diversify your programming toolbox -- which is a good idea -- then rather than asking where C# is the wrong tool, you need to ask which language is most appropriate for each task, and make an effort to learn that language better. Otherwise C# will always be the best tool for all jobs, for you.
you've asked an interesting question.
I'll rephrase it: Why Object Oriented? And why .NET? And when not?
I suppose the thing to keep in mind is why OO is so popular. In the modern world, much of the demand for programs is essentially for business. This is why object oriented paradigms are so popular; it is often the most straightforward way to turn a business problem into a program. You basically take a look at a business, break down what the interacting parts (people, machines, places, etc) are, and write something that mimics it in code. So OO is popular because it allows you to mimic many real world situations.
.NET I suspect is popular because it seems so comprehensive. You get loads of components with it, and all you're really doing is mimicking a business issue by writing some connective tissue between these components. Add to that the fact that there's a huge community of people using it already, and the network effect speaks in .NETs favour.
Finally, when would you NOT use .NET?
If your problem is not a business problem, ie isn't merely an issue of connecting some premade components, you might need something different. For instance, if you're writing a driver for a new piece of hardware, that driver is really a layer below the business layer, because
1) It needs to work regardless of what the composition of components is used for
2) The business layer doesn't really care how it works
There's plenty of programming problems where you wouldn't use an OO model, but I suspect OO is useful because it connects all the parts (which aren't OO, like databases and drivers) to create a whole.
I would not use C# for application that make heavy use of resources and need close acces to hardware, ie high profile computer games.
Real time applications (lets say some app that monitors the temperature in a nuclear plant, unless of course Homer simpson in runnig it) have been mentioned, but not games.
World class 3D intensive, IA Intensive games are best server by C++ (at leats the core of them), because you need to be close to the procedural paradigm and hardware, and you need to tell the computer what to do and how to do it, without anything in the middle (the CLR)
C# and .NET are not the right solution if you work in a heterogeneous environment with many platforms. For all practical purposes .NET is a Microsoft-only solution (yes, I know about Mono and I stand by my statement) that locks you in to one vendor and hardware architecture. If your workplace has Macs and Linux boxes and SPARC servers and PowerPC blade servers, etc. etc. etc. then C#/.NET is not going to do you a whole lot of good.
You also have the problem of vendor lock-in. Let's say you write a server application in C# and .NET. Now let's say ARM's recent foray into server-grade components pans out and ARM-equipped server kit hits the market like a thunderbolt. If you use C#/.NET for your app you're hosed until Microsoft ports their stuff over to the ARM-based architectures (if ever -- NT once supported many more architectures than it does now: the trend is toward shrinking the Windows ecosphere, not expanding it). By locking yourself in to one vendor-specific technology you've made yourself less able to survive market shifts.
They move the programming paradigm away from small interoperating tools to large monolithic applications, due to the fact that their load times, minimum worknig sets and interactions with the file system are much higher than those written in compiled-to-host languages.
That's not always a bad thing, but it does mean that the highly efficient (albeit high learning curve) command-line based programming models - a la UNIX - become less used, which is a shame in my opinion.
London Stock Exchange was originally written in .NET
http://blogs.computerworld.com/london_stock_exchange_suffers_net_crash
You can gain some insightful insights about why using .NET and any non-deterministic memory releasing apps(aka garbage collection) for that matter, does make things like real-time systems not amenable on .NET, see the following link. Humor is bonus
http://tech.slashdot.org/tech/08/09/08/185238.shtml
And they ditch .NET, and chooses MilleniumIT which uses C++
http://linux.slashdot.org/story/09/10/06/1742203/London-Stock-Exchange-Rejects-NET-For-Open-Source?from=rss
For anything like volume money transactions and life matter(embedded device for car engine), you cannot let just garbage collection kicks-in randomly and incessantly
[EDIT]
Why the downvote, are there any Microsoft shills here? I just talk in general terms in which the underlying paradigm .NET was architectured in (managed and garbage collected). Perhaps if I just say that the only instances where .NET are not to be used are in car engines and machines that are connected to humans (e.g. heart pacemaker, dialysis machine), I would not get downvoted
I've recently watched an InfoQ presentation where Neil Ford presents a Thoughtworks project that chose Ruby on Rails over .NET because of the alleged better flexibility of Rails and Ruby. Take a look there at their take on the subject.

Planning a programming project by example (C# or C++)

I am in the last year of undergraduate degree and i am stumped by the lack of example in c++ and c# large project in my university. All the mini project and assignment are based on text based database, which is so inefficient, and console display and command, which is frustrating.
I want to develop a complete prototype of corporate software which deals in Inventory, Sales, Marketing, etc. Everything you would usually find in SAP. I am grateful if any of you could direct me to a books or article or sample program.
Some of the question are :
How to plan for this kind of programming? should i use the concept of 1 object(such as inventory) have its own process and program and have an integrator sit for all the program, or should i integrate it in 1 big program?
How to build and address a database? i have little bit knowledge in database and i know SQL but i never address database in a program before. Database are table, and how do you suppose to represent a table in a OOP way?
For development type, which is better PHP and C++ or C# and ASP.NET? I am planning to use Web Interface to set form and information, but using a background program to handle the compute. .NET is very much integrated and coding should be much faster, but i really wonder about performance if compared to PHP and C++ package
thank you for the info
This may not answer your question directly, but I thought this might help you get started in some way. So here it goes: I would say, "think through the process". This means, think through the software development process:
Gather requirements
Identify and define the problem.
Get as much information/facts as you can. (turn on green light, think about everything that you want to go into your software)
Come up with a baseline (turn on red lights, what you really want? the minimum functionality your software "must have" - cant live without)
Analyze
Know what you don’t know, what are the missing facts?
Evaluate your information or lack of it/reliability of information source.
Infer facts that you don’t know.
Form an assumption, opinion, or possible solutions.
Consider alternatives and implications of each solution.
Form an action plan.
Identify technology pros/cons.
Decide technology
Comeup with a functional specs.
Research
Dig into stuff that you would want to know (Best database, ORM, design practices, code samples - gather everything, read about inventory systems that are already there)
Design
Develop
Test
Fix
Prepare deployment plan
Release the product
Gather user feedback
Analyze user feedback
Plan for items in next release.
Repeat steps
And Enjoy!
Before I start this is a shallow answer to a deep question.
1) It looks like you have a reasonable grasp of the major components of your target application. As a .net developer I'd build assemblies that matched broad areas of functionality (not sure what the equivalent is in PHP) and then you can use those assemblies together as a single large app, or seperately as required. It's unlikely you'll get it right first time, so build it how it feels right, and then do some ruthless refactoring to make it better once you've got a handled on the problem.
2) This whole area is covered by Object Relational Mapping - ORM, NHibernate is the best of the bunch in the .Net world. BTW if you learn that you'll be way ahead of the game come graduation/work time. Raw sql is so last decade. I guess you know that Sql Server Express is a free download?
3) For development go with the languages/environment you feel most comfortable in. My preference is .net, and the integrated coding is much faster. Performance is definitely good enough, especially as this is learning project - SO runs on .Net and that supports a gazillion users pretty well.
Enjoy
I don't have any good recommendations for SAP-like projects in particular, but in general the best examples to use for things like this are well-established open-source projects. Anything else is going to be a "toy" example in one way or the other, and will be simplified and cleaned up. It's the "cleaned up" that makes it most unrealistic -- one of the really key things that makes real-world large software projects different from university examples is that the real world is messy, and real-world requirements are messy, and collaboration between lots of people with not quite the same priorities is messy, and real-world software projects have to adapt to and thrive in this messiness.
In answer to your specific questions, though:
1.) Do things in a modular way. This means you have something you can test and work with as soon as you get the first module done. That's especially important when you're learning, because (a) you probably won't have time to actually finish the whole thing, (b) you'll learn a lot from writing the first bit that you'll want to apply in future bits and then you'll probably want to rewrite the first bit, and (c) you'll learn even more from using the first bit.
2.) There are many views on this, and many online articles and books. I can't answer that in an answer here (except to note that in some cases trying to represent it in an OOP way is the wrong programming paradigm -- be careful about overconstraining the answer by the question you ask!); the right answer is to find things to read and spend some days reading them.
3.) You do not care about that sort of performance issue here. Successful programs have been written in both forms. You care about what will teach you the most, and what you are comfortable working with. Either one should be fine. You'll probably find more open-source pieces to look at with PHP and C++.
Your question pretty much covers the whole gamut of planning for a project; a whole thesis might be written (+:
Keep in mind what your team and your teaching-staff want out of the project.
1) Modular is my choice. It'll force you to address the application one module at a time and keep you focussed, but that is subject to
The familiarity of your team with the preferred/recommended language for this project.
Time in hand
Remember that modular means you will necessarily have to provide for module integration too.
2) C++ or C# ? Whichever offers the more learning experience. My own experience with both mentioned technologies is limited, but I remember there used to be a Database Template Library (DTL). C# on the other hand will probably be faster to develop. I could be wrong. There are any number of free DBMS engines available on the net. Unless the assignment explicitly recommends using a text, opt for one of these.
3) I concur w/Brooks up there ^^^
Good Luck!
You are a university undergraduate. And you are talking about complete inventory system.
I suggest building a blog application first with all the best practices (like blogengine), then move to e-commerece sites (nopcommerce, dotcommerce). And then do whatever you like.
This is a common problem with undergrads like you, of jumping way higher without building any simple projects first.
As a full time PHP developer, PHP sucks! ASP.net is okay (mmm... no it sucks too), but it locks you into proprietary licenses.
If you're starting from scratch, go for node.js. It's c++ and server-side javascript. Yes, it's new, but it has engineering promise. It'll be more commonplace in a few years.
And if you're worried about performance, don't. Javascript in V8 is extremely fast.
http://shootout.alioth.debian.org/u32/which-programming-languages-are-fastest.php
Here are some node.js links to get you started:
http://www.delicious.com/homer6/nodejs
Enjoy.

Ideas for computer science project with CORBA or ICE

We have to perform a semester project with distributed computing using CORBA or ICE. It is a single-person project and we have a couple of months of time.
For the programming language I'd like to focus on c# for it may be any other like C++.
I don't want to write the one millionth prime generator, maybe there is something much more interesting which I didn't think of yet..
Not sure if the focus of the project is on the distributed processing portion or the actual task you decide upon.
CORBA is more prevalent than ICE in the real world, though hardly something you would want to hang a career around. It's still used in various embedded projects and it is still fairly popular in certain military applications.
ICE is easier to work with but doesn't have nearly the industry penetration (to my knowledge) of CORBA. But if your goal is to complete a project and learn distributed principles then I would go with it. It will be much less painful to learn and work with than CORBA. In fact ICE was developed by former CORBA engineers who wanted to correct some of the mistakes they saw in CORBA.
I've found that fault tolerance makes distributed computing projects a little more interesting. The task itself can be relatively simple, but ensuring that it can handle unavailable systems or faulty data adds a nice additional requirement.
If I were you, ....what I would do is go to your prof and ask to work outside the lines. Ask to be released from the CORBA or ICE requirement.
Ask if you can use something that is NOT Corba. Ask if you can use REST, or XML Web services, or even protobufs.
CORBA is not irrelevant, as far as the principles go, but it is nearly irrelevant in commercial appeal. Do something that will teach you some more current skills.
To me, it would be like studying vacuum tubes. Interesting academically and scientifically, but...
Rather than a prime number generator, why not get a little more interesting?
a distributed hash table, something like the new BitTorrent design.
a work distribution system for a compute farm. How would you build a distributed map/reduce across that farm? you could do encryption, compression, video ripping. Build a general purpose distributed work management system that would be appropriate for any of those jobs, with a modular architecture. How would you detect failures (host offline or non-responsive)? How would you deal with rescusitated hosts?
a SETI-#Home type of network. or protein folding. or climate trend analysis (using Public Domain databases - http://en.wikipedia.org/wiki/Public_Domain_Resource ) Something where you're doing something more practical than computing prime numbers.
OR - actually do the prime number problem, but apply it to cryptography, breaking keys.
a network of agents, where you actually distribute code to the nodes to execute. Something like JavaSpaces.
a poker bot.
just some ideas.
If your project is asking you use CORBA or ICE. I would say try both and see which one you make progress on first, then go with that one. They both seem to have C# interfaces (from google searches).
Otherwise you could look into using .Net Remoting. It wasn't too tough to get the rudiments working for me the one time I was asked to do it... ~2 years ago now.

Choosing a Platform C#/MsSql or Php/Mysql or JSP or what?

It seems like there are an inordinate number of really intelligent people here, so I thought it was the best place to ask a couple involved questions (shameless flattery). Your feedback on any item would be so appreciated.
I am about to develop a very large web based operations, inventory, sales management system. I had intended on C#/MsSql/Reporting, but am now leaning towards Php/MySql.
Multiple facility support. I
would love to have it all run from a
single place, but I need for each
facility to be able to run
autonomously from each other in case
of internet connectivity loss.
Servers could reside in each
facility and replicate to a central
one. MS Replication will hang the
DB for large databases. MS
recommendation to restructure the
database into smaller
segments…thanks. MySql seems to
have very solid replicability
features. Thoughts on this issue?
Distribution: Eventually this could be marketable
to other companies in the industry.
Using the method above I would have
to distribute the system to my
server in the customer’s facility.
With C# I can distribute compiled
code. With PHP any intellectual
property is vulnerable.
Reporting. Will I be able to print labels and
really specifically configured
reports with PHP? Pdf export is a must. MsSql has the
reporting service, but it has issues
with PDF font embedment, the
flexibility is very time consuming
and I am thinking that building it
all by hand might be faster. MS
print control also seems problematic.
Cost. Load would probably not ever exceed 100
simultaneous hits. Full Ms server
licensing is cost prohibitive.
Would sql express support this load?
MySql cost structure is very
appealing.
Thanks in advance for your insight. Sorry for the book.
As with most software, the biggest cost factor is almost certain to be developer time.
That in mind, you should go with whatever your team can get up and running in the fastest. Both of the stacks you are suggesting can get the job done.
(although I'm sure someone will be along in a minute to slate PHP and suggest you use C#/the MS Stack)
To answer the other points from a PHP perspective, which is what I know best:
Replication in mysql will do what you want, but make sure you set up something to let you know if there are problems.
You can use Zend_Guard to compile PHP, it costs though. PHP 5.3 is due for release soon and includes Phar archives - a shameless copy of java's jar archives so that you can distribute an app as a single file.
PHP can do PDF via fPDF. Never used the MS options, so not sure how it compares here.
I think sql server express could do that load, and mysql could too.
Adding point 2 with point 4 if you're intending to sell, you should think that, although in your company it won't exceed 100 simultaneous hits, in the companies your going to sell to it can exceed 10000 hits. So you should think about scalability now
As it is an application with massive size for what you say, you should expect in the future to have someone wanting to communicate with it, excluding php, for jsp or c# so you can make web services if needed.
PHP won't also allow so much distribution as C# or JSP.
3 - Reporting You can do that with any of those languages.
I think in the end is pretty much up to what you know to handle better. I would go for a language i already know instead of hitting a new one. That way you'll minimize deployment time, which is probably very important also.
For database i think you can get mysql or posgresql as they are both free, and will lower your costs.
Hope it helps :)
"I am about to develop a very large web based operations, inventory, sales management system." - this is a very ambitious undertaking. Are you doing this for fun, education, or profit? Do you intend to sell or open source this?
You realize, of course, that there are a lot of alternatives already in the marketplace. What advantage will yours have over the others?
Sounds like a classic buy versus build choice. Have you considered the buy before building?
It sounds like you prefer C# and MySQL. MySQL has several articles on using .NET with MySQL and the Connector/NET driver.
Unfortunately, I know very little about reporting with MySQL.

Good language to develop a game server in?

I was just wondering what language would be a good choice for developing a game server to support a large (thousands) number of users? I dabbled in python, but realized that it would just be too much trouble since it doesn't spawn threads across cores (meaning an 8 core server=1 core server). I also didn't really like the language (that "self" stuff grossed me out).
I know that C++ is the language for the job in terms of performance, but I hate it. I don't want to deal with its sloppy syntax and I like my hand to be held by managed languages. This brings me to C# and Java, but I am open to other languages. I love the simplicity of .NET, but I was wondering if, speed wise, this would be good for the job. Keep in mind since this will be deployed on a Linux server, it would be running on the Mono framework - not sure if that matters. I know that Java is syntax-wise very similar to .Net, but my experience with it is limited. Are there any frameworks out there for it or anthing to ease in the development?
Please help me and my picky self arrive on a solution.
UPDATE: I didn't mean to sound so picky, and I really don't think I was. The only language I really excluded was C++, Python I don't like because of the scalability problem. I know that there are ways of communicating between processes, but if I have an 8 core server, why should I need to make 8 processes? Is there a more elegant solution?
I hate to say it, and I know I'm risking a down mod here, but it doesn't sound like there's a language out there for you. All programming languages have their quirks and programmers simply have to adapt to them. It's completely possible to write a working server in Python without classes (eliminating the "self" variable class references) and likewise just as easy to write C++ with clean syntax.
If you're looking to deploy cross-platform and want to develop cross-platform as well, your best bet would probably be Java. It shorter development cycles than compiled languages like C and C++, but is higher performance (arguable, but I've always been anti-Java =P) than interpreted languages like Python and Perl and you don't have to work with unofficial implementations like Mono that may from time to time not support all of a language's features.
I might be going slightly off-topic here, but the topic interests me as I have (hobby-wise) worked on quite a few game servers (MMORPG servers) - on others' code as well as mine. There is literature out there that will be of interest to you, drop me a note if you want some references.
One thing that strikes me in your question is the want to serve a thousand users off a multithreaded application. From my humble experience, that does not work too well. :-)
When you serve thousands of users you want a design that is as modular as possible, because one of your primary goals will be to keep the service as a whole up and running. Game servers tend to be rather complex, so there will be quite a few show-stopping bugs. Don't make your life miserable with a single point of failure (one application!).
Instead, try to build multiple processes that can run on a multitude of hosts. My humble suggestion is the following:
Make them independent, so a failing process will be irrelevant to the service.
Make them small, so that the different parts of the service and how they interact are easy to grasp.
Don't let users communicate with the gamelogic OR DB directly. Write a proxy - network stacks can and will show odd behaviour on different architectures when you have a multitude of users. Also make sure that you can later "clean"/filter what the proxies forward.
Have a process that will only monitor other processes to see if they are still working properly, with the ability to restart parts.
Make them distributable. Coordinate processes via TCP from the start or you will run into scalability problems.
If you have large landscapes, consider means to dynamically divide load by dividing servers by geography. Don't have every backend process hold all the data in memory.
I have ported a few such engines written in C++ and C# for hosts operating on Linux, FreeBSD and also Solaris (on an old UltraSparc IIi - yes, mono still runs there :). From my experience, C# is well fast enough, considering on what ancient hardware it operates on that sparc machine.
The industry (as far as I know) tends to use a lot of C++ for the serving work and embeds scripting languages for the actual game logic. Ah, written too much already - way cool topic.
Erlang is a language which is designed around concurrency and distribution over several servers, which is perfect for server software. Some links about Erlang and game-servers:
http://www.devmaster.net/articles/mmo-scalable-server/
http://www.erlang-consulting.com/euc2005/mmog/mmog_in_erlang.htm
I'm thinking of writing a game-server in Erlang myself.
Speaking of pure performance, if you can run Java 6 you get about 1:1 performance when compared to optimized C++ (special cases notwithstanding, sometimes Java is faster, sometimes C++), the only problem you will have is of course stuff like database libraries, interconnectivity, scalability and such. I believe there's a variety of good to great solutions available to each of these problems but you won't find one language which would solve everything for you so I have to give you the age old advice: Choose the language you like and use that one.
Oh, you're still reading this? :) Well, here's some extra pointers.
EVE Online uses Python for its client and server side code and it's both bug-ridden and laggy as something I don't think I should write here so that'd be an example of how Python can be extended to (poorly) serve vast amounts of users.
While Java has some good to great solutions to various related problems, it's really not the best language out there for vast amount of users; it doesn't scale well to extremes without tuning. However there's multi-VM solutions to this which somewhat fix the issue, for example Terracotta is said to do the job well.
While C++ is rather cumbersome, it allows for such a low-level interaction with the system that you may actually find yourself doing things you thought you couldn't do. I'm thinking of something like dynamic per-core microclustering of runtime code blocks for "filling" every possible clock cycle of the processor as efficiently as possible for maximum performance and things like that.
Mono is far behind the .NET VM/equivalent on Windows platforms so you wouldn't be able to use the latest and fanciest features of C#. However Windows XP (x64) OEM licenses are so laughably cheap at the moment that with small investment you could get a bunch of those and you could then run your code on the platform it was meant to be. And don't fall into the Linux hype, Linux is your saviour only if you really know how to use it and especially XP is pretty damn fast and stable nowadays.
What kind of performance do you need?
twisted is great for servers that need lots of concurrency, as is erlang. Either supports massive concurrency easily and has facilities for distributed computing.
If you want to span more than one core in a python app, do the same thing you'd do if you wanted to span more than one machine — run more than one process.
More details about this game server might help folks better answer your question. Is this a game server in the sense of something like a Counter Strike dedicated server which sits in the background and hosts multiplayer interactions or are you writing something which will be hosted on an HTTP webserver?
Personally, if it were me, I'd be considering Java or C++. My personal preference and skill set would probably lead me towards C++ because I find Java clumsy to work with on both platforms (moreso on Linux) and don't have the confidence that C# is ready for prime-time in Linux yet.
That said, you also need to have a pretty significant community hammering on said server before performance of your language is going to be so problematic. My advise would be to write it in whatever language you can at the moment and if your game grows to be of sufficient size, invest in a rewrite at that time.
You could as well use Java and compile the code using GCC to a native executable.
That way you don't get the performance hit of the bytecode engine (Yes, I know - Java out of the box is as fast as C++. It must be just me who always measures a factor 5 performance difference). The drawback is that the GCC Java-frontend does not support all of the Java 1.6 language features.
Another choice would be to use your language of choice, get the code working first and then move the performance critical stuff into native code. Nearly all languages support binding to compiled libraries.
That does not solve your "python does not multithread well"-problem, but it gives you more choices.
The obvious candidates are Java and Erlang:
Pro Java:
ease of development
good development environments
stability, good stack traces
well-known (easy to find experienced programmers, lots of libraries, books, ...)
quite fast, mature VM
Pro Erlang:
proven in systems that need >99.9% uptime
ability to have software updates without downtime
scalable (not only multi-core, but also multi-machine)
Contra Erlang:
unfamiliar syntax and programming paradigm
not so well known; hard to get experienced programmers for
VM is not nearly as fast as java
If your game server mainly works as a event dispatcher (with a bit of a database tucked on), Erlang's message-driven paradigm should be a good match.
In this day and age, I would not consider using an unmanaged language (like C or C++); the marginal performance benefits simply aren't worth the hassle.
It may depend a lot on what language your "game logic" (you may know this term as "business logic") is best expressed in. For example, if the game logic is best expressed in Python (or any other particular language) it might be best to just write it in Python and deal with the performance issues the hard way with either multi-threading or clustering. Even though it may cost you a lot of time to get the performance you want out of Python it will be less that the time it will take you to express "player A now casts a level 70 Spell of darkness in the radius of 7 units effecting all units that have spoken with player B and .... " in C++.
Something else to consider is what protocol you will be using to communicate with the clients. If you have a complex binary protocol C++ may be easier (esp. if you already had experience doing it before) while a JSON (or similar) may be easier to parse in Python. Yes, i know C++ and python aren't languages you are limited to (or even considering) but i'm refer to them generally here.
Probably comes down to what language you are the best at. A poorly written program which you hated writing will be worse that one written in a language you know and enjoy, even if the poorly written program was in an arguable more powerful language.
You could also look at jRuby. It comes with lots of the benefits of Java and lots of the benefits of Ruby in one neat package. You'll have access to huge libraries from both languages.
What are your objectives? Not the creation of the game itself, but why are you creating it?
If you're doing it to learn a new language, then pick the one that seems the most interesting to you (i.e., the one you most want to learn).
If it is for any other reason, then the best language will be the one that you already know best and enjoy using most. This will allow you to focus on working out the game logic and getting something up and running so that you can see progress and remain motivated to continue, rather than getting bogged down in details of the language you're using and losing interest.
If your favorite language proves inadequate in some ways (too slow, not expressive enough, whatever), then you can rewrite the problem sections in a more suitable language when issues come up - and you won't know the best language to address the specific problems until you know what the problems end up being. Even if your chosen language proves entirely unsuitable for final production use and the whole thing has to be rewritten, it will give you a working prototype with tested game logic, which will make dealing with the new language far easier.
You could take a look at Stackless Python. It's an alternative Python interpreter that provides greater support for concurrency. Both EVE Online's server and client software use Stackless Python.
Disclaimer: I haven't used Stackless Python extensively myself, so I can't provide any first-hand accounts of its effectiveness.
There is a pretty cool framework in development that addresses all your needs:
Project Darkstar from Sun. So I'd say Java seems to be a good language for game server development :-)
I know facebook uses a combination of Erlang and C++ for their chat engine.
Whatever you decide, if you choose a combination of languages, check out facebook's thrift framework for cross language services deployment. They open sourced it about a year+ back:
http://incubator.apache.org/thrift/
C++ and Java are quite slow compared to C. The language should be a tool but not a crutch.

Categories

Resources