The Server Side (Part 1)

Sooner or later, you're going to need your mobile app to communicate with a server. It might be to load data, or to share something with a friend, but the need will inevitably arise.

In the next article, I'll describe how to communicate between a mobile device and a web server. However, before I take on that task, it's necessary to create and host the server code.

I've been doing corporate development for quite some time, so it's natural for me to develop the code in Java (aka J2EE). And while that's certainly a reasonable platform for server code, there are a few problems for the average developer. The most critical of these problems is the ability to find a low-cost hosting company that will serve up J2EE code.

There's an option at Amazon to get a free micro instance environment. This option is great for those who are familiar with J2EE and Linux, but if you're not, it's a bit of a struggle to configure the instance and successfully deploy the code. Furthermore, after a year, if you want to continue to host your J2EE code, it's necessary for you to start paying for the service. (Don't get me wrong - that's perfectly reasonable on Amazon's part.)

For server-based code, there's another option: PHP. Nearly all hosting providers will provide you with PHP and MySQL. (In the US, you can get this service for as little as $5 / month.) So given the ease of programming PHP, and the inexpensive availability of a hosting service, this too seems like a reasonable server platform.

So you're probably asking: Which is better? To this question, I'll give you my standard answer: You can build great software with either platform. I know that's a bit anticlimactic, but it's how I really feel.

Some folks have scoffed at PHP, and said that it's not a "real" language. They argued that sites would eventually have to convert to other languages to scale. Then came Facebook, and that ended the argument for the most part.

So, in keeping with the bilingual motif of these articles, I plan to provide both Java and PHP examples of the server code. Both examples should produce the same results, so the only client-side differences will be in the URL. Then, once the server-based code is complete, I'll be ready to load data onto iOS and Android mobile devices.