BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage Articles Book Excerpt and Interview: Rails for .NET Developers

Book Excerpt and Interview: Rails for .NET Developers

Bookmarks

Ruby on Rails has seen spectacular growth over the recent years with many PHP and Java programmers learning Ruby and Ruby on Rails to help create faster solutions to business problems. This leaves out a large group of developers who are also recognizing the advantage of Rails, ASP.NET developers. These are the developers writing C# and VB.NET ASP.NET applications for all those Microsoft shops around the world.

Many ASP.NET developers are starting to get interested in the Ruby programming language and the web framework, Ruby on Rails. These developers are seeing life outside of Microsoft and often find the reality a bit difficult to grasp. So where are they to turn? InfoQ has been fortunate enough to meet two such developers, Jeff Cohen and Brian Eng, who were just like so many Microsoft developers picking up Ruby on Rails and learning how to use this web framework.

Jeff and Brian are the maintainers of the Softies on Rails blog which chronicles the journey from Microsoft technologies to Ruby on Rails. Jeff and Brian also just had a book published by the Pragmatic Programmers titled Rails for .NET Developers. Pragmatic Programmers, the book publisher, has provided InfoQ with an excerpt from the book, Chapter 2 titled "Switching to Ruby".

InfoQ had the opportunity to speak with Jeff and Brian about the journey from .NET to Rails.

Robert Bazinet (RB) : First, tell the readers a little bit about yourselves?

Jeff Cohen (JC) : A one-time MCSD, I worked for 15 years with Microsoft technologies; mostly with C++ creating MFC/ATL applications, later C# desktop apps. I dabbled in ASP and ASP.NET but generally preferred creating desktop/mobile solutions instead. Discovered Rails in 2005, and within a year was working with Rails full time. I currently work as a Senior Software Engineer for Leapfrog Online, and founded Purple Workshops in mid-2008.

Brian Eng (BE) : I was a MCSD as well, and had done a lot of web development with classic ASP and ASP.NET. Jeff and I were working together developing touch screen and Tablet PC applications at a big retail company here in Chicago in 2004, when Rails was publicly released. I was also trying to build my own startup at the time, and thought it might be fun to try and recreate the prototype I'd built using ASP.NET with Rails. That experiment turned into a real product, and that side-business turned into my company, Bluebuzzard, and that's still what I'm doing today.

RB : What was your motivation moving from Microsoft development to Ruby and Rails?

BE : I'd been leveraging Microsoft technologies successfully in my career for more than 10 years, but for some reason, I never really enjoyed the tools I'd worked with on a day-to-day basis. One day, I discovered this great tool for managing small projects called Basecamp from some company in Chicago. I was talking about it with one of my co-workers, and he said "you know, they wrote that in Ruby". That seemed totally absurd to me, so I Googled a little bit, discovered Rails, and it instantly clicked.

JC : I had read a little bit about Ruby as a scripting language, but sometime in 2005 started to try Rails. I downloaded the One-Click Installer for Windows, and easily created a simple Hello World app in Rails. I found the MVC structure more intuitive than the ASP.NET page model, and instantly realized how much fun I could have creating websites with Rails. Writing C# ASP.NET code quickly seemed like trudging through mud compared with writing beautiful Ruby code in a Rails app, and I've been hooked ever since.

RB : What were the biggest challenges you both faced?

JC : Using Ruby really made me put my money where my mouth was, TDD-wise. With an interpreted dynamic language, there's no compilation step to check for typos, so it all comes down to your unit tests. Which for me is a great fit anyway; I'd been an agile geek for a number of years before using Rails.

On the language side, there were several programming concepts that I hadn't encountered in .NET. It seems silly in hindsight perhaps, but I couldn't wrap my brain around "yield" for a while. Even though C# had added a yield statement, I never used it, and if I recall it was really only meant for iterators. I had been reading some of the .NET beta documentation about anonymous methods in C# at the time when I was learning Ruby. But the funny thing is, it wasn't until I understood blocks in Ruby that I looked back and really came to see the potential in C# anonymous methods. It's also been through the Ruby community that I got introduced to the concepts of continuations and functional programming. Ruby may not have those concepts exactly, but the people using Ruby also tend to be fluent in other languages as well, like Smalltalk and Lisp, both of which influenced the development of the Ruby language. Understanding the perspectives and implementations of other languages than your "main" language isn't easy, but I've found that it really deepened my appreciation for the larger software community around me. So that was another challenge: to be a well-rounded software developer, not just a C# or Ruby programmer.

BE : There is certainly a big learning curve for anyone going from a programming language with static typing to a dynamic one. Once I got past the initial wow factor of Rails, there was definitely a temptation to do things the way I was accustomed to with C#, instead of "the Ruby way". This often meant over-thinking problems and coming up with overly complicated solutions.

RB : Why should .NET developers be interested in Ruby on Rails?

BE : I was learning Rails and using it for side-projects while working at my 9-to-5 .NET job for almost 2 years. I was shocked at how much of an immediate impact it had on how I thought about my .NET code. It definitely made me a better developer, and that in itself is reason enough to learn Ruby. Plus, as techies, we're easily distracted by new, shiny things.

JC : I wish all .NET developers could have a chance to develop a simple application in Rails, perhaps on a Linux box or with a Mac, with something other than Visual Studio, if only for a week. I think they'd get a glimpse of why Rails is so compelling; why using Linux or Mac isn't as esoteric as it may sound; and why you really don't need all that intellisense sugar to be a good software developer. Plus, like it or not, Ruby is coming to Visual Studio in the form of IronRuby. John Lam's team has been doing amazing things and we're excited to see it take shape. It's possible that ASP.NET MVC + IronRuby will be the way that most .NET developers get a taste of what we've been doing this whole time with Rails.

RB : What, if any, has the adoption and success of Ruby on Rails been to the .NET community in general?

BE : Since Rails was released, we've seen a lot of changes with Microsoft and the community. Clearly, Microsoft has since embraced and shown its commitment to things like MVC, REST, and dynamic languages. More importantly, we've seen that there are a lot of .NET developers that care deeply about their work and understand that you're allowed to use the best tools for the job, not just those provided by Microsoft itself. Agile development has taken off in the .NET community. Independent .NET developers have built tools inspired by Rails, like Castle Project/MonoRail and Subsonic, and that is an overwhelmingly positive thing for the developer community.

RB : How can .NET developers get started with Ruby on Rails?

JC : You can read only so much; to get over the fear of trying something new, you just have to, well, try it. Download the free One-Click Installer for Windows, fire up your favorite text editor, and just get started. My first freak-out moment with Rails came when I realized I was using Notepad to create my first "Hello World" Rails app. I would type a variable name and period and hesitate, waiting for the intellisense dropdown that would never come. Might sound funny, but that really was a hurdle that I had to overcome. I found that after a few days, I didn't miss it at all. I remember Brian and I pairing on our first couple of Rails attempts, having no idea how to do find elements in an array based on some condition. So we just guessed that the method was called .select, and it worked! We soon discovered that a lot of Ruby was like that. So for .NET developers thinking about giving it a try, we say don't give up too early - it's going to be easier than you think.

RB : What are your key pieces of advice would you give .NET developers as they approach learning Ruby on Rails?

BE : Aside from what Jeff has already said, the most important thing to keep in mind is to not be intimidated. Rails has come a long way since 2004 and the constant change going on in the Rails development community can be difficult to keep up with. And, the exercise of understanding and embracing the open-source culture that many of those coming from Java or PHP are already familiar with can be particularly daunting for a .NET developer. You don't have to trade your PC in for a Mac - not today anyway. Just jump in and take it in a little at a time.

RB : How do you see the development of IronRuby helping .NET developers move to Ruby on Rails? Do you see IronRuby as being "the" way .NET will implement Ruby on Rails in the future?

BE : IronRuby is an extremely important project, because it shows that Microsoft is committed to funding and supporting open-source technologies and dynamic languages. Soon, I'll be able to open Visual Studio and start an ASP.NET MVC project and write the whole thing in Ruby or Python, and that's an important step in terms of dynamic languages being taken seriously. And as .NET web development becomes more "Rails-like", that only forces the Rails community to continue to innovate and stay ahead of the curve - a good thing for everyone.

RB : How do you think .NET developers will deal with the opinionated approach Rails takes in its implementation? Meaning, in .NET you have a blank slate, MS will let you do whatever you want, even if it means bad practice.

JC : The opinions held by Rails are only good for database-backed web applications. It's not a blank slate. So if you're writing a database-backed web application, you're going to love it. You're going to stand on the shoulders of giants: an easy to use ORM (ActiveRecord), and built-in MVC architecture, code generators that create only best-practice code, database-agnostic schema migrations, and built-in unit testing framework. You're not going to reinvent many wheels. Most of your time will be spent working on whatever is specific to your problem domain. So be warned. If what you really want to do is build your own database middle tier that maps your objects to a relational database, or you want to create your own URL routing using as many GOF patterns as you can, then you're going to hate Rails. Stick with ASP.NET, I'd say.

RB : How do you see the adoption of Ruby on Rails in the .NET community long term?

BE : We'll continue to see steady growth in .NET developers giving Rails a try. Most of these developers will probably have a similar experience to ours; they'll continue to work at their 9-to-5 .NET jobs while spending nights and weekends in the basement hacking on a side project or the Next Big Thing. If you're in this situation, it's a perfect time to try Rails. You can get a lot done quickly on your project, and you're learning something new at the same time. Ultimately, you might give up on Rails and go back to using ASP.NET or perhaps ASP.NET MVC. But the exercise alone will make you a better developer, guaranteed.

RB : Microsoft seems to have countered the Ruby on Rails excitement with its own MVC implementation called ASP.NET MVC. How do you think this compares to Rails and should the Rails community care about ASP.NET MVC?

BE : If anything, it's validation that Rails has been doing it right. Using MVC/REST patterns and having complete control over the markup of a page has always felt like the right way to build a web app to me. Microsoft is now giving developers the option to do that. Ultimately, it's a good thing for everyone, because it will make the tools better, regardless of which ones you prefer.

RB : What was your motivation to write this book?

JC : The book is our attempt to communicate a couple of essential ideas, and to kind of bring to a closure our journey from .NET to Rails. First, that software engineering should be joyful. Not "fun" - that implies you're using a toy or something without a lot of value. I really mean joy - a real sense that you're enjoying the work that you do. Second, that anyone with intermediate programming skills can make the jump to Rails. We assume a decent knowledge of general .NET programming, but nothing about Ruby or Rails. So it's a great way to make the lateral transition. We wrote the book like we write our blog: in a really non-intimidating way for those who are new to the subject, but with topics that are applicable to everyday work. From the beginning, the mission of the blog was to clear the path of obstacles for everyone else who wants to try this new thing called Rails, and our hope is the book will also do just that.

RB : What are some good, top 5 resources a .NET developer should go to find more information about getting into Ruby on Rails development?

RB : Thank you Jeff and Brian for your time.

Additional information about transitioning from .NET to Ruby on Rails can be found on the Softies on Rails web site where readers can also contact Jeff and Brian.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • The Best Environment for Rails on Windows

    by Charles Roper,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    There is a mild implication in this article that you should be using either a Mac or a Linux machine to develop Rails apps but this just isn't necessary. You can develop Rails apps just fine on Windows (no need for VS!), especially if you setup a local Linux VM (I recommend VirtualBox with either Linux Mint or Ubuntu) to use as a local test server. I find this to be a very satisfactory setup and very easy to work with, especially if you follow some of the tutorials found on Slicehost.

    There's a fantastic post over on Akita on Rails titled The Best Environment for Rails on Windows. It's a really good tutorial on how to setup a robust working environment for Rails on Windows. Akita suggests gVim as the editor to use for Rails development, but I'd recommend E Text Editor which is compatible with Textmate, the editor of choice for Rails developers on the Mac.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT