Friday, May 30, 2014

Cross-platform is a feature

The way of making software has changed a lot since the early days, it has changed more than what the software itself has. Think of an old green-screen program where you had a lot of data entry to do. Now think of a brand new (smooth, spa) web application also for data entry, they might even look the same, but I’m sure the process of building each is totally different.

Nicol├ís Jodal mentioned in a recent keynote that the way of creating software is much more complicated than what it used to be. I couldn’t agree more, and I’ll try to explain here why.

Back in the old days when you were asked for a piece of software, you had (almost every time) the chance to choose the programming language and tools of your choice. Were you good at php, or asp? you could work in whatever you wanted and then tell your customer what hardware he needed to run the software you would provide. Sometimes of course, the client would tell you he had an old Linux server he wanted to use for that piece of software. Then, you would go to your office (bed room?) and hack for days in order to get to the promised schedule with something good enough to show your client. Once you had the program “done” you would deliver it to the client. There were some features he wanted but never told you about. He wanted the software to run smooth, with no delays (I remember 3secs per page load being the affordable top) and of course, secure. He didn’t want it to be hacked.

Now everything is a little more complex than that.

When you are asked for a program, it’ll will most likely be for a phone and/or tablet. That’s where the trends are. You could be asked for an app or a whole solution with back-end integration with existing software. Plus, you’ll most likely be asked to provide services to talk to other programs, and also consume from other programs. One thing is clear: you will have to provide many platforms.

Being good (expert) in Java and provide one single “flavor” of the app for Android is not good enough. You will have to learn Objective-C for iOS and C# (or Javascript) for Windows Phone. And that’s just as of today, we have no idea what will come next.

So a lot of people realized that, it is not something new, and are trying to provide some layer of abstraction so you don’t have to actually learn everything that comes out.

Xamarin provides you with a single language approach, where just by knowing C#, you can create native apps for every major smart device platform. That is OK, but still, you need to learn how the different programming models work.

Let’s say you want to show a small message in you app, you would have to write something like these depending on the platform:


Toast.MakeText (this.Activity, "Please verify your Xamarin account credentials and try again", ToastLength.Long).Show();


var alert = new UIAlertView ("Could Not Log In", "Please verify your Xamarin account credentials and try again", null, "OK");
alert.Show ();
alert.Clicked += delegate {
LoginView.PasswordField.SelectAll (this);
LoginView.PasswordField.BecomeFirstResponder ();
};


The first line is for Android, while the second snippet is for iOS. Trust me when I say they’re both C#, but as you can see, when developing for Android you need to learn what Toasts and Activities are. While for iOS the code looks totally different and you need to learn about the UIAlertView, program it’s delegate for the callback and so on.

As you can see, the language is not the problem here, the problem is that you still need to learn a lot from every platform you are targeting, and this is a simple example of course.

Xamarin recently released Xamarin.Forms. This trends to solve this problem by adding another layer with controls and pages that match a specific control in Andoid and iOS.

The other problem I see with traditional approaches, and this brand new from Xamarin, is that you need to write your business rules in a Word document (?) and then write the code, and sometimes also comment that code to explain what is supposed to do. That means that you have the same information in 3 different means.

Wouldn’t it be great if you could have all that information someplace centralized and versioned, let’s say a model? And run some process for which its output is the program that implements those rules? Wouldn’t it be great if once you have your Android app you could just (after tweaking some properties) run the process again and have your iOS app ready?

Wouldn’t that be awesome?

You cannot afford to learn everything if you really need to, I’m not saying it would be fun, but if you really need to do real world stuff that just does not scale up. What if a new platform shows up? Would your customer wait for you to learn the new thing (say Swift)?

It just does not scale up.

I mentioned before about Find my Plane, the flight tracker app I built which is now for Android, iOS and Windows 8. I could have never done that app for every platform in the time it actually took me. And now I’m able to prototype and deploy new versions easily, why? because I work on a model where I declare what I want to happen next and then I run this process to generate the many versions of my app.

image 

That’s why I believe Genexus is on the right track. I’m not saying it is done or solves every developer problem, but it sure helped me and thousands of developers around the world to take their apps out there. On time.

NOTE: The code shown above was taken from the actual app from Xamarin Store. You can download the app here: http://xamarin.com/sharp-shirt

No comments: