I recently was asked to teach a guest lecture for a class in C#. Only one catch: my laptop was a Mac.
Of course, this day and age, there are plenty of options for running Windows on a Mac. Some magazines have gone so far as to declare that Macs are the best Windows laptops. However, I wasn’t interested in using virtualization or dual-booting to achieve my end goal – not least of which because I’d be required to buy a Windows license (and possibly a Visual Studio license). Rather than focusing on running Windows on my machine, I decided to see if it was possible to do some stuff Mac-native.
Microsoft has some instructions for getting .NET Core (their open source .NET libraries) running on a Mac. This approach is pretty interesting, because Microsoft is even going so far as supporting the deployment of these kinds of applications to servers running operating systems other than their own – however, it doesn’t mimic the workflow of your typical .NET developer.
I then checked out Visual Studio Code, Microsoft’s free/open source text editor, thinking this might be a step closer to the typical Visual Studio experience. While it’s closer to real VS than using Atom + Terminal, it’s still pretty different. It only supports opening certain types of projects (.NET Core specifically), and the interface itself is quite different.
At this point I was nearly resigned to buying Windows and running it in a VM, but then I happened across MonoDevelop. Mono is an open source platform based on .NET. I think Mono:.NET is like GNU/Linux:Unix – it’s designed to mimic the functionality as much as possible, while remaining completely free/open source.
Although it is open source, MonoDevelop is most easily installable as part of Xamarin Studio. Studio is a tool intended for cross platform development, and as such it includes plugins for Android/iOS development. I believe these plugins are not free, but downloading Xamarin Studio itself, including MonoDevelop, is.
Once I got Xamarin Studio downloaded and installed, I found it very similar to Visual Studio (although Mac-like in appearance). There are preferences that let you make it act like Visual Studio as far as code formatting, syntax highlighting, and shortcut keys are concerned. It can natively open
*.csproj files. I was able to take a project created by another instructor using Visual Studio, and run it just after updating the project to point to the version of the .NET Runtime I had installed on my machine.
The lesson I was teaching revolved around exception handling. As is my usual teaching style, I built a project driven primarily by the students, and everything went off without a hitch! Xamarin even has nice debugging features, such as GUI setting of breakpoints and a step-by-step graphical debugger. When we hit unhandled exceptions, execution dropped back to the IDE, highlighting the line and the exception that was encountered: exactly like what the students using Visual Studio were seeing.
All in all, I’m glad I discovered Xamarin and would strongly recommend it. If I’m in a job where I’m developing C# code full time, I might very well find myself using it for my primary development.