$30 off During Our Annual Pro Sale. View Details »

The Rise of Xamarin: Mobile Development in C#

The Rise of Xamarin: Mobile Development in C#

MonoTouch and Mono for Android empower C# applications targeting iOS and Android respectively.

David Ortinau

May 17, 2012
Tweet

More Decks by David Ortinau

Other Decks in Programming

Transcript

  1. The Rise of Xamarin:
    Mobile Development in C#
    Friday, August 24, 12

    View Slide

  2. David Ortinau
    @davidortinau
    http://davidortinau.com
    16 yrs web, interactive, mobile.
    Flash, iPhone, Android, WP7
    BA English,
    Maryville University
    Friday, August 24, 12

    View Slide

  3. Friday, August 24, 12

    View Slide

  4. I Don’t Hate Objective-C
    Friday, August 24, 12

    View Slide

  5. I Don’t Hate JavaScript
    Or HTML5
    Or HTML6
    Or HTML7
    Or HTML8
    Or HTML9
    Friday, August 24, 12

    View Slide

  6. Let’s Talk About
    • Cross Platform Holy Grail
    • What is Mono?
    • Who is Xamarin?
    • Why C#?
    • The World According to Xamarin
    Friday, August 24, 12

    View Slide

  7. Write Once Run Anywhere
    Friday, August 24, 12

    View Slide

  8. Friday, August 24, 12

    View Slide

  9. Write Once Run Anywhere
    • Do you hate users?*
    • Most cross-platform solutions benefit
    developers and customers, but rarely value
    users and user experience.
    * kidding, of course you don’t. Users are cuddly.
    Friday, August 24, 12

    View Slide

  10. Either/Or
    • Concessions are made to afford faster
    development and less code to target
    multiple platforms.
    • Typically you must learn a new, custom way of
    coding for the middle framework in order
    to use it and target multiple platforms.
    *learning new stuff is not bad. Embrace it. Then decide the best path.
    Friday, August 24, 12

    View Slide

  11. iOS Programming: The Big Nerd Ranch Guide
    “An aspiring iOS developer faces
    three basic hurdles: You must learn the
    Objective-C language...You must
    master the big ideas... You must master
    the frameworks.”
    Friday, August 24, 12

    View Slide

  12. Both/And
    • How can we achieve broad reach across
    platforms while:
    • reusing as much code as possible
    • not sacrificing user experience
    • not sacrificing performance
    • not sacrificing features
    Friday, August 24, 12

    View Slide

  13. What is Mono?
    Friday, August 24, 12

    View Slide

  14. Mono Overview
    • Run .Net code across multiple platforms
    • Project began in 2001
    • Novell “held” project for years
    • Mono “died” when Novell was acquired April 2011
    • Xamarin founded May 2011
    Friday, August 24, 12

    View Slide

  15. Key Parts
    • open source implementation of Microsoft's .Net
    Framework based on the Ecma standards for C#
    and the Common Language Runtime
    • Mono's C# compiler is feature complete for C#
    1.0, 2.0, 3.0, and 4.0 (Ecma)
    • The runtime implements the Ecma Common
    Language Infrastructure (CLI). The runtime
    provides a Just-in-Time (JIT) compiler, an Ahead-
    of-Time compiler (AOT), a library loader, the
    garbage collector, a threading system and
    interoperability functionality.
    Friday, August 24, 12

    View Slide

  16. Supported Platforms
    • Linux
    • Android
    • Mac OS X
    • iOS
    • BSD
    • Sun Solaris
    • Unix
    • Microsoft Windows
    • Nintendo Wii
    • Sony PlayStation 3
    • XBox
    Friday, August 24, 12

    View Slide

  17. Who is Xamarin?
    Friday, August 24, 12

    View Slide

  18. Xamarin Rising
    • Miguel de Icaza & Nat Friedman
    • 20+ Members from the Mono team
    • Self funded
    • Selling
    • MonoTouch for iOS
    • Mono for Android
    • Support Contracts
    • Other projects include MonoGame
    Friday, August 24, 12

    View Slide

  19. XobotOS
    • Android Ported to C#
    • Sharpen - code conversion tool
    • http://blog.xamarin.com/2012/05/01/android-
    in-c-sharp/
    • https://github.com/xamarin/XobotOS
    • https://github.com/xamarin/XobotOS/tree/
    master/sharpen
    Friday, August 24, 12

    View Slide

  20. Friday, August 24, 12

    View Slide

  21. Miguel
    “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.”
    Friday, August 24, 12

    View Slide

  22. Why C#?
    Friday, August 24, 12

    View Slide

  23. Mature Language Features
    • Generics
    • LINQ
    • Events
    • Lambda Expressions
    • Reflection
    • Garbage Collection
    • Thread Pooling
    • Asynchronous
    Programming
    Features
    Friday, August 24, 12

    View Slide

  24. Broad Reach
    • Desktop
    • Windows
    • OS X
    • Linux
    • Mobile
    • iPhone
    • Android
    • Windows Phone
    • Gaming
    • Unity3D
    • Wii
    • PS3
    • XBox
    • Embedded
    • Web and Server
    Friday, August 24, 12

    View Slide

  25. N A T I V E
    Friday, August 24, 12

    View Slide

  26. Tools
    • Visual Studio
    • ReSharper
    • Blend Studio
    • MonoDevelop
    Friday, August 24, 12

    View Slide

  27. The World According to Xamarin
    Friday, August 24, 12

    View Slide

  28. Friday, August 24, 12

    View Slide

  29. UI#
    C##
    Run)me#
    Pla/orm#
    Silverlight#
    Business#Logic#
    .NET#
    WP7# iOS#
    Mono#
    Android#
    MonoTouch#
    Mono#for#
    Android#
    Friday, August 24, 12

    View Slide

  30. Requirements
    • MonoTouch
    • Mac OS X
    • MonoDevelop
    • Mono for Android
    • Mac OS X or Windows
    • MonoDevelop or Visual Studio 2010
    • Windows Phone
    • Windows
    • Visual Studio 2010
    Friday, August 24, 12

    View Slide

  31. Runtime
    • Mono provides a superset of the
    Silverlight .Net profile
    • Still less than full .Net removing pieces either
    too bulky or unnecessary on mobile
    Friday, August 24, 12

    View Slide

  32. Compiling
    • Apple doesn’t allow runtime compilation so
    MonoTouch provides Ahead-of-Time
    compilation
    • Publish directly to TestFlight
    • Android allows it, so Mono for Android
    employs Just-in-Time compilation
    Friday, August 24, 12

    View Slide

  33. Bindings
    • Follow the conventions of the native platform
    • UIViewController
    • UITableViewController
    • Create custom Bindings for 3rd party libraries
    Friday, August 24, 12

    View Slide

  34. Memory Management
    • Obj-C is retain count*
    • MonoTouch abstracts this adding Garbage Collection
    • Most classes expose a Dispose() method
    *newer iOS provides Automatic Reference Counting (ARC) that makes this less of a burden
    Friday, August 24, 12

    View Slide

  35. Delegates
    • Obj-C makes heavy use of delegation
    • C# provides delegation methods
    • C# replaces most with events
    Friday, August 24, 12

    View Slide

  36. Code Sharing
    • View code is platform specific
    • Business logic can be shared across all
    platforms using
    • Shared Libraries
    • Linked Files
    • Other methods
    • Partial Classes
    • Conditional Compilation
    • Default platform symbols provided
    Friday, August 24, 12

    View Slide

  37. Persistence
    • Isolated Storage
    • Read/Write from file using XMLSerializer
    • Database
    • Sql Server Compact Edition - WP7
    • sqlite - iOS and Android
    • For WP7
    • C#-SQLite - APIs
    http://code.google.com/p/csharp-sqlite/
    • sqlite-net - ORM
    https://github.com/praeclarum/sqlite-net
    Friday, August 24, 12

    View Slide

  38. Testing
    • NUnitLite
    http://www.nunitlite.com/

    Friday, August 24, 12

    View Slide

  39. Popular Libraries
    • TinyMessenger
    http://hg.grumpydev.com/tinyioc/wiki/TinyMessenger
    • TinyIoC
    http://hg.grumpydev.com/tinyioc/wiki/Home
    • RestSharp
    http://restsharp.org/
    • MonoCross
    http://code.google.com/p/monocross/
    • MvvmCross
    https://github.com/slodge/MvvmCross
    • MvvmLight
    http://www.galasoft.ch/mvvm/
    • C#-SQLite
    http://code.google.com/p/csharp-sqlite/
    • sqlite-net
    https://github.com/praeclarum/sqlite-net
    Friday, August 24, 12

    View Slide

  40. More Links
    • MWC 2012 App
    https://github.com/xamarin/mobile-samples/tree/master/MWC
    • NYC Code Camp 6 App
    https://github.com/gshackles/NycCodeCamp6
    • Mobile Development in C#
    http://amzn.com/1449320236
    Friday, August 24, 12

    View Slide

  41. Thanks!
    @davidortinau
    http://davidortinau.com
    [email protected]
    Friday, August 24, 12

    View Slide