Mélységi keresztfejlesztésekre is alkalmas Mono a Xamarintól

Mélységi keresztfejlesztésekre is alkalmas Mono a Xamarintól

Mellbeverő hír:
— Az Android 4.0 (Ice Cream Sandwich) Java-ban lévő kódbázisát, több mint egy millió sort, sikeresen portolta a Mono gyökerű Xamarin C#-ra, amit a Mono futtató környezeten lehet immár végrehajtani, azaz a Dalvik kihagyásával.
— Teljesítmény javulás szempontjából ez azt jelenti, hogy hozzávetőleg egy nagyságrenddel jobb futási teljesítményt értek el a struct-ok és a generic-ek terén. Ennyit jelent a C# nyelvileg fejlettebb volta és a Mono futtató környezet 10 éves érettsége összességében a megfelelő Java-s nyelvi konstrukciókkal és a fiatal Dalvik futtató környezettel összehasonlítva (ezekben az esetekben)!
— Ez egyúttal azt is jelenti, hogy a Mono, mint platformok közötti keresztfejlesztő rendszer még jelentősebbé válik. Már egy korábbi fejlesztők közötti felmérés is megmutatta, hogy a Xamarin MonoTouch / Mono for Android benne van az első ötben (a PhoneGap, Sencha Touch/JQTouch, Mono, Appcelerator, Adobe Flex az akkori használati gyakoriság sorrendben), a tervezett adaptáció szempontjából pedig a második helyen áll a PhoneGap után. Ezt tetézi még a vállalati alkalmazások mobil változatának kidolgozásában elfoglalt vezető szerep.
— A Xamarin – a sikeres Android 4.0 (ICS) portolás után – most kihelyezte github közösségi fejlesztésbe az eddig elkészült XobotOS változatot, a keresztfejlesztések szempontjából jól hasznosítható eszköz megoldásokat pedig a Mono részeként fogja majd hasznosítani.

Az alábbiak ennek a merőben új Mono helyzetnek legfőbb ismérveit foglalják össze:

Last July when Xamarin was getting started, we got our team together in Boston to plan the evolution of Mono on iOS and Android. … Over and over we came back to the basics: Dalvik is a young virtual machine, it is not as performant or tuned as Mono and suffers from many of Java’s performance limitations without the benefit of the high-end optimizations from Oracle’s HotSpot. One crazy idea that the team had at that dinner was to translate Android’s source code to C#. Android would benefit from C# performance features like structures, P/Invoke, real generics and our more mature runtime.

… What if we could swap out Java with faster C# and get rid of various Dalvik limitations in the process? Could we create an Android phone completely free of Java, and free of the limitations of the Dalvik VM?

We decided it was crazy enough to try. So we started a small skunkworks project with the goal of doing a machine translation of Android from Java to C#. We called this project XobotOS.

The XobotOS Research Project

The result of our efforts is that today we have most of Android’s layouts and controls entirely in C#.

Getting to this point required that the majority of the Android Java code be translated from Java to C#, so what you see above represents very significant progress. So how did we do it?

Java Translation via Sharpen

Android’s core codebase contains over a million lines of Java code, and we knew we wanted to be able to stay up to date with new releases of Android — in fact, we started with the Android 2.x source code back in 2011, and then upgraded XobotOS to Android 4.0 when Google open sourced Ice Cream Sandwich earlier this year. So for us, the only reasonable option was to do a machine translation of Java to C#, building and maintaining any necessary tools along the way.

The tool we used as a starting point is called Sharpen. Sharpen is famous for helping people such as Frank Krueger port a Java applet to an award-winning iPad app in two months.

We matured Sharpen a lot, and the result is a much-improved Java-to-C# translation tool for everyone. We are releasing this new version of Sharpen today along with the code for XobotOS and we hope that many more people will benefit from it and contribute to it.


So once you have Android running on Mono, the obvious question is — how does Mono perform compared to Dalvik?
So once you have Android running on Mono, the obvious question is — how does Mono perform compared to Dalvik?

You can see the massive difference in the performance of structs and generics in this benchmark we ran of a simple binary tree implementation in Java and C#:

What’s Next

Today we’re proud to announce that we’ve made XobotOS available on github so that you can try it out yourself.

Our goal as a company is to provide the best platform for building mobile apps, and so XobotOS will not be a focus for us going forward. But it was a fun experiment to run, and as it turns out, a few technologies have come out of the effort that we’ll be able to include in future versions of our products:

Direct Graphics Access to Skia: Currently Mono for Android accesses the underlying graphics libraries through Java, with the code that we built for XobotOS, we will skip the middleman and use Mono’s P/Invoke to get straight to the native rendering code in Skia.

Java to C# tooling: Our new version of Sharpen is available as part of our XobotOS release.

Replacing Java code with C# code we now have the tools necessary to replace some chunks of Java code with C# code where performance is critical and when C# can offer better solutions than Java has. Our plan is to take elements of the research project and integrate those into our products.

A project that we started because we thought it would be fun to do has turned out to yield some serious benefits for our products. It’s important for a startup to stay focused, but sometimes you have to try something crazy to make progress. And who knows, maybe Google will thank us some day :-) . [Miguel de Icaza]

Android Ported to C# [Xamarin blog, May 1, 2012]

When considering how to build Android applications, many people think that Java is the only choice. However, over the past few years, an entire new ecosystem of platforms for building Android applications has emerged. These new solutions include Mono for Android, AppCelerator, PhoneGap, etc., just to name a few.

Each of these platforms has a different feature set and each varies in its ability to write native applications – that is, applications that compile down to native code and that interop fluently with the underlying Java subsystem. For example, some platforms only allow you to build apps in HTML and JavaScript (such as AppCelerator), whereas some are very low-level and only allow C/C++ code. Some platforms (such as Flash) don’t even utilize the native control toolkit.

Mono for Android is unique in that it combines all of the power of Java and adds a number of powerful features of its own, including:

  • Complete Binding for Android Java API  Mono for Android contains bindings for nearly the entire ADK. Additionally, these bindings are strongly-typed, which means that they’re easy to navigate and use, and provide robust compile-time type checking and autocomplete during development. This leads to fewer runtime errors and higher quality applications.

  • Modern Language Constructs  Mono for Android applications are written in C#, a modern language that includes significant improvements over Java such as Dynamic Language Features, Functional Constructs such as Lambdas,LINQ, Parallel Programming features, sophisticated Generics, and more.

  • Modern Integrated Development Environment (IDE) Mono for Android uses MonoDevelop on Mac OSX, and also MonoDevelop or Visual Studio 2010 on Windows. These are both modern IDE’s that include features such as code auto completion, a sophisticated Project and Solution management system, a comprehensive project template library, integrated source control, and many others.

Mono for Android allows you to use C# and the .NET Base Class Library (BCL) to write native Android applications. This is accomplished by executing applications in an instance of the Mono runtime VM, which co-exists on devices along with Google’s Dalvik VM. When a Mono for Android application is built, three main steps occur:

  • Resource Generation As a pre-build step, aresgen.exe is run against a Resources directory in order to generate a Resources.designer.cs file containing Android resource identifiers. These resource identifiers are a key piece of Android applications and are used to locate images, UI files, strings, etc.
  • Compilation C# code is compiled into a Managed .NET/Mono assembly.
  • Android Wrapper Creation The mandroid.exe tool is run against the .NET assembly to generate Android-callable wrappers and generate an Android package.

Introduction to Mono for Android [Xamarin, Nov 14, 2011]

I have a MonoTouch or WindowsPhone 7 application, can I just rebuild it with Mono for Android and target Android?

Both Mono for Android and MonoTouch bring the core of .NET to the iPhone and Android platforms, but neither offer a UI cross-platform solution.

Each operating system offers slightly different services for building user interfaces, interacting with the phone, the address book, the built-in GPS and audio systems.

Our recommendation for users that want to target all three mobile platforms is for developers to separate the business logic of their application from the user interface and hardware interface layer.  This means that both the user interface layer and any hardware integration components will have to be written once for each platform.

Android :: FAQ [Xamarin]

Navigate the 2012 Mobile World Congress Conference in style with Xamarin’s mobile cross-platform Unofficial MWC 2012 app (MWC 2012)! Or, better yet, jump in and take a look at the source to see how we shared 100% of our backend code, including the database, across iOS, Android, and Windows Phone 7!

Announcement of the cross-platform Unofficial MWC 2012 app

(Xamarin Mobile World Congress 2012 Unofficial Conference App Released! [Xamarin blog, Feb 24, 2012])

Long Term

Cross-platform mobile APIs to make it easier to share code across MonoTouch, Mono for Android and Windows Phone 7 platforms.

Roadmap – Mono for Android [Xamarin, July 25, 2011]

Roadmap – MonoTouch [Xamarin, Aug 23, 2011]

További információ:
Mono for Android – Create amazing Android apps with C# and .NET [Xamarin microsite]
Preparing Package for Android Marketplace [Xamarin tutorial, April 6, 2011]
Preparing Package for Android Marketplace [Xamarin guide, April 27, 2011]
MonoTouch – Create amazing iPhone and iPad apps with C# and .NET [Xamarin microsite]
Building for Distribution [in Apple App Store] [Xamarin [earlier Novell] tutorial, Sept 16, 2009]
Publishing to the App Store [Xamarin tutorial, Nov 24, 2011]

Google Could Have Used C# for Android: Xamarin [eWeek article, May 3, 2012]
Mono for Android 4.0 is Here! [Xamarin blog, Dec 11, 2011]
Top 5 Features of Ice Cream Sandwich with Mono for Android 4.0 [Xamarin on slideshare, Feb 09, 2012]+ video for these slides [35:20 long video on the XamarinHQ YouTube channel, Feb 9, 2012]
Third Party Libraries with MonoTouch and Mono for Android [Xamarin on slideshare, Feb 24, 2012]
+ video for these slides [41:22 long video on the XamarinHQ YouTube channel, Feb 23, 2012]
Mono for Android 4.0 Introduction [Xamarin on slideshare, March 24, 2012]
VisionMobile Identifies Xamarin as a Leader in Mobile Cross-Platform Application Development Tools [Xamarin press release, Marchh 20, 2012]
Cross-Platform Developer Tools 2012 [VisionMobile blog, Feb 28, 2012]
+ the full, free, and “industry-first” report on cross-platform developer tools downloadable here
Cross-platform Mobile Development [Xamarin on slideshare, April 23, 2012]
+ video for these slides [40:40 long video on the XamarinHQ YouTube channel, April 23, 2012]


Feltöltve 2012. május 4. péntek Szerző: Nacsa Sándor

Vélemény, hozzászólás?

Adatok megadása vagy bejelentkezés valamelyik ikonnal:

WordPress.com Logo

Hozzászólhat a WordPress.com felhasználói fiók használatával. Kilépés /  Módosítás )

Google+ kép

Hozzászólhat a Google+ felhasználói fiók használatával. Kilépés /  Módosítás )

Twitter kép

Hozzászólhat a Twitter felhasználói fiók használatával. Kilépés /  Módosítás )

Facebook kép

Hozzászólhat a Facebook felhasználói fiók használatával. Kilépés /  Módosítás )


Kapcsolódás: %s

%d blogger ezt kedveli: