views:

209

answers:

5

Hi guys,

I know some ruby language. Now I need do some .net development. I don't want to learn a new language. So, after googling I got IronRuby. Now my question is Can I use IronRuby to write all apps that c# can write?

Thanks.

+2  A: 

Yes, you can use IronRuby to write Apps, but with Ruby the support and online community will not be as matured as C# is. So, you would find it a bit easier if you learn C# and write applications. This is my personal opinion.

IronRuby is just one more implementation language that Ruby has besides C, Java etc., This does not mean that you can do coding in C#. You will be coding only in Ruby language and you can enjoy all its pros and deal with it cons.

So, the answer to your question is, whether you use IronRuby or JRuby or (C)Ruby does not really matter.

Bragboy
+5  A: 

Broadly speaking, I believe you should be able to do almost anything you can do in C#. However, there may be some areas where C# makes things easier for you - the framework was certainly designed with statically typed languages in mind.

One area which does raise a spectre is LINQ. I don't know whether IronRuby supports expression trees at all directly. You could create them manually of course, but that would be a pretty poor experience. Likewise I don't know what IronRuby would do about inferring the relevant delegate types for LINQ to Objects etc.

Don't be too afraid of learning a language: it's an experience which can broaden the mind significantly. Given that you're already going to have to learn the .NET framework to at least some extent, you might as well learn the language which most of the examples of the framework are written in. If this is a reasonably large project, I suspect that overall you'll save time - and, of course, have a broader knowledge as a result.

Another thing to consider is who's going to maintain the code base. You haven't said why you need to do this development - but if it's for a professional reason, presumably you'll either have colleagues or have to hand the code over to someone in the long run. Find out what their preference is.

Jon Skeet
Ah, that is a quandary. To me, when I think about IronRuby and LINQ (assuming there is no direct implementation of expression trees), my immediate thought is: well, is it strictly necessary to "write all apps C# can write" (especially with regard to LINQ to Objects, as some of the constructs have always existed in Ruby wrt. closures)? But then I ask myself, "In 2010, why on Earth would you _not_ take advantage of LINQ if you were using .NET?" :)
Marc Bollinger
@Marc: Exactly. That's the difference between "theoretically" and "practically" :)
Jon Skeet
LINQ is not supported in IronRuby since it is a C#/VB.NET DSL. In IronRuby you would have to manually create expression trees and as @Jon said, this wouldn't be a nice experience.
Shay Friedman
@Shay: Full query expressions are VB/C# DSLs, but if IronRuby supported expression trees and extension methods with some cunning way of inferring the types, that would give a lot of the benefits of LINQ. It's fundamentally a statically typed technology though...
Jon Skeet
By the way, Ruby has a similar thing to LINQ to Objects, it's done with the map and select methods - look here: http://www.benjaminbooth.com/tableorbooth/2006/12/ruby_arrays_sel.html
Shay Friedman
@Shay: That's Select and Where covered... what about the rest? ;) (Seriously, I'd expect most of it to be there, but possibly not all.) If those are taking and returning arrays though, does that mean they're eagerly evaluated? Deferred execution is one of LINQ's strengths IMO.
Jon Skeet
@Jon, in more you mean joins? this doesn't exist AFAIK. However, the new AREL language for ActiveRecord, is very very similar to LINQ methods and supports joins, groups, etc. and also deferred execution.
Shay Friedman
@Shay: Join, GroupJoin, GroupBy, OrderBy, Take, Skip, Zip etc. Sounds like ActiveRecord may be a better fit in many cases. Good to know, thanks.
Jon Skeet
IronRuby now supports extension methods, enabling LINQ: http://ironruby.codeplex.com/releases/view/43540#ReleaseNotes
Jimmy Schementi
+2  A: 

I think what you really want to be asking here is one of two things:

  • Can I use IronRuby to interface with existing .NET and .NET-based libraries, interacting as a C#-language program would?

    The answer is yes, well, mostly. The primary section you will not be able to do directly is to interface Win32 API calls directly in the same way C# does with P/Invoke. P/Invoke is basically to C# what FFI is to Ruby. If you don't don't care about that, great.

  • Can I write any algorithm/structure/construct/etc. in the language Ruby that I can in the language C#?

    This is the more literal interpretation of the actual wording of your question, but I don't think it's what you meant to ask, as the answer is more nebulous without getting into some pretty heavy theory. So, we'll just say 'sure'.

Marc Bollinger
Ooh, I didn't realise that IronRuby didn't support P/Invoke. I suppose it would be pretty easy to write a C# wrapper where necessary.
Jon Skeet
+1  A: 

The general answer to your question is yes - everything you can do in C# you can do in IronRuby and vice versa. However, every language has its own advantages and disadvantages... for example, Ruby has awesome metaprogramming capabilities that C# can only dream of. On the other hand, C# has LINQ.

Regarding the community, I don't think there is much of a difference. With IronRuby you get the Ruby community and the IronRuby community. With C# you get the .NET community and MSDN...

Choosing a programming language is kind of a religious question... what would you go with - Christianity, Judaism or Islam? only you can tell... :-)

Shay Friedman
A: 

If you already know ruby and want to use .NET then IronRuby is great. But to learn .NET using IronRuby without knowing C# might be challenging. As Bragboy has pointed out, the IronRuby support and online community will not be as matured as C#. For example MSDN .NET documentation gives example code in C# but not in IronRuby. So it can help to know C# when looking at .NET documentation.

NoonKnight