From Ruby to C#
Table of content
I started my career as a Ruby developer and I have not been in C++, Java (except for some Clojure) or C# land. Here at Diatom, most of my colleagues were .NET developers, and I was selling them Ruby and they were selling me C#. In this post, I wanted to share how I got convinced to use C#, what I learned to appreciate about it and what it means for me as a Rubyist. Please note that this is not a rant against Ruby, I love the language and I still think it is one of the best tools out there.
My intro to the mobile world
I wanted to learn mobile development a long time ago, but for me, the road always seemed kind of quirky: you would need to learn Java for Android and Objective-C for iOS, and I am not a fan of either language, to be honest. Our company started using the Xamarin framework, which allowed us to write business logic once for all apps using C# and to use the native view approach (that part is also handled in C#). For each platform, the speed is almost the same as with the native approach. The idea seemed cool to me, and I asked if I could be of any help on the mobile front. That’s what got me started and now I can share my findings with you.
Static typing
Static typing is something we do not have in Ruby. It seems strange for us to pass type to every method call, property or variable declaration. In Ruby we use duck typing: it’s a great power when you can just call a method on the object as long as it responds to it.
class Duck def make_noise "QUACK" end end class Cow def make_noise "MOO" end end class Human def speak "HELLO" end end class NoiseMaker def initialize(animal) @animal = animal end def make_noise @animal.make_noise end end puts NoiseMaker.new(Duck.new).make_noise puts NoiseMaker.new(Cow.new).make_noise puts NoiseMaker.new(Human.new).make_noise
Press ENTER or type command to continue QUACK MOO file.rb:23:in `make_noise': undefined method `make_noise' for #<Human:0x007f914c87e328> (NoMethodError) from file.rb:29:in `<main>' shell returned 1
On the other hand, we can hurt ourselves by passing a wrong object and it might take a considerable amount of debugging time in order to understand what has happened. An IDE can use static typing to help us with the types that we need to pass:

Interfaces
Ruby does not have explicit interfaces. We can always define an interface with an abstract class or module, but the environment and compiler does not help us with that:
class AbstractUserClass def greeter raise NotImplementedError end end class User < AbstractUserClass attr_accessor :username, :password def initialize(username, password) self.username = username self.password = password end end User.new("username", "pass").greeter
When executing this code you would get an error at runtime:
Press ENTER or type command to continue file.rb:3:in `greeter': NotImplementedError (NotImplementedError) from file.rb:15:in `<main>' shell returned 1 Press ENTER or type command to continue
On the other hand, Xamarin Studio allows you to implement the interface with a single click:
And if you have not implemented a single method in the interface, you won’t be able to compile. This is only great if you have small objects; I can’t imagine implementing the interface for ActiveRecord::Base class :).
IDE
I am a VIM user and we have auto-completion, CTags and other goodies, but what I found out is that an IDE is a powerful tool when you are developing with a statically typed language. Because of the type system, it helps you autocomplete your methods, implement interfaces and write code in general. It is not something you can easily do in Ruby.
What do I miss when writing C#?
I miss something like the Rails console, where you have absolute freedom to interact with the environment – even production. It comes in handy when you need to debug or evaluate a problematic part of your code on the server, but I should mention that this is not something you can do on a mobile platform – even with Ruby.
Lessons learned
I do not think that language is so important, as long as you care for the craft of code and follow OO best practices and Test Driven Development. C# is a great language with its benefits and drawbacks. The same goes for Ruby. Care for your craft and write awesome code!
Update (November 2026): Microsoft ended Xamarin support on 1 May 2024. Xamarin.Android and Xamarin.iOS projects now move to .NET for Android and .NET for iOS, and Xamarin.Forms apps to .NET MAUI. Ruby has gained optional type descriptions too: since Ruby 3.0 (December 2020) it ships with RBS, a language for describing the types of Ruby programs.


