IronShay

Ironing code, geek t-shirts and even presentations!

NAVIGATION - SEARCH

Upcoming Session: Riding IronRuby on Rails at WDC, Israel

I’m glad to announce that another IronRuby session is getting closer, this time at the Israeli Web Developers Community!

When?

Sunday, 1st of  November, 2009. 17:00-20:00.

Where?

Microsoft Offices, 2 HaPnina St., Rannana.

What?

The session is all about IronRuby, with a focus on Ruby’s most famous member – Ruby on Rails. The session will  start with an overview of the Ruby language and its powerful abilities, continue with IronRuby and  the stuff it brings to your everyday work and end with a Ruby On Rails overview, including live demo of building a Web 2.0 application from scratch.

Why?

Because IronRuby can enhance your everyday work, speed up your development process and make it enjoyable and fun! In addition, you will see another web development framework, Ruby on Rails, which will show you another way of web development and will also give you an idea about where today’s web MVC frameworks got all their ideas and probably their future ones as well  :)
And most importantly, there will be free food and drinks!

How?

Register to the event at: http://msevents.microsoft.com/cui/EventDetail.aspx?EventID=1032426828&culture=he-IL 

By the way, If you’d like me to come and present at your event (conference, user group, internal gatherings, courses…), please contact me.

Hope to see you there,
Shay.

My Presentation at the Nes Ziona User Group

Yesterday I did a presentation at the Nes Ziona user group. My session was about IronRuby and my main goal was to show the audience what they can do with IronRuby in their everyday .Net work.

First of all, thanks everyone for coming! I had a lot of fun!

I discussed the following subjects:

  • Creating internal tools and POCs with IronRuby – taking advantage of the Ruby language abilities and libraries to write code faster.
  • Using Ruby REPL abilities in .Net apps – can be used for polishing, debugging and extending .Net applications.
  • Cucumber – the amazing Ruby test framework that now can help test .Net code.
  • Gestalt – oh yea!

You can download all the demos from here: NesZionaUGDemos.zip (4.82Mb)
I didn’t have any slides, so no ppt this time!

Some resources to get you started:

If you have any questions, suggestions, complaints, consulting needs or whatever, don’t hesitate to contact me (also via twitter)!

Thanks for attending!
Shay.

Upcoming Session: IronRuby on the Nes Ziona User Group

It’s time for another session about IronRuby!

Where?

The Nes Ziona user group, HP Indigo Offices – Scientific Park – 20 Einstein St. Nes Ziona.

Nes Ziona!

When?

Tuesday, 13-October-2009, 17:00 – 20:15

What?

The session will be separated into two parts – the first one will be passed by Vitaly Kushner who works with Ruby everyday in the company Astrails. Vitaly will introduce Ruby to you – syntax, Ruby on Rails and general coolness. On the second part (starting from 19:00) I will take everything Vitaly has told you about and bring it to the .Net world. I will introduce you IronRuby (shortly) and then move forward to explain you how you can use it in your everyday work in order to enhance yours and your team development life.

Why?

Because IronRuby rocks and I really believe it can help any one of you in your everyday work.

How?

Register at: http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032429242&culture=he-IL
there’ll be food and drinks for free!!!

Hope to see you there!
Shay.

.Net Developers Hear Me Out! IronRuby is IN DA HOUSE!

Everywhere I go and preach about IronRuby I come across .Net devs who don’t understand what’s in it for them. This time I’ve decided to take action and tell you all about what’s in it for you and why you should be as excited as I am about the upcoming IronRuby 1.0.

This post is written as a conversation between me and my imaginary .Net developer friend (don’t you have one too?). Enjoy!

Friend: Hey Shay, what is this IronRuby that you can’t stop talking about?

Me: Oh imaginary friend, finally you’re being productive! well, IronRuby is Microsoft’s implementation of the Ruby language which runs on top of the DLR. Its unique power, comparing to other Ruby implementations (MRI, JRuby…), is its ability to interop with .Net assemblies with ease.

Friend: So is it an entire new language?

Me: Ruby isn’t a new language, it’s been around since 1996. However, it is a new language for the .Net framework. It is the first time for Ruby to be a fully .Net language. As a result of IronRuby being a .Net language, just like you can run VB.Net from C# and C# from VB.Net, you can run C# from IronRuby and vice versa.

Friend: Why did Microsoft choose Ruby from all the languages out there?

Me: First of all, Ruby rocks! secondly, along with the development of the Dynamic Language Runtime (DLR), Microsoft decided to develop .Net implementations of Ruby and Python. These languages appear in the top 10 of programming languages (look here) and with these .Net implementations, Microsoft will open its doors to thousands of developers worldwide, who until now had no reason to take a look at the .Net framework.

Friend: What’s in it for Ruby developers? Why would they want to use IronRuby?

Me: For Ruby devs, using IronRuby means that they can use .Net framework frameworks like WCF, WPF, ASP.Net MVC, Silverlight and others. Even though there are many libraries and frameworks available in Ruby, Microsoft does have some killer frameworks which are hard to find elsewhere like Silverlight. Another advantage is the possibility to use Microsoft infrastructure. For example, running Ruby on Rails on IIS.

Friend: Ok, so if I want to use IronRuby, I need to learn Ruby, right?

Me: Correct.

Friend: But I don’t know the language!

Me: Just like many other .Net developers, you will need to learn the Ruby language in order to write IronRuby code. Do NOT be afraid. Ruby is an easy language to learn and I promise you that learning it will open your eyes to a whole new world (which might amaze you, beware!). When I was learning Ruby I was surprised time after time about its syntax and the fun feeling you have while coding. Moreover, learning another programming language is a good practice to increase your knowledge of programming in general (read my other post about how to increase code quality).

Friend: Assuming I have learned Ruby, the company I work for will never abandon C#/VB.Net for IronRuby.

Me: I agree, I don’t believe companies will stop using C# and start coding in IronRuby. It isn’t gonna happen. However, when companies realize the benefits of using IronRuby in different scenarios, you will start seeing IronRuby code over there.

Friend: How can a company benefit from using IronRuby?

Me: A lot. As I said, I don’t expect companies to change their core code to IronRuby. There’s no reason to do that. But, there are several other areas where you can use IronRuby – tests, POCs, automation, internal tools and more.

Friend: How can IronRuby improve my tests?

Me: IronRuby has incredible test frameworks. For me, Cucumber is a killer test framework. It’s one of the most brilliant frameworks I’ve run into. To make it possible for QA and product managers to write specs in a human-readable syntax and run them as tests afterwards is just astonishing. Ruby has other great and widely-used test frameworks like RSpec and even web test frameworks like Watir.

Friend: Sounds pretty promising I must say. And why did you say it was good for POCs?

Me: Ruby is a language that enables you to write code fast. This is why writing a POC in IronRuby will take less time to develop. Remember that when you develop in IronRuby, everything is a CLR object so it is almost like writing C#/VB.Net code. Once the IronRuby POC is done and the feature goes into production development, transferring the IronRuby code to C#/VB.Net is very easy (SharpDeveloper even has a feature that does the conversion automatically). Same goes for internal tools – you write the tools faster and continue with your other tasks (look at my first ever IronRuby post where I was excited how easy and fast it was to write a tool I needed) . By the way, writing in a different language from time to time can also be a breeze of fresh air and a great routine breaker.

Friend: Great! and what about automation?

Me: Ruby has Rake which is similar to Nant in concept, just uses Ruby syntax. Once you know Ruby, there is not need to learn Nant as well… just use Rake.

Friend: You make faces like there is more. Is there?

Me: Yes! Except all the great Ruby stuff, you can also use IronRuby from your static language code. This is great because it lets you extend your application in a very easy way (take a look at my post about the subject). Another thing, the DLR along with Silverlight gives client scripting a whole new life and makes it bearable (which is not an easy task at all). Take a look at the amazing Gestalt project for more about that.

Friend: Now let’s say I write something in IronRuby. How do I deploy it? is it hard?

Me: The deployment is a matter of seconds. It is actually just copy and paste. All you need in order to run IronRuby on a different machine is to copy the Dlls there.

Friend: Nice! Well, I’ve waited till now and here is the million dollar question – can I write IronRuby inside Visual Studio?

Me: Well, in the meantime - no. There is a voting going on to convince Microsoft to do that ASAP. However, there are some great Ruby IDEs (like NetBeans, RubyMine, SciTE and more) that you can use. There is also the Ruby-in-Steel Visual Studio addin which makes it possible to work on Ruby files inside Visual Studio (it doesn’t work with IronRuby yet, but it is included in their plans). These IDEs do not have the intellisense that you are used to in VS and C#, but they are good for the job. I must say, once you get familiar with the language, you don’t need intellisense anymore. Really.

Friend: You got me convinced! I want to start IronRubying!!!

Me: Awesome! You can start with http://IronRuby.net and download the latest IronRuby version from there. If you have any questions, make sure to check the IronRuby mailing list or contact me and I’ll do my best to help. By the way, IronRuby is currently in version 0.9.1 and will advance to version 1.0 in the next couple of months.

Friend: Thanks Shay! now I see what IronRuby gives me and I’m willing to give it a try!

Me: Glad I could help! see ya!

Readers, do you have any questions? post them as comments and I’ll address them as soon as I can.

Enjoy IronRubying!
Shay.

kick it on DotNetKicks.com Shout it

IronRuby Tip: Using Generic CLR Methods from IronRuby

A while ago I wrote a post about using Generic CLR classes from IronRuby. This time I’ll share with you its less intuitive friend – using generic CLR methods from IronRuby.

As a result of Ruby being a duck-typed language which works with types implicitly, generics is not really needed. The whole language is generic… This is why using generic CLR types might become a bit odd for the language. Nonetheless, this fact will not stop us. The price to pay in order to enjoy Ruby in the .Net framework is worth it! :)

Anyway, assuming we have the following C# class defined in file sample.dll:

namespace ClassLibrary1
{
    public class Class1
    {
        public string Test<T>(T param)
        {
                return param.ToString();
        }
    }
}

In order to use it with a specific type, you need to do two things – get the generic method object (by using the method method) and provide it with the type via the special of method. For example, the next code invokes Test with a string and pass it “Shay Friedman”:

require "sample.dll"

sample = ClassLibrary1::Class1.new
sample.method(:test).of(String).call("Shay Friedman") # returns "Shay Friedman"


And that’s all there is to know.

All the best,
Shay.

Configuring SciTE to Run IronRuby

I talked with Ariel today and recommended him my favorite Ruby editor for small scripts and apps – SciTE.

The nice thing about SciTE is the ability to run your script file from the application via the F5 key. Since we were talking about IronRuby, SciTE gave us good syntax highlighting and auto-completion features, but we couldn’t execute our code on the IronRuby interpreter.

BUT… this is a problem of the past now! with a few simple steps, you can turn your SciTE environment to an IronRuby stupendous development environment! or at least make it use the IronRuby interpreter…

Now, to the job:

  1. Open SciTE.
  2. Go to Options->Open ruby.properties:
    Running IronRuby via SciTE Step 1
  3. A file with a lot of settings will be opened inside the editor window. Look for the text “ruby $(FileNameExt)” (I have it on line  108 and  116).
  4. Change “ruby $(FileNameExt)” to “ir $(FileNameExt)” on both places (if you’re on Windows, changing the first one will be enough):
    Running IronRuby via SciTE Step 2
    Pay attention that there is the rbw line (look at line 110 on the image). I haven’t changed it because it’s not that common to use rbw files and also IronRuby doesn’t have the option as far as I know… I just left it there to use the regular MRI interpreter.
    If you want to make sure that every Ruby file on SciTE environment is run via IronRuby, change “rubyw $(FileNameExt)” to “ir $(FileNameExt)” as well.
  5. Note
    You must  have ir.exe defined in your PATH environment variable in order for this to work.  It is a good practice to do that, but if you don’t want to, just write the full path to ir.exe instead of just “ir”.
  6. Save the file.


That’s it, your’re done! now go and create an rb file and hit F5. IronRuby will run your script now.

Running IronRuby via SciTE Step 3

Enjoy!
Shay.

My Presentation at the AltNetCrossGroup in London

I had the honor to be the first speaker of the cross language talks in altnet London group.

I really had a great time – the people were great, the MRM office was awesome (even though Kevin might think otherwise :) ) and most of the demos worked smoothly. Microsoft organized Pizzas and beer and the atmosphere was just incredible. Special thanks for Seb, Neil and MRM for making this happen.

And there was a talk too! I talked about Ruby, IronRuby, Cucumber and Ruby on Rails. I really tried to bring some real-world demos that you can take with you and implement right away. Hopefully, you will.

If you have any questions, requests, comments, notes or whatever don’t hesitate to contact me.

So, to those who came and to those who didn’t make it, here are the slides and demo files:

Some pics from the event (click to open a higher resolution version):

Talking… pegs, cucumbers…
Starting with a story about clothes pegs Introducing the Cucumber framework

When you drink and present, you get huge exceptions…
Beers are NOT good for demos

Audience! Thanks  for coming!
The session attendants #1 The session attendants #1

At the end of the session with Neil:
End of the session with Neil Robbins

Hope you enjoyed it as much as I did,
Shay.

Upcoming Session: IronRuby on the AltNetCrossGroup in London

Announcement!  Announcement!  Announcement! 

I’m coming to London this Friday and I’m going to do a session about IronRuby on the AltNetCrossGroup!

IronRuby Session on AltNetCrossGroup

The session will take place in MRM London (76 Southwark Street) on Friday, September 25th, between 18:30 and 20:30.
The agenda is:

  • Introduction to the Ruby language
  • IronRuby – using CLR objects from IronRuby and using IronRuby from C#
  • Cucumber – test your code with style
  • Ruby on Rails

This is the current plan. If you have ideas or requests, please let me know (via the contact page or twitter)!

Register here: http://altnetcrosstalks.eventbrite.com/
If you’re interested, make sure to register ASAP since the amount of seats is limited.

I am very excited to be the first speaker on the AltNetGroup series of cross language talks and I hope to see you there!
Shay.

