justintxu
24/04/09, 00:14:33
Navegando un poco y buscando noticias acerca del HTC Touch Diamond 2, me topé con un artículo muy interesante en donde se compara el código de programación en cada una de estas plataformas para presentar un mensaje que diga Hello World
Échenle un vistazo:
Ejemplo “Hello World” para Symbian:
// 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);
}
Tambien necesitaremos el archivo HelloWorld.mmp con lo siguiente:
// 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
Y finalmente el archivo bld.inf:
// BLD.INF
// Component description file
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
PRJ_MMPFILES
//only one project
HelloWorld.mmp
Ejemplo “Hello World” para Iphone SDK:
Lo primero que necesitaremos es crear un proyecto XCode llamada “HelloWorld”. No necesitaremos modificar los archivos main.m y main.h. Pero sí los archivos helloworldAppDelegate.m y helloworld.AppDeleage.h.
El archivo header.
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
Y el archivo 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
Ejemplo “Hello World” para J2ME:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorld extends MIDlet implements CommandListener {
private Command exitCommand;
private TextBox tbox;
public HelloWorld() {
exitCommand = new Command(”Exit”, Command.EXIT, 1);
tbox = new TextBox(”Hello world MIDlet”, “Hello World!”, 25, 0);
tbox.addCommand(exitCommand);
tbox.setCommandListener(this);
}
protected void startApp() {
Display.getDisplay(this).setCurrent(tbox);
}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
public void commandAction(Command cmd, Displayable disp) {
if (cmd == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
Ejemplo “Hello World” para Google Android:
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);
}
}
Ejemplo “Hello World” para Windows Mobile:
using System;
using System.Windows.Forms;
public class HelloWorld {
public static void Main() {
MessageBox.Show( “Hello World!” );
}
}
Solo me queda repetir lo que dice al final del artículo : MICROSOFT RULES!!!!!!!! X-D
Échenle un vistazo:
Ejemplo “Hello World” para Symbian:
// 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);
}
Tambien necesitaremos el archivo HelloWorld.mmp con lo siguiente:
// 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
Y finalmente el archivo bld.inf:
// BLD.INF
// Component description file
//
// Copyright (c) 2000 Symbian Ltd. All rights reserved.
PRJ_MMPFILES
//only one project
HelloWorld.mmp
Ejemplo “Hello World” para Iphone SDK:
Lo primero que necesitaremos es crear un proyecto XCode llamada “HelloWorld”. No necesitaremos modificar los archivos main.m y main.h. Pero sí los archivos helloworldAppDelegate.m y helloworld.AppDeleage.h.
El archivo header.
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
Y el archivo 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
Ejemplo “Hello World” para J2ME:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HelloWorld extends MIDlet implements CommandListener {
private Command exitCommand;
private TextBox tbox;
public HelloWorld() {
exitCommand = new Command(”Exit”, Command.EXIT, 1);
tbox = new TextBox(”Hello world MIDlet”, “Hello World!”, 25, 0);
tbox.addCommand(exitCommand);
tbox.setCommandListener(this);
}
protected void startApp() {
Display.getDisplay(this).setCurrent(tbox);
}
protected void pauseApp() {}
protected void destroyApp(boolean bool) {}
public void commandAction(Command cmd, Displayable disp) {
if (cmd == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
Ejemplo “Hello World” para Google Android:
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);
}
}
Ejemplo “Hello World” para Windows Mobile:
using System;
using System.Windows.Forms;
public class HelloWorld {
public static void Main() {
MessageBox.Show( “Hello World!” );
}
}
Solo me queda repetir lo que dice al final del artículo : MICROSOFT RULES!!!!!!!! X-D