I want to make a project for the summer where I want to create an Android app. Now my question is for those who have used Xamarin before to create Android apps:
Is it better to create Android apps with Java than in C# with Xamarin?
Are there any restrictions with usin Xamarin for Android app development?
I.e. are there some things that I can do in Java but not in Xamarin?
And last, what do you think about Xamarin for a pretty new programmer?
You specifically asked to:
create an android app
If that is your only requirement, and you have no previous experience in C# development, you should stick to developing the application using JAVA and Android SDKs. After all, it is free of charge.
However,
Why do you want to limit yourself to Android platforms?
If there is a chance that you might want to expand to other platforms in the future, you should IMHO start preparing for it right now, and create a cross-platform application.
C# is a powerful language, Xamarin products are mature and of high quality and Xamarin community is big enough for wide support.
There are no restrictions that I know of, and everything that you can do with native Java you can also achieve with Xamarin.Android. Also, in case you will ever find any restriction, you can always include Native Java Code inside your application.
The only thing to mind is the price, which is probably high for a beginner developer.
An additional feature which is in C# but is omitted in Java is LINQ which gives significant assistance to data handing and sorting.
The main factor to consider is as Liel has already said your preference of programming Language, Java or C#, go with which you are more comfortable with. The only hesitation which I would mention when referring someone to Xamarin as opposed to Java is that their is significantly tutorials out their.
This in my view though should become less of an issue in time. The main source which I use when I am learning is AppDev and Pluralsight Training DVDs and have found them to be essential in learning.
It is possible to simply refer to Java sources the only manipulation sometimes needed is to capitalize the first character setContentView() => SetContentView() in C#, and then using Intelisence to find the correct syntax Resource instead of R in Java.
Good luck with whatever you choose,
James
Related
So, one of the main features of coding using the native SDK provided by Android and iOS is the fact that you get not only a better performance, but also the look and feel of each platform: for example, on iOS, a tab-navigation bar would be located at the bottom of the screen, while in Android it is located at the top (yeah I know it also can be top and bottom, but you get my point), or also the Navigation Drawer dock is an Android navigation style while (as far as I know) there is nothing similar in iOS native sdk. My point being, you can feel the difference of platforms by their design guidelines which is a good thing, since it makes your app looks professional.
So taking that into account, in terms of performance and maintaining the feeling of your app, using JS-based frameworks like Titanium or PhoneGap will not make a wise choice.
Then comes Xamarin. As I read in here: Xamarin how it is getting the Native Look and Feel? it seems it is a C# wrapper for native SDK, which as far as I understand, it should not affect performance. But where's the look and feel part. Since XML layouts are not entirely what gives Android or iOS apps their feel, but also the navigation (which comes from the controller classes) how does Xamarin deals with these? It is said in their website that you can share code between platform, but will that also means I have to share navigation system and similar?
Finally, for the sake of "not writing code for each platform" , is it worth NOT to use native SDK and go with Xamarin (I don't really have a problem writing code for both iOS and Android), or is this framework target for C# developers so they won't have to learn Objective-C or Android.
Any extra explanation would be awesome, and thanks in advance.
I built a large application within the last year (2013) with different components: mainly an API (ASP.NET Web API => C#), a Website (ASP.NET MVC => C# + AngularJS), and both an app for Android (Xamarin.Android => C#) and iOS (Xamarin.iOS => C#). The decision to use Xamarin had its advantages and its disadvantages, but all in all I am more than happy with it.
As you can see in my list above, almost everything was done with C# (okay, the Website is mainly written in JavaScript ;-)). It's a wonderful mature language with really nice features (as LINQ). In my scenario it becomes clear: I did not have to learn and to perfect four languages (Swift/Objective-C, Java, C#, JavaScript) but only two: C# and JavaScript.
That comes especially into play regarding the code sharing aspect: our client applications aren't really thin clients because of some offline functionality which requires a lot of synchronization logic, so the UI part of the two apps is only one side of the medal. As it turned out, I could really use 90% of that non-interface code on both iOS and Android. This is an incredibly huge benefit, as it's not only about some language originalities of Swift/Objective-C or Java, but also about the different frameworks you are using on iOS and Android. To use the .NET Framework/Mono as foundation of every Xamarin app enables you to abstract things like data access or network communication from the underlaying OS.
In terms of speed and UI you don't have any disadvantages, because you're using the native APIs 1:1. Whatever is available on iOS or Android is also available through Xamarin. And whenever Apple for example ships a new version of iOS, Xamarin will ship the update for that within a few days, so you don't have to wait to be able to use newly introduced features by Apple.
Xamarin uses a technique called Ahead of Time Compiling on iOS, so everything you write in C# is compiled into the native iOS stuff before it is deployed to your device. That means there is no difference in what is executed between a "native" Objectice-C application and a Xamarin application (except some small overhead which isn't noteworthy from my experiences).
On Android Just in Time compilation is used as just with any other "native" Android app, too.
That all means you have all the exact same APIs and possibilities you would otherwise have, if you would go with Objective-C or Java. You even use the same objects for building your UI with the exact same types and names (sometimes slightly optimized ;)). So if you want a tab bar navigation for your app - you use a UITabBarController for that. See iOS vs. Xamarin.
After multiple years on my way with Xamarin I only one disadvantage:
Possible memory leaks. Their whole samples out there are a bunch of crap regarding essential basics of preventing memory leaks. If you are working with "expensive resources" like media files within your application, you should take care from day one. I had to get rid of all that problems when an app of mine had already been growing to up to 35 different (complex) dialogs. That took me almost two months or in other words thousands of bucks. They provide some documentation about it, but the tooling is poor at this end. And errors are likely to appear and very hard to be found (example).
But all in all it was one of my best decisions to go with Xamarin.
I have been coding with Xamarin for a while now. Its been great so far. Any problems I've had I figured it out because c# is my native language. The Xamarin site has many examples and API references for many features on all platforms.
Performance - You get native performance from using Xamarin. No questions asked. I have been using it to create audio, video and photo recording features for a new app i'm working on. Xamarin processes the c# code into native byte code for all platforms. Thats how this is achieved.
Look - The look of your app will be native. You literally have to use the Android xml format to make your user interface and the same Goes for IOS. You will still style your elements the same way you did on each platform. All Xamarin does is link a view to an event for you.
Api - The beauty of Xamarin is in the API. They ported the whole Android and IOS namespace to c#. Take a look at their Documentation.
Expensive - My only problem with Xamarin is that it is expensive. If you check their pricing it is outrageous. But you get what you pay for. A premium product that is backed by support.
C# - Sharp is a great language that has loads of support. The new async/await gets ride of the whole thread management issue. Json processing is super easy on the platform. I have uploaded several classes on Github that can be used for many apps.
If you are from a java background, brushing up on your c# skills will be a breeze.
The rdio app was created with Xamarin. Download it on Android and IOS and test its performance and enjoy its native look.
Best of Luck
There is much much more internet content, help, and support for native. That alone helps me make my choice. If you are really good at Xamerin, maybe 70% of the code you write will be usable by both apps, you still have to custom tailor things for each app.
But again, the support for native is so vast, that if you run into a proble, so has someone else.
With xamerin, well, good luck.
When I say app I mean iOS/Android
I've used C# quite a lot, it was my main programming language during University and I wondered which of the two languages for developing for Android or iPhone are easiest to learn bearing that in mind.
I'm interested in people's opinions on the two languages, I've dabbled a little in both but nothing more than a couple of hours. I'm also interested in people's opinions on Windows Phone 7 as an app/game platform, as this uses C# so would be an obvious choice for transitioning into that area.
Opinions?
That would be Java but you will miss LINQ a lot.
You can develop in C# for the iPhone with MonoTouch but it's not free and you'll never know if Apple sends them out in the cold (unlikely). Soon you can even use C# for Android development with MonoDroid but I kind of feel that that's a smaller win for a C# programmer than not having to learn Objective-C. Java and C# are so close that the transition most probably will be smooth.
As a C# programmer I think that the Windows Phone 7 development platform looks very promising but my experience tells me to wait and see. Microsoft has a terrible track record in the mobile business and they also have a tendency to make big changes between early releases.
Java I think. The semantic model for C# is closer, and ObjectiveC for iPhone apparently is not garbage collected. You will probably miss some of the features of C#, but most people get over it.
Your choice of language will depend on your motives. If you intend to write commercial software that you want to sell, it's probably best to go for Objective-C and aim at the iPhone/iPod Touch/iPad. Objective-C is a steeper learning curve for a C# programmer than Java but that is as nothing compared with actually thinking up an app that people will want to buy and getting it to commercial quality. And people who own iDevices are still more numerous than people with Android devices and they probably have more expectation of having to pay for apps.
If you are doing it as a hobby then you will want to choose whichever platform your current smartphone/tablet or whatever supports. You are going to be the primary user of your apps. It makes sense to develop apps that you can use. Another consideration, if you are a hobbyist: to develop an iPhone app you need an Intel Macintosh and a $99 Apple electronic certificate to deploy apps to an iPhone even for testing.
The actual language is a relatively minor consideration. A reasonably competent programmer can pick up Objective-C in a couple of weeks. The frameworks will take a little longer, but if you are doing it as a learning experience, it will be a more rewarding experience than learning Java which is nearly the same as C# by comparison.
I have a co-worker who made an attempt to learn Objective C to do I-phone development. We are both .Net developers working mostly in C#. He had a very long learning curve and finally abandoned trying to learn Objective C not only because of the language barrier but also because of the setup. Coming from a C# background, expect a long haul getting your arms around Objective C. Java on the other hand is more like C# and might be better to start with. I am in the same boat as you and actually decided on Windows Phone 7 development first because it is C#. I would go after the droid market next as I think it would be easier to learn.
I know this has been said before, I figured I would point out a fact, C# came about because of the law suit surrouding Microsoft's Java Virtual Machine. I would describe C# as the son of Java and C++, at least in early versions. C# 4.0 has added features neither of them have, its really matured into its own language.
So if you come from a C# background then you should be able to pick up Java effortlessly. Of course Objective-C is C++ on crack, so it should still be possible, what you will miss is Visual Studio and all the features it brings. The reason C# is so easy to develop for is all the features in Visual Studio and most of the features of the language are supported.
As you can see, C# is partially based on Java, so that step would be a lot easier.
I'm also familiar with Java, C# and ObjC and started out with C#, then did Java and now use Objective-C..
And the C# -> Java part was because my education did it that way.. ;-)
And because WEBAPPS are a thing that is HOT right now.. i would say.. Java is a safer choice, because you could base a webapp on that.. although ObjC might also have those possibilities, i just don't know about it..
I switched from C# to Java because I needed to code a lot of systems integration. C# was just not powerful enough / limited to .NET systems. I agree that LINQ is a nice feature, and that generics in C# are a lot more straightforward, but if you start looking at the whole Java ecosystem, I guess these are just minor losses.
Just to sum up some great things you get when switching to Java: Eclipse IDE, maven build system, Spring dependency injection and aspect oriented programming framework + OSGi, GlassFish application server, Grizzly, Jetty, Hadoop, the apache commons libraries, ... . All these things come in Java, and are very useful when you start programming services.
I don't know about Objective-C
Hope this helps,
J.
Have you considered using MonoTouch?
I've decided to start writing an iPhone app and coming from a c# background, I thought I'd start developing it with mono.
Though this question may be subjective, I'd love some guidance from you.
Is it safe to develop my app using this technology, or should I buy some books and start learning objective C?
I know Adobe were going to release a feature that allows you to build iPhone apps using Flash CS5, but this didn't last long.
I appreciate your feedback.
Marko
Monotouch is doing a great job of keeping up to date (usually within 24 hours of api updates) so just saying you have no idea about xyz but you know abc is much better than it is a bit silly. Monotouch has some serious advantages over obj c - for instance obj c has only been updated something like twice in the last twenty years!! expect good XML, regex, Http support? Think again. Linq in Obj c? never. Good OS community? Not likely. There's plenty of reasons to use MT, aside from C# being a far superior language. Being able to re-use a good percentage of your code in MonoDroid is one. Though there is word that apple are creating a new language - I'm not holding out too much hope for it. We'll see I guess.
I learned Obj C before getting into MT and the reason I went with MT is that using Obj C is like stepping back into the 90s. It just doesn't have any modern language features and is too far behind the curve. Create your bleeding edge apps with their archaic langauge? Thanks but no thanks.
None of us except people who work very closely with the OS and the App store policy in Apple would know whether it is "safe" to develop apps using this technology. Apple can say no anytime in the future, but we don't know. What we know is that all the compiled code has to be in C, C++, or Obj-C. However there's one catch: In some cases you can run interpreted languages.
If I were you, I'd go with Objective-C. We know that Apple supports it fully, it's been in there for almost 20 years. It's not that hard to learn since you know C#. I came from C++/C and it took me about a month or so to learn half of the frameworks. There are many other frameworks which I didn't learn because they're not applicable in my apps (such as accelerators, GPS, OpenGL ES, etc). You probably can get away with this too.
Once again, there's also another way: build it with HTML5. However that way you'd have to consider what your app'll do when it's opened with Safari desktop, Firefox, IE, etc.
The iPhone dev agreement is pretty clear that C# is not an accepted technology for developing iPhone apps. Regardless, Monotouch apps have still been accepted to the app store to date without any problems. My suggestion is to keep in touch with the Monotouch forums to see what their stance is on this issue and make your decision based on that. The long term safe bet is to go learn Objective-C.
Recently Apple changed the clause relating to the third party development tools now stating that if you have prior approval you can use them. I haven't seen any official word that Mono will be allowed though.
If you are coming from a c# background I would highly recommend learning Obj-C because it always helps knowing another language and you could pick it up reasonably easily. Have a look at the stanford University iPhone lectures, they were the best resource when I was learning.
Although I haven't personally used C# or Mono, the iOS SDK once you get to know it has some really great work behind it making it both easy and powerful once you get used to it and I would be surprised if Mono took advantage of it all.
I think it's important to learn the language the frameworks for your platform of choice were written in. Then you can understand more why the frameworks are the way they are, and often anticipate behavior or API calls just based on knowing what is typical for the language and framework.
On top of that there is now a ton of support for blocks across the API (iOS4 and on only), which may take some time to be incorporated into MonoTouch. Overlay frameworks are always a step behind the base platform so it's nicer to be using the frameworks directly.
It's now been months since the Flash debacle and Monotouch and Unity are still rocking along.
As developers in a .NET shop we're looking at expanding into iOS development. After prototyping some fairly basic stuff in Objective-C, We're 100% committed to using Monotouch, it's worth every penny.
I’d like to develop an application with a complex GUI (combobox with animation, charts with spline, transparent layers, …). I have good experience with C# 2.0 and I’m studying WPF, but I read that, unfortunately, there is no plan to port WPF to Mono.
If I stick with C# and create custom GUI controls using OpenGL (via OpenTK), I feel it will be a hard work (integration with GTK#, debugging, hard to use to design forms).
I can use Java (with JOGL), but I’m not very skilled with it, and I don’t know about performance issues.
Last option is C++, but I have to do a big revision (years since last time I used it), and I find it hard to develop GUI and portable applications in C++. (Maybe I’m wrong! Still, I’m quite afraid to develop such complex application with this language.)
What is your advice? Had I better choose C# + OpenTK, Java + JOGL, or return to C++?
I would go with Qt. Take a look at http://qt.nokia.com/products/ . If you are afraid of C++ (but there is no reason to be afraid of it), you can try with Java Swing. I think that those are the best options to go with multi platform desktop GUI development.
I would suggest Mono and GTK#. Developing apps with .Net is far more effective than doing it in C++ vanilla. Sure, you have to stick with C# 3.0 and .Net 2.0 (some features from 3.5 is implemented, like LINQ). But it still gives you a lot more than C++ with, for instance QT, would give you.
Go C# for productivity. Nothing against C++ but it's a bit verbose.
As for the GUI library, I think WinForms used to work on Mono. Alternatively, GTK#.
I would not suggest using wpf for it is a platform dependant platform. Silverlight might be a better option.
But if you are developing a web application, jquery would be a nice option you also might consider adobe flex and adobe air; http://www.adobe.com/products/air/
Does multi-platform have to include iDevices? Can it be on the web? Those are 2 questions you have to answer first.
If you can live without iPad/iPhone suppport, then Flex/Flash/Air is good option for highly graphical things. It is multi-platform for sure and easily integrates to the web. Probably your best option for this case with the limited details given.
Qt could work for you as well, although I can't say for sure if it's graphic library will make it easy. I've personally never worked with it, so other would have to answer that. But since it is in C++, you could use other libraries as well.
Java Swing sounds rough to me for this complex of a GUI. Making some basic stuff isn't too bad, but if you are expecting an experience like with C# I think you will be frustrated. Just a personal opinion of course.
Lastly, if it can be a web app, why not stick with C# and Silverlight? A .NET solution may work well for you since you are already learning it.
Silverlight runs on Windows/Mac/Linux and some handhelds, and is being ported to more handhelds. I believe Silverlight will ultimately be ported to every popular device.
Silverlight is:
Much, much more powerful than Flex/Flash/Air.
Much, much more powerful than Qt.
Ridiculously more powerful than GTK+ or GTK#.
Ridiculously more powerful than JOGL.
Silverlight has all of the features you have requested.
Silverlight works very well with C#, which is a much more productive language to work in than C++.
Silverlight is basically a very large subset of WPF, so if you already know WPF, you already know Silverlight.
Unless you absolutely require iPhone/iPad support I think the decision is perfectly obvious.
See this comparison of WPF and Cocoa to get some feeling of how WPF/Silverlight compares with the likes of Qt, Flash/Flex/Air, and GTK#, all of which use a primitive WinForms-like object model similar to the one used by Cocoa.
At my day job (a well-known microprocessor company) we develop complex engineering apps with Java, Eclipse RCP, and Java OpenGL. Performance is good -- we can easily get many millions of polygons/second and up to 100 frames/second. The SWT widgets in Eclipse are fast enough where we haven't had to render any custom controls with JOGL.
I've got a set of tutorials that shows how to get started with this kind of programming. The series starts with http://wadeawalker.wordpress.com/2010/10/09/tutorial-a-cross-platform-workbench-program-using-java-opengl-and-eclipse/.
First, don’t use C# for anything that should be portable. Mono is a bad option for GUI for two reasons:
Mono goes always several steps behind .NET.
Mono does not support WPF, so the only way to develop GUI is using something like GTK#.
My personal opinion – use C++. It would give you very good portability and independence.
You have two options:
Qt4 – very good GUI toolkit, makes GUI development very easy, and highly portable.
GTKmm – also very good toolkit, but it feels less natural on Windows.
Also, Java has Swing toolkit that comes with JDK and is available on all Java platforms, even very strange ones like OpenVMS.
Greeting,
I'm a C# programmer guy. I'm planning to start developing app for iphone but I'm not sure if I should use C# under MonoTouch or just use the native language for iphone OS Objective C.
Is there a different to program for iphone app using C# or Objective C?
Is there limitation using C# to program app for iphone or it can do as much as Objective C can do to develop iphone app?
MonoTouch wraps most but not all of the iPhone SDK. So, yes there are things you can't do (yet), but they're relatively few and far between.
Many .Net folks find that they are more productive (at least initially) using MonoTouch, since they can leverage their existing skills. On the other hand, there's nothing like working in the native language of the land, it just takes a little longer. You will have to learn some Objective-C since most documentation out there in the world uses it (and/or C-level CoreFoundation APIs). Objective-C's dynamic nature will feel foreign at first, but you may find it quite liberating once you grok it fully. Having used many languages in my career, I find Objective-C (and the Cocoa APIs) one of the most pleasant development experiences out there.
Here's a Monotouch developer's answer rather than some guess work from people skim reading blogs.
Have you bought the Monotouch license? If not then clearly objective-C would be preferred. If you have bought a license then it makes sense to develop the app in Monotouch because:
The domain and business logic can easily be ported for a Windows Mobile 7 app later this year
The same is also the case for Monodroid which is coming soon, and the API could easily be ported to Java too.
Controllers, Views and the whole Monotouch system bar static void main can be very easily converted to objective-C. The names are all identical but in Pascal case.
As far as apps being accepted - so far Apple have let Monotouch apps through. I'm not saying they won't suddenly say "NO! THOU SHALL USE OBJECTIVE-C" but for them to ban an SO iPhone client on a high profile site like Stackoverflow would be bad PR.
Apple use apps in their demos which break their own SDK (Tap Tap Revolution being one), and 1 in 10 of the appstore best selling games use a health portion of none-objective-C.
Monotouch is a direct mapping to Cocoa and UIKit. You need to have a mac to use the compiler and IDE. As far as I'm aware Flash had no such restrictions and its UI was a lot less strict in terms of forcing the common "widget" set like UINavigationController, UITabViewController, UIAlertView and so on.
Here's my take: if you have absolutely never seen Obj-C code in your life, it'll take a bit of a time to get used to it. Put it together with the fact that the SDK is totally different and you'll have to learn every single new method, and it'll probably take at least a couple of months for you to become an average obj-c developer if you study hard.
Instead, use MonoTouch and learn the entire SDK using C#. In a couple weeks, you'll feel right at home with all the classes, Interface Builder, etc. You'll be able to develop the app in the same way you would with Obj-C, but in C#. The demo version allows you to use everything, for free.
THEN you decide what to do. Depending on how the whole issue with Apple goes, you may decide to just continue using MonoTouch, or you may decide to learn Obj-C, and basically use all the knowledge you have already gained about the SDK, which will make the transition much easier.
There is some debate over whether Apple will allow this. On the face of it, it seems not:
In the new version of the iPhone
Developer Program License Agreement
released by Apple today (and which
developers must agree to before
downloading the 4.0 SDK beta), section
3.3.1 now reads:
3.3.1 — Applications may only use Documented APIs in the manner
prescribed by Apple and must not use
or call any private APIs. Applications
must be originally written in
Objective-C, C, C++, or JavaScript as
executed by the iPhone OS WebKit
engine, and only code written in C,
C++, and Objective-C may compile and
directly link against the Documented
APIs (e.g., Applications that link to
Documented APIs through an
intermediary translation or
compatibility layer or tool are
prohibited).
From monotouch forums