Teaser – MonoDroid with Oxygene

August 20, 2010 in .NET, Android, Elements, Mono, Oxygene, Platforms, Visual Studio

Now that the MonoDroid preview is out, I thought I’d experiment a little with Oxygene (aka Delphi Prism), so I ported the “Button” sample to Oxygene. Here’s a taste of what I came up with:

method Activity1.OnCreate(bundle : Bundle);
begin
    inherited OnCreate(bundle);
 
    // Create your application here
    var button := new Button(self);
 
    button.Text := 'Oxygene Says: Click Me!';
    button.Click += method begin
      button.Text := string.Format('{0} clicks!', count);
      inc(count);
    end;
 
    SetContentView(button);
end;

As you can see, there’s not a lot of difference from the C# version.

Obviously, this won’t be in the build that we RTM’ed last week, and will soon be available from our friends at Embarcadero, but it will work with said release. So if you’re a Delphi Prism customer, or just have a fondness for Pascal syntax, keep an eye out here – more info will be available soon, including templates & other support files.

method Activity1.OnCreate(bundle : Bundle);
begin
inherited OnCreate(bundle);

// Create your application here
var button := new Button(self);

button.Text := ‘Oxygene Says: Click Me!';
button.Click += method begin
button.Text := string.Format (‘{0} clicks!’, count);
inc(count);
end;

SetContentView (button);
end;

10 responses to Teaser – MonoDroid with Oxygene

  1. Very cool. :-) Eventually I presume a RO/DA application could work with this?

    • eventually, I’m sure it can. I’ve been working on RO/DA for MonoTouch as well, but it’s not ready for daylight yet. We’ll keep you informed :)

  2. Oh, I’m drooling already!

  3. Please tell me what do you think about a .Net based language (Prism, for instance) + Mono targeting iphone? marc has a interesting point of view about it. What makes .net based language + mono, targeting Android diferent?

    • i’ll let Brian answer for himself, as he’s more deeply invested into the platform as i am, but right out of hand, i can see three big reasons why MonoDroid might be more attractive to Android developers that MonoTouch is, imho, to iOS ones:

      (a) iOS has an awesome tool chain already, with Xcode, Cocoa, Instruments and all that. it’s a pleasure to work with. Android has, well, Java ;)

      (b) on conceptual level, Objectve-C is much more different from .NET languages (including C# and Delphi Prism) than Java is. As a result, a lot of “awkward” remapping is required in MonoTouch to make the Cocoa libraries accessible from .NET – invalidating all Apple docs and all third party samples you find out there, because method names and the way things works are so much different. This mapping takes a very well designed OOP API and basically turns it upside down. That is not the case for Java, and while i have not looked at the Android vs. MonoDroid APIs myself, i would imagine they can look much more similar (if not identical) than the iOS vs MonoTouch ones do.

      (c) Apple, as platform vendor for iOS, has explicitly disapproved the use of languages other than Objective-C. Google has not. So, regardless of what one thinks about this decision from Apple (personally, i can understand it, and as a user, approve it), and regardless of whether Apple will actually start rejecting app based on MonoTouch or not (i doubt they will), investing into a project based on MonoTouch does bear a certain risk, as you are using an unapproved tool chain and your app might get rejected. especially when combined with the above 2 reasons, IMHO that is enough to not bother with MonoTouch. Once again, for MonoDroid, this is not the case.

      hth,
      marc

    • I wouldn’t say it’s “different”. marc has some good points, and I think that attracting existing developers away from the device’s native language isn’t the goal. For me, being a long-time .Net developer, and mostly Delphi & Turbo Pascal before that, there are several benefits on both platforms:
      (1) I don’t have to learn a new language in order to code for each device. In fact, if I do it right, I can have the same backend code for an app in iOS, Android, and WinPhone7.
      (2) As much as marc likes Objective-C, there are a lot of developers (almost everyone I talk to in the MonoTouch camp, for example) that can’t stand it. I find it hard to even read, and does things backwards most of the time.
      (3) And don’t even get me started talking about Java… When I got my Droid, I spent about a week trying to figure out the differences with C# and get past the “Hello World” stage… but it wasn’t worth it.

  4. This is awesome. I haven’t gotten into Android yet, because I can’t stand Java. Monodroid is going to rock. As for Chrome, I’ve been away from ObjectPascal for quite a while now, but I can’t help noticing what a nice readable language it is.

  5. Brian you really could run monodroid Delphi Prism? You have created a version of Novell.MonoDroid.CSharp.targets for Prism?

    • yes, i did. i guess i need to get this polished up and distributed. keep an eye out for a blog post about it in the next few days.

  6. I managed to install the monodroid in the Prism and generate a new project with a
    MonoDroidApplication.oxygene and to change the cs to pas, but I can not validate the
    syntax of Pascal during compilation. I know that one problem is in
    Novell.MonoDroid.CSharp.targets, you could not send any material, source, note or doodle that can help me?
    Or is this really is more complex than it seems?