What is IronRuby? How does a developer use it in rails?

Source: Internet
Author: User
Tags require

The IronRuby of Ruby molecules

IronRuby is Microsoft's Ruby implementation, which takes. NET architecture is well known for its interactivity. The name iron is actually the acronym for "Implementation running on. NET". NET's common language runtime and Mono (unofficial) can support IronRuby. You don't have to figure out some problems with dynamic language running (such as Ruby on the CLR), which is what the DLR (Dynamic Language runtime) is going to help you solve. The DLR is a technical tool for Microsoft to provide dynamic language support on top of the CLR.

As part of Microsoft's commitment to open source software, the IronRuby and DLR can be obtained from GitHub and CodePlex, in accordance with Microsoft Public License (License), respectively. From the beginning of design, IronRuby's goal was to become the first choice for Ruby implementations on the Windows platform, and it naturally provided good compatibility and excellent performance. At the time of writing this article, IronRuby's pass rate in Rubyspec has been able to reach 86%. In turn, let's look at the MRI, which has a 98% pass rate. Although the pass rate is still insufficient, from the test point of view, IronRuby performance than the MRI 1.8 much better (more than four times times), the test results Antonia Cangiano run his ruby test suite after the.

Not only has good compatibility and excellent performance, IronRuby's killer is its ability to interact well with the. NET Standard library and the. NET assembly (assembly). With just one ' require ' statement, you can use it in Ruby code. NET schemas and classes. This important feature is thus "automatically" introduced into the IronRuby code on the basis of the Ruby Standard library. Require behind can be with any. The name of the net assembly. Let's create a Windows Form in Ruby to see how Ruby and. NET are seamlessly integrated:

require 'System.Windows.Forms'
System::Windows::Forms::Form.new.show

Run IR (IronRuby interpreter) and you will see a standard Windows form! on the screen Although it's just an empty form, how much can you expect for just two lines of code? The beauty of the code here is that it needs to do the same thing with less code than C # or VB. As you can imagine, you can also programmatically add some control logic to this new form:

require 'System.Windows.Forms'
form = System::Windows::Forms::Form.new
lbl = System::Windows::Forms::Label.new
lbl.text = "foo"
form.controls.add(lbl)
form.show 

Comparing static and dynamic language code is very difficult, but we can first look at what the above code should look like in C #:

using System;
using System.Windows.Forms;
namespace MyWinFormsApplication
{
   static class Program
   {
     static void Main()
     {
       Form form = new Form();
       Label lbl = new Label();
       lbl.Text = "foo";
       form.Controls.Add(lbl);
       form.Show();
     }
   }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.