12 ms·
Android Ported to C#
- sosuke 14y agoDo those benchmarks suggest that XobotOS is faster for those metrics than vanilla Android? That seems like a very large performance gain, and I already wonder what the performance on a device would be like.
- jlawer 14y agoYeah, but this was 1 synthetic benchmark, which heavily uses 2 features they made a point about being significantly faster. The real question is what is the difference between dalvik and mono on more balanced applications. I expect we are talking closer to 10% difference then the order of magnitude their benchmark shows.
- migueldeicaza 14y agoIt really depends on the program load. In general, Mono is just a more mature VM than Dalvik is, so it is rare for Dalvik to match Mono (although there are a couple of cases where it matches it). The other problem is that Dalvik uses a model that limits the amount of memory your app can use, so most of the heavy duty tests could not be ran to compare the apps, since Dalvik would crash with an out of memory condition while Mono does not impose this limit. Dalvik has also other ugly limitations, like their GC being suspended whenever a JNI invocation is taking place.
- Zigurd 14y agoYour mileage may vary. Myriad had been trying to sell their own VM as a "turbo" Dalvik, but, so far, no takers, that I know of, among handset OEMs. The thing is that Dalvik balances performance and battery life by aiming for fast interpretation plus minimal JIT compilation. One could easily show that the Oracle VM would trounce Dalvik at computation benchmarks, since it is aiming for best possible performance using a very sophisticated JIT compiler. But I suspect getting the Oracle VM to not suck your battery dry would be a challenge.
- shadowmint 14y agoTo be fair, they didn't open source theirs and make it available for people to play with.
- jsight 14y agoInteresting, but there's not a single mention of memory usage impact. Dalvik in particular makes some fairly severe tradeoffs to reduce memory usage. OTOH, I've often wondered if those tradeoffs are actually worth it in the end. This may just be demonstrating how weak/slow the Dalvik VM actually is.
- koenigdavidmj 14y ago> Dalvik in particular makes some fairly severe tradeoffs to reduce memory usage. Out of curiosity, would you be willing to write a little blurb (or post a link) about those tradeoffs?
- yonran 14y agoHere's Dan Bornstein's talk at Google I/O 2008 about the dex format and the original Dalvik interpreter: http://www.youtube.com/watch?v=ptjedOZEXPM http://www.youtube.com/watch?v=ptjedOZEXPM I'm not sure how useful it is in comparing the Dalvik JIT to MonoTouch though.
- Osiris 14y agoI find it interesting that there was such an effort to reduce memory usage because I've always had severe memory issues on the two Android phones I've had. The first, the myTouch 3G had about 100MB of RAM, with only about 25MB free from a cold boot, meaning the phone is really really slow due to memory pressure. My current phone, a G2, has about 350MB of RAM total and about 70MB free on a cold boot (ICS). A full Ubuntu Desktop install can use only about 250MB of RAM on cold boot and even Windows XP would run in 256MB of RAM. So with so much emphasis on saving RAM, why is 350MB of RAM insufficient to run basically one app at a time on a phone (plus the various background processes the system is running)?
- Zigurd 14y ago"Free memory" in a garbage-collected managed language is difficult to measure. If you don't have to GC, the performance-minded choice would to not GC. Every computation costs battery life, so I would suppose Android's GC is tuned to not run if it doesn't have to. If you look at the specifications of system.gc(), it can be implemented as a placebo, like the "push to walk" button at the street corner. So even explicitly GC'ing isn't guaranteed to do anything. Android also has a strategy for "swapping" components within a process, and whole processes. This is, effectively, Android's GC strategy across processes. An Android system's memory, especially on small-memory devices, should always look full-ish, but you can almost always launch a new task, since GC and components and process "swapping" (the "destroy" phase of component lifecycle) and GC can almost always make room for more.
- untog 14y agoFascinating, especially in the light of the Google Java issues right now- the performance graphs are just the icing on the cake. Mono has traditionally had a reputation as being a lot slower than .NET- perhaps that isn't the case any more either? It would be great to see some independent third party figures on this. It's funny that the MS created C# is one of very few languages that lets you make native apps in iOS, Android and WP.
- gravitronic 14y agoI've been successful in using C++ (with libSDL) to write apps for Android, iOS, QNX (PlayBook) and WebOS (RIP). Whats more bizarre is that windows phone 7 does not have a development kit for using C/C++. Only C#/XNA. I've heard on HN that this may change for WP8. I hope so.
- HardyLeung 14y agoWP8 and Windows 8 are definitely very C++ friendly. I actually think that C++ may be the language to rule them all as the next generation of web application goes beyond what Javascript can handle. Well, that and C# given Miguel's effort. I can develop ONE piece of core logic, and have it run on iOS, Android, Windows, Mac, even web (via NativeClient). I posted an AskHN about this earlier today (though not much interest). That sounds like a win.
- bratsche 14y agoInterestingly enough, you can also run C# on NativeClient via Mono.
- cageface 14y agoIt's ironic, but C++ does seem to be the best language to write portable code in right now. C is just too low level and everything else is either too slow or tied to one platform.
- cantankerous 14y ago
- kamechan 14y agonot sure that C# is the answer either, given that microsoft is trying to build a nest in the mobile space. that said, nice work. poses an interesting question though: if google had to or wanted to switch platforms/languages, which might they choose?
- untog 14y agoThe article covers that, to some extent: Unlike Sun with Java, Microsoft submitted C# and the .NET VM for standardization to ECMA and saw those standards graduated all the way to ISO strong patent commitments. The .NET framework is also covered by Microsoft’s legally binding community promise. It's strange- with the work Xamarind has been doing, C# is one of the few language choices you have to go cross-platform and native- MonoTouch does iOS, MonoDroid does Android, and MS themselves do Windows Phone. I've not used any of these extensively so can't vouch for them, but it's an interesting development.
- edwinnathaniel 14y agoI was reading the wikipedia entry about C# a few days ago and was surprised to see the following bits: "As of December 2010, no ECMA and ISO/IEC specifications exist for C# 3.0 4.0, and 5.0." http://en.wikipedia.org/wiki/C_Sharp_(programming_language) http://en.wikipedia.org/wiki/C_Sharp_(programming_language) Does this mean newer syntax updates won't make it to Mono? or not as open as it used to be in terms of patent and copyright?
- migueldeicaza 14y agoStandards take time, the ISO spec is typically 2-3 years behind the current product. But cheer up, the ECMA team just updated the VM spec a couple of months ago and the committee is resuming work on new features. We are all pretty psyched about the next steps for the ECMA standards. As for Mono, we already have C# 5 and many of the new class library features. Having two independent implementations helps coming up with a better standard.
- 14y ago
- revelation 14y agoI guess Google did make the wrong choice back then. I certainly prefer C# over Java any day, even by the most basic test like "language features". Using Mono would've certainly resulted in _less_ fragmentation than they have with Dalvik today.
- mdwrigh2 14y ago> Using Mono would've certainly resulted in _less_ fragmentation than they have with Dalvik today Why would using Mono result in less fragmentation? Most of their "fragmentation problem" comes from having developers having to develop for multiple devices (screen size, performance, GPU, android versions, etc.), and changing the language won't magically fix it.
- revelation 14y agoNot that kind of fragmentation; sorry, given that the phenomena runs rampart in Android world, I should have been clearer. SUN and Google have both expressed concerns over fragmenting the Java ecosystem. And with Dalvik, that has certainly happened.
- mdwrigh2 14y agoAh, that makes much more sense. Having said that, where do you see fragmentation in the Java ecosystem? I don't use Java to write anything but Android apps, but I've used a few pure Java libs with Android and they all seem to work great. That isn't to say it isn't happening, I just don't experience and would be interested in knowing where it does occur.
- kefs 14y ago> 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. That should be bolded.
- ch0wn 14y agoTotally! If Google would actually dump Java in favor of C#, there would be the huge problem of all the apps that need to be ported. With a tool that has already proven to be capable of doing that, the required efforts are already massively reduced.
- j_s 14y agoI am curious about Sharpen, the automated translation tool used to convert from Java to C#. It seems like every project that uses it winds up with its own tweaks that have no centralized location to be upstreamed to. For example, Sharpen was also used to translate JGit to C#: https://github.com/mono/ngit https://github.com/mono/ngit
- migueldeicaza 14y agoThe history right now is: Original Sharpen -> mono/ngit sharpen -> XobotOS sharpen So the XobotOS one is the most complete, but also requires more setup than the NGit one.
- deleted 14y ago[deleted]
- biafra 14y agoDo I need to install Windows to do MonoTouch development for Android?
- darrenkopp 14y agono, you can use monodevelop on osx to develop mono for android applications.
- zanny 14y agoOr use monodevelop on anything, it is cross platform and open source from Xaramin.
- lucian1900 14y agoBut for some reason you can't do MonoDroid development on Linux. I can't even have a look at the trial version.
- cageface 14y agoThe other thing that's holding me back on Mono for mobile is that it really only addresses the non-UI parts of an app and in most apps the UI code is 80-90% of the entire codebase. So rewriting some core logic and network code in a portable language isn't really enough of a win to justify using working with an unsupported (by Apple) and niche tool.
- noveltyaccount 14y ago> in most apps the UI code is 80-90% of the entire codebase Not in my experience. I write software for large enterprises, mostly .NET glue between systems like SAP, e-commerce engines, search engines, databases, etc. The UI is a thin little layer on top of complex systems integrations. I'd say the UI code is 10 to 20% in most systems I've worked on.
- cageface 14y agoI'm talking specifically about mobile apps here. Most don't involve sophisticated processing or logic but need a very slick, polished UI.
- HardyLeung 14y agoI think both of you are right. To each his own. I have a few applications that are algorithmically complicated and it is impossible (or very expensive) to implement multiple versions of the same thing on different platforms. Even though the core stuff is say 60% of the codebase (vs 40% in UI), say measuring in number of lines, the benefit of doing the 60% in a single productive platform is very very important. I'm talking about correctness, maintainability, consistency between different versions, etc. The remaining 40% UI code can be ugly, platform-dependent, inconsistent, etc, and it won't bother me as much. After all, an error in the presentation is far less lethal than an error in the core logic. In this case, a common platform is strongly favored. That said, indeed many apps are not like that. Going forward though, I would conjecture that there will be more and more sophisticated apps.
- noveltyaccount 14y ago
- b0sk 14y agoHow long till Google buys Xamarin?
- sreque 14y agoI like .NET and I like Mono, but I was disappointed that the article showed no hard evidence of overall performance improvement for XobotOS vs Android. I understand that they probably have more important things to work on, but I hoped that if they could show concrete benefits even at this early stage then their work might pick up more traction. It was a fun idea to read about, at least.
- jeswin 14y agoWow! Congrats. Isn't this like huge, though? If you can actually make it run faster, I am guessing it would be possible to spin it off and get serious funding. I merely watch from the sidelines, but what the Mono/Xamarin guys accomplish year after year could be a good lesson for any founder. Having spent enough time in the .Net world, I can tell that any attempt at creating a compatible .Net framework is a daunting, enormous undertaking. I guess the key thing is, FOCUS.
- zanny 14y agoI would really love for Mono to take off in a big way, I like the language features and syntax of C# more than Java, but when I have to work with other developers it is nice not to have to worry about major memory leaks across the system. And the patent wars regarding Java just make me not want to support that development ecosystem anymore.
- sll 14y agoWhy would anybody be interested in a MS-only language in this day and age (when MS is in decline)?
- amorphid 14y agoMicrosoft's sales and profits continue to grow. How is that a company in decline?
- hhrvoje 14y agoWe should bail out of some lang as soon they loose first dollar? And MS is not loosing any dollars yet. Dev ecosystem and market are quite healthy, even I'd like to see more small (web, startups) projects out there.
- pixie_ 14y agoThey should wrap up the whole working build environment in a VM, and distribute that, so people can start contributing immediately.
- daniel_solano 14y agoThis is really interesting project, and after taking a little bit of time to look it over, there are a couple of things that I have noticed: 1. It's not entirely clear how to use this. Is XobotOS a replacement for Android, or is it something that can be shipped as a standard application? In my limited time reading the documentation on the GitHub page, this was not clear to me. 2. It looks like a it is a terminated research project, to quote the README: This code is provided as-is, and we do not offer support for any bits of code here, nor does Xamarin plan on continuing evolving XobotOS at this point. From the blog post, it sounds like they are integrating some of this technology in their products, but XobotOS is otherwise just a code dump. As such, unless someone is really interested in this, it doesn't seem like it's going to go anywhere.
- Mordor 14y agoC# created because Sun didn't like Microsoft. Not at all surprising if Google drops Java.