IronRuby Tip: Data Binding Silverlight Elements to IronRuby Objects

When I was playing around with Silverlight and IronRuby, I ran into a problem with data binding and IronRuby objects. This post is to let you know about it and hand you the workaround as well.

The Problem

You have an IronRuby class. You fill it with data and set it as the data context of your Silverlight element.
The result: the values are not presented on the Silverlight page.

Detailed steps to reproduce:

1. Create an IronRuby class. For example:

class Person
  attr_accessor :full_name
  def initialize(full_name)
    self.full_name = full_name
  end
end


2. Create an instance of that class and set it as the data_context of an element:

shay = Person.new "Shay Friedman"
@root.data_context = shay


3. Set the element to present the data:

<StackPanel>
  <TextBlock>You name  is </TextBlock>
  <TextBlock Text="{Binding full_name}"/>
</StackPanel>


4. Run the page – nothing is shown.

 

The Reason

With the help of Jimmy Schementi I’ve figured out what the problem was. Silverlight 3.0 elements can only do reflection-based data binding. IronRuby objects are based on ICustomTypeDesciptor, which means that the attributes cannot be read using reflection. Bummer.

The Workaround

Instead of using an IronRuby class, use a CLR class. This means that in order to make it work, the work flow should be as follows:

1. Create a C#/VB.Net class. For example (assume this appears in “person.dll”):

class Person
{
  public string FullName { get; set; }
  public Person(string fullName)
  {
    FullName = fullName;
  }
}


2. Create an instance of that class in IronRuby and set it as the data_context of an element:

require "person.dll"
shay = Person.new("Shay Friedman")
@root.data_context = shay


3. Set the element to present the data:

<StackPanel>
  <TextBlock>You name  is </TextBlock>
  <TextBlock Text="{Binding FullName}"/>
</StackPanel>


4. Run the page – everything works as expected.

All the best,
Shay.

I'm Proud to Present - IronRuby Unleashed

Hi readers!

I'll start with the announcement - I'm writing a book! it is called "IronRuby Unleashed" and it will be published by Sams Publishing who has brought the world the great Unleashed series.

What is the Book About?

Well, I bet you've guessed it already - the book is about IronRuby. With version 1.0 right around the corner, it is more than important to have some reference books so developers can get started in no time.

The book is a ~500 page reference and guide book. You will start by learning the Ruby language (an essential part for IronRuby devs, I'd say) - from the basic to the advanced subjects. Then you will get to know IronRuby - how to use it in simple and complex occasions. On the third part of the book, you will go through different frameworks and learn how to take advantage of them with IronRuby (WinForms, WPF, Ruby on Rails, ASP.Net MVC and more). Eventually on the last part, you will be guided how to extend IronRuby and add your own touch to the language.

The table of contents (subject to change):

  • Part 1 - Introduction to IronRuby
    • The Ruby Language
    • The .Net Framework
    • The DLR
    • Getting Started with IronRuby
  • Part 2 - The Ruby Language
    • The Basic Basics
    • Methods, Blocks, Classes and Modules
    • The Standard Library
    • Advanced Ruby
  • Part 3 - IronRuby Fundamentals
    • .Net Interoperability Fundamentals
    • Object Oriented .Net in IronRuby
  • Part 4 - IronRuby and the .Net World
    • Data Access
    • Win Forms
    • WPF
    • ASP.Net MVC
    • Ruby on Rails
    • Silverlight
    • Unit Testing
    • Using IronRuby from C#/VB.Net
  • Part 5 - Advanced IronRuby
    • Extending IronRuby using C#/VB.Net

Who is it for?

I tried to write the book in a way developers from both sides, Ruby and .Net, can benefit from it. In addition to that, because of the structure of the book (basics to advanced), people who want to learn their first programming language might find the book helpful as well.
Generally, If you are interested in IronRuby, I believe you will find what you're looking for in this book.

Why Did I Do It?

Hmmm... Tough one... firstly, I really believe in IronRuby. I think it is a killer language which gives developers so much power with such a small effort. For me it was something I had been waiting for for a long time - a language that is fun to work with but still is powerful. By the time I started writing the book I didn't even know how big of a fan I would become...
Secondly, I wanted to know how it would be like to write a programming book (hint: not easy at all!).
Thirdly, I needed something to make mom and dad proud :-)

Where Can I Read Sample Chapters (and purchase purchase purchase!)?

I'm glad you asked. The book is already on Amazon and the Safari Books Online ready for pre-ordering.

The book is also on the Rough Cuts program, which means that a few chapters are released while they are in development so you readers can get a sneak peek, express your opinions and help make the book better. You can access the chapters via the Safari Books web site.

Well, that's about it. I'm still working on it, but the finish line is nearby.
Hope you'll enjoy it,
Shay.