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?? :)