Hello World: Windows Mobile vs Symbian vs Android vs Iphone

First Symbian, than Windows Mobile, than the Iphone, now the Google Android platform... the mobile development world is really on movement.

These are all great platforms, each of them with their pros and cons (as usual).

What about if you have to develop the classic "Hello World" application on each of this platforms?

With Symbian it will be something like this:

// HelloWorld.cpp
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
#include "CommonFramework.h"
// do the example
LOCAL_C void doExampleL()
{
_LIT(KHelloWorldText,"Hello world!\n");
console->Printf(KHelloWorldText);
}

You will also need an mmp (HelloWorld.mmp) file which contains:


// HelloWorld.mmp
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
//
// using relative paths for sourcepath and user includes
//
TARGET HelloWorld.exe
TARGETTYPE exe
UID 0
//
SOURCEPATH .
SOURCE HelloWorld.cpp
//
USERINCLUDE .
USERINCLUDE ..\CommonFramework
SYSTEMINCLUDE Epoc32include
//
LIBRARY euser.lib

And finally a bld.inf file


// BLD.INF
// Component description file
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
PRJ_MMPFILES
//only one project
HelloWorld.mmp

With the Iphone SDK:

You've to start by creating an XCode project named helloworld. You won’t need to touch the main.m or main.h files, only the helloworldAppDelegate.m and helloworld.AppDeleage.h files.

The header file:

    1 //
    2 //  helloworldAppDelegate.h
    3 //  helloworld
    4 //
    5 //
    6 //
    7
    8 #import <UIKit/UIKit.h>
    9
   10 @class MyView;
   11
   12 @interface helloworldAppDelegate : NSObject {
   13     UIWindow *window;
   14     MyView *contentView;
   15     // Levi: Define textView object
   16     UITextView  *textView;
   17 }
   18
   19 @property (nonatomic, retain) UIWindow *window;
   20 @property (nonatomic, retain) MyView *contentView;
   21 // Levi: Declare textView as a property
   22 @property (nonatomic, retain) UITextView *textView;
   23
   24 @end
   25

The helloworldAppDelegate.m:

    1 //
    2 //  helloworldAppDelegate.m
    3 //  helloworld
    4 //
    5 //  
    6 //
    7
    8 #import "helloworldAppDelegate.h"
    9 #import "MyView.h"
   10
   11 @implementation helloworldAppDelegate
   12 
   13 @synthesize window;
   14 @synthesize contentView;
   15 // Levi: Tell the compiler to synthesize relevant accessors
   16 @synthesize textView;
   17
   18 - (void)applicationDidFinishLaunching:(UIApplication *)application {
   19     // Create window
   20     self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
   21
   22     // Set up content view
   23     self.contentView = [[[MyView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
   24     [window addSubview:contentView];
   25
   26     // Levi: Create the text view.
   27     self.textView = [[[UITextView alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)] autorelease];
   28     [textView setEditable:YES];
   29     [textView setText:@"Hello World"];
   30
   31     // Levi: Add a text view to the content view.
   32     [contentView addSubview:textView];
   33
   34     // Show window
   35     [window makeKeyAndVisible];
   36 }
   37
   38 - (void)dealloc {
   39     // Levi: Release the textView
   40     [textView release];
   41     [contentView release];
   42     [window release];
   43     [super dealloc];
   44 }
   45
   46 @end
   47

With Google Android it will be:

package com.android.hello;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello World");
       setContentView(tv);
   }
}

And with Windows Mobile? It will be:

using System;
using System.Windows.Forms;

public class HelloWorld {

    public static void Main() {

        MessageBox.Show( "Hello World!" );
    }
}

Who is the winner?? :)

Technorati Tags:

Print | posted on Wednesday, September 24, 2008 9:14 PM

Comments on this post

# re: Hello World: Windows Mobile vs Symbian vs Android vs Iphone

Requesting Gravatar...
hi,

nice, though one would argue about number of files needed,
iPhone is cocoa so your WMobile sample can be fitted into single "main.m" autogenerated file:

#import

int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}

@interface HelloWorldAppDelegate : NSObject {
UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end

@implementation HelloWorldAppDelegate
@synthesize window;

- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window makeKeyAndVisible];
UIAlertView *alert = [[UIAlertView new] initWithTitle: @"Message" message:@"Hello World!" delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil];
[alert show];
[alert release];
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end


regards,
Peter
Left by Peter Blazejewicz on Sep 25, 2008 4:09 AM

# re: Hello World: Windows Mobile vs Symbian vs Android vs Iphone

Requesting Gravatar...
Thanks Peter...
Left by Stefano Demiliani on Sep 25, 2008 2:31 PM

# re: Hello World: Windows Mobile vs Symbian vs Android vs Iphone

Requesting Gravatar...
Well, since the latest symbian phones has python built in, the symbian version becomes


print "Hello, World!"

- so now who is the winner ;-)
Left by erta on Oct 16, 2008 2:29 AM

# re: Hello World: Windows Mobile vs Symbian vs Android vs Iphone

Requesting Gravatar...
Print the entire Python code or it will be difficult to say who is the winner :)
Left by Stefano Demiliani on Oct 16, 2008 8:51 AM

# re: Hello World: Windows Mobile vs Symbian vs Android vs Iphone

Requesting Gravatar...
but the entire Phyton code is:

print "Hello, World!"

hehe
Left by souojor on Oct 27, 2008 12:13 AM

# Mr

Requesting Gravatar...
You didn't put any comments with the Windows Mobile one. Bias if ever I saw it.
Left by Jimbo on Dec 05, 2008 3:07 PM

# re: Hello World: Windows Mobile vs Symbian vs Android vs Iphone

Requesting Gravatar...
Python does install on WinMo too, so the "print 'Hello, World!' works on that too!! Now, who's the winner?
Left by James Kally on Dec 08, 2008 1:51 PM

Your comment:

 (will show your gravatar)
 
Please add 5 and 5 and type the answer here: