So I have access to a dedicated server and want to finally create my game - it's a browser based game, fairly simple. I know PHP and MySQL fairly well and would want to integrate with them on the front end.
The question is what is a good server-side language to use either as a constant process or with cron to interface with the MySQL database to do calculations?
Ideally my requirements are:
- As short a learning curve as possible.
- Easiest access to MySQL as possible.
- As hard to shoot yourself i开发者_C百科n the foot as possible.
I'd like to avoid C/C++ if possible for the above 'shoot yourself in the foot' problems. It'd also be nice to have a secondary language to use personally so I may take it beyond this limited scope.
Thanks in advance for any insights!
You could use commandline php with cron. The great advantage of that is that you can reuse libraries that you write for your game and you already know the language. I don't think it's performance is great though.
Besides that there are a ton of languages you might choose, Python and Java are popular.
There are two good options here:
PHP
PHP is a server side language, and if you design the frontend with some robust classes, you can reuse the classes for the command-line daemon. This allows you to have a more standardized application suite, which will be easier to modify in the future. PHP can access MySQL, and since you already know it, the learning curve will be minimal.
Python
Python is an excellent server side language for an application like this. It can talk to any SQL database with a standardized instruction set, called DB API 2.0. This means taht if at any point you want to change from MySQL to PostgresSQL, you simple change:
import my_mysql_library as sql
to:
import my_postgres_library as sql
And your application won't need any other code changes. Python also contains many libraries that might come in handy, and if optimized correctly, will be faster than PHP.
Conclusion
Personally, I would use Python, for the following reasons:
- Learning Experience; Programming is always about learning. At any opportunity, use a language or tool you don't already know so that you can learn it.
- Language Preference; After programming in both PHP and Python, I can honestly say that there is no situation where I would prefer to use PHP over Python. Not one.
- Available Libraries; Python has a very robust community, and a lot of useful libraries and packages (such as NumPy) that make things much easier for you.
With both languages you could have them run intermittently via a cron job, or you could have them run as a Daemon (which is as easy as running the script(s) while piping your output to a black hole, such as /dev/null)
Another great option for your server side scripting is perl. It has a bit of a learning curve at the start but becomes a very fast language to script in.
A great resource is http://perldoc.perl.org/
精彩评论