Developing on Apple (new platform) - c#

Coming from a Microsoft development backgroup I am a bit confused as to what development languages/environments are available on an Mac. Are there any C# like languages to develop with on the Mac other than Java that I should also consider? What do MS to OSX converts prefer and why? I am after a business level programming strategy and not gaming or graphics so application performance is not the overall driver for my choice of platform.

Objective-C with the Cocoa API is the way to go. Once you have those down, there's also bridges between Ruby and Python to the Cocoa API. I'd highly recommend initially learning the Cocoa API with Objective-C first, though.

I also just bought a Mac and come from a .NET development background. I tried a bunch of different languages and environments. If you're going to write OS X desktop software, you're going to need to use Cocoa and Interface Builder. IB doesn't have a Windows counterpart because it's so heavily tied into Cocoa. This means you're going to need to learn Cocoa simultaneously, and it's not easy to do by looking at code.
Objective-C is the native language of the Mac and it's not as refined as C#. It takes a while before you can read it fluently because calling functions looks different. Using Python or Ruby instead of Objective-C only adds a layer of complexity until you learn Cocoa, but it seems quite viable after that. C# via Mono works fine, but I don't think the whole Cocoa# bridge is implemented. The C# tools are a lot lower quality than Visual Studio, and MonoDevelop is extremely ugly on the Mac. I decided that if I want to go this route then I need to learn Objective-C, but went a different direction.
If you're writing a web site then you have a lot more flexibility. The entire Python and Ruby cultures are available, although there are some hiccups with installing some Python libraries. This is the route I took because I had some basic Python experience and the skills are almost 100% compatible with Linux. iTerm is a better client than Terminal. I didn't like most of the code editors I tried, and started with Smultron which isn't much more than a very competent text editor with syntax highlighting. There are definitely tons of options.
No matter how you approach it, you're going to spend a lot of time learning. I have constantly stumbled over Python syntax but I'm finally getting good at it. The SQLAlchemy (Python ORM) docs almost always have an open browser window. I also bit the bullet and started using Vim (MacVim specifically), which is actually a fun thing to learn because there always seems to be another command that does exactly what you want. (For example, I got tired of going to a line, hitting $ to go to the end, hitting a to append, then hit enter to start a new line so I Googled and found out I can just hit o.)

Have a look at the Mono project
Quote from wikipedia
Mono is a project led by Novell (formerly by Ximian) to create an Ecma standard compliant, .NET-compatible set of tools, including among others a C# compiler and a Common Language Runtime. Mono can be run on Linux, BSD, UNIX, Mac OS X, Solaris and Windows operating systems.
But I really recommend go the Cocoa route and get Aaron Hillegass book "Cocoa Programming for Mac OS X"

Objective-C, C, C++, Java, Ruby, Python, Php, ... There are lots of choices of languages/development environments to use, including C# via Mono as #epatel says. I would say that the choice of language depends more on what you are developing than on what platform you are coming from.

Objective-C and Cocoa is the way to go for sure. Quite often devs will make the misconception that Objective-c isn't "as detailed", or "as fine tuned". But I can assure you, it's the power house behind some of the best apps in the business. There is a noticeable learning curve.

On a related note,
Silverlight is a web-based "flash-like" technology supported on Windows and Mac and you can code in most .net languages.

C# is available for OS X, as long as you're willing to use Mono. For non-UI and web stuff it ought to work just fine.
For desktop app development, I use REALbasic. It's syntax and object model are very similar to Visual Basic.
For business-level programming, I'm not sure if Cocoa/Objective-C will be the most productive thing to start with; it's quite different than .NET and/or Java.

I would forget mono, it doesn't work very well. Slow, buggy and system.drawing/forms don't work properly when you distribute.
With c# I would go with monomac. You access all the mac apis but in c#. It's like a half way house. Instead of Forms you use NSWindow and instead of controls you use NSView. Instead of drawing you use graphics context. The downside is the documentation is a bit thin and it costs.

Related

Which is easier to learn coming from a C# background: Objective C or Java?

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?

MonoTouch, the future of MonoTouch and whether I should use it for iPhone apps (instead of objective-C)

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.

Writing cross-platform application with a complex GUI

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.

MonoTouch & C# VS Objective C for iphone app

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

Making a C#/Winform application cross-platform - should I use AIR, Mono, or something else?

I have an app that I've written in C#/WinForms (my little app). To make it cross-platform, I'm thinking of redoing it in Adobe AIR. Are there any arguments in favor of WinForms as a cross-platform app? Is there a cross-platform future for Winforms (e.g., Mono, etc.)? Suggestions for cross-platform UI development?
By cross-platform I mean, currently, Mac OSX, Windows and Linux.
This question was asked again and answered with better success.
As far as my experience in Flex/AIR/Flash actionscripting goes, Adobe AIR development environment and coding/debugging toolsets are far inferior to the Visual Studio and .NET SDK as of the moment. The UI toolsets are superior though.
But as you already have a working C# code, porting it to ActionScript might requires a redesign due to ActionScript having a different way of thinking/programming, they use different primitive data types, for example, they use just a Number instead of int float double etc. and the debugging tools are quiet lacking compared to VS IMO.
And I heard that Mono's GtkSharp is quiet a decent platform.
But if you don't mind the coding/debugging tooling problems, then AIR is a great platform. I like how Adobe integrates the Flash experience into it e.g. you can start an installation of AIR application via a button click in a flash movieclip, that kind of integration.
I'm thinking of redoing it in Adobe AIR
Not having spent much time with AIR, my personal opinion is that it is best for bringing a webapp to the desktop and provide a shell to it or run your existing flash/flex project on the desktop.
Btw, if you don't know ActionScript, I mean its details, quirks, etc, don't forget to factor in the time it will take googling for answers.
Are there any arguments in favor of WinForms as a cross-platform app?
Is there a cross-platform future for Winforms (e.g., Mono, etc.)?
It's always hard to predict what will happen, but there is at least one project (Plastic SCM) I know of which uses Mono Winforms on Win, Mac and Linux, so it is certainly doable. However, they say they built most of their controls from the ground up (and claim they want to release them as open source, but not sure if or when), so you will need to put in some work to make things look "pretty".
I played with Winforms on non-windows platforms and unfortunately, it isn't exactly "mature" (especially on Mac). So what you get out of the box may or may not be sufficient for your needs.
If you decide a desktop app is not the best way to provide a cross-platform solution, you can always take your business logic written in C# and create either a full-blown webapp with ASP.NET or go with Silverlight, so many other options exist with C#.
WinForms are fully supported by Mono, so they are cross-platform.
Why would you go with Air?
Use GTK#, and you have a cross platform forms engine and you get to keep your C# code.
Well I think the only way to for cross-platform reliably with C# is Microsoft Silverlight, but is not really WinForms, and browser-based. Other than that, yes Mono is a chance.
If you want to use the .net Framework, Microsoft Silverlight is a good (the only?) choice. The browser does a good job as a shell, but you could also write your own application shell for it. For example, Scott Handelman mentions the NY Times Reader written in Silverlight and hostet on Cocoa on a Mac.
I don't think there is a future for WinForms at all. Since it appears to have been a stop-gap solution even in MSFT world ( a very thin wrapper around Win32). And virtually no changes seem to have been made to System.Windows.Forms in both .NET 3.0 and 3.5
</speculation>
I would use Java or Air.
I think that as long as you make sure that the business logic code you write is cross-platform (i.e. using backslashes in paths only works on Windows - forward slashes works on all OS's), then Mono shouldn't have major problems running an unmodified WinForms program. Just make sure you test for graphical glitches.
I asked a similar question last week. I've been using Mono all along, and have had no issues running the applications I compile to IL to run on SuSE linux (I usually run KDE) or windows, however, I've not gone out and got a mac yet to test it on. I will be soon, though, probably with in a couple weeks. But all and all development in Mono has been very good at creating application that will run on multiple platforms.

Categories

Resources