This was my presentation from the MIX10 conference in Las Vegas introducing Ruby and IronRuby to .NET Developers. Covers intergration with CLR, BCL and Silverlight
3. History
Ruby and .NET
Ruby to .NET
Ruby CLR Project
RubyCLR
All attempted to run Ruby on top of the CLR
4. History
CLR 2.0
(.NET 3.0 and 3.5 were still CLR 2.0)
No dynamic dispatch
Everything had to be compiled
Lots of magic, and shims
5. History
CLR 2.0
(.NET 3.0 and 3.5 were still CLR 2.0)
No dynamic dispatch
Everything had to be compiled
Lots of magic, and shims
CREDIT: HTTP://WWW.FLICKR.COM/PHOTOS/37341680@N04/4278580062
6. History
alias alias_method_missing method_missing
def method_missing(name, *params)
alias_method_missing(name, *params)
unless name == :Count
create_ruby_instance_method(self.class, 'Count') do
include 'System.Collections'
ldarg_2
call 'static Marshal::ToClrObject(VALUE)'
call 'ArrayList::get_Count()'
call 'static Marshal::ToRubyNumber(Int32)'
ret
end
self.Count
end
8. History
CLR 4.0
Dynamic keyword (C#)
Calculator calc = GetCalculator();
int sum = calc.Add(1, 3);
9. History
CLR 4.0
Dynamic keyword (C#)
var calc = GetCalculator();
int sum = calc.Add(1, 3);
10. History
CLR 4.0
Dynamic keyword (C#)
object calc = GetCalculator();
Type calcType = calc.GetType();
object res =
calcType.InvokeMember("Add",
BindingFlags.InvokeMethod, null,
new object[] { 10, 20 });
int sum = Convert.ToInt32(res);
11. History
CLR 4.0
Dynamic keyword (C#)
dynamic calc = GetCalculator();
int sum = calc.Add(1, 3);
12. History
DLR
Introduced in 2007
Set of libraries to assist language developers
Still runs on the CLI, and can access the CLR
Standardizes the implementation of dynamic
languages on the CLI/CLR
13. History
IronRuby
John Lam hired by Microsoft in 2006
Announced in 2007 at MIX7
Goal to make Ruby a first-class citizen
Completely rewritten to take advantage of the
DLR
14. History
DLR
Dynamic Language Runtime (DLR)
Common Language Runtime (CLR)
15. History
DLR
Dynamic Language Runtime (DLR)
Common
Hosting Model
Common Language Runtime (CLR)
16. History
DLR
Dynamic Language Runtime (DLR)
Common
Runtime
Hosting Model
Common Language Runtime (CLR)
17. History
DLR
Dynamic Language Runtime (DLR)
Common Language
Runtime
Hosting Model Implementation
Common Language Runtime (CLR)
18. History
Ruby
Dynamic Language Runtime
Common Language Runtime
19. History
Ruby
Dynamic Language Runtime
Common Language Runtime
20. History
Ruby
VB
C# Dynamic Language Runtime
Common Language Runtime
21. History
Ruby
VB
C# Dynamic Language Runtime
Common Language Runtime
22. History
Ruby
VB
C# Dynamic Language Runtime
Common Language Runtime
23. History
Ruby
VB
C# Dynamic Language Runtime
Common Language Runtime
24. History
Ruby
VB
C# Dynamic Language Runtime
Common Language Runtime
25. History
Ruby
VB
C# Dynamic Language Runtime
Common Language Runtime
26. History
Ruby
VB
C# Dynamic Language Runtime
Common Language Runtime
38. Metaprogramming
CREDIT: HTTP://WWW.FLICKR.COM/
PHOTOS/CHOCONANCY/2470073711
All Classes Are Open
Definitions are active
All method calls have a receiver
Classes are objects
60. IronRuby Basics
..and what did we just install?
bin - IronRuby executables (ir.exe, etc)
lib - Helpers for including assemblies and other
common tasks
61. IronRuby Basics
..and what did we just install?
bin - IronRuby executables (ir.exe, etc)
lib - Helpers for including assemblies and other
common tasks
samples - Contains the Tutorial app and others
62. IronRuby Basics
..and what did we just install?
bin - IronRuby executables (ir.exe, etc)
lib - Helpers for including assemblies and other
common tasks
samples - Contains the Tutorial app and others
silverlight - Contains the Silverlight Dynamic
Languages SDK
63. IronRuby Basics
..and, how the heck did it just do that?
Dynamic Language Runtime (DLR)
Common Language
Runtime
Hosting Model Implementation
Common Language Runtime (CLR)
64. IronRuby Basics
..and, how the heck did it just do that?
Runtime
Call sites Binders Rules
Common Language Runtime (CLR)
65. IronRuby Basics
..and, how the heck did it just do that?
Language Implementation
Language
ASTs Compiler
Context
Common Language Runtime (CLR)
66. IronRuby Basics
..and, how the heck did it just do that?
Common Hosting Model
ScriptRuntime ScriptEngine ScriptScope ScriptSource
Common Language Runtime (CLR)
68. Get Involved!
Website - http://ironruby.net
http://ironruby.codeplex.com/
http://github.com/ironruby
Mailing List - http://rubyforge.org/mailman/listinfo/
ironruby-core
foyc@coryfoy.com | @cory_foy
Slides @ http://blog.coryfoy.com
Notas del editor
Sample Ruby App, Extend Access to .NET Object, Extend to pop up a WinForms MessageBox, Extend to do a 3D WPF “Hello MIX10!”
Ruby to .NET - Thomas Sondergaard - 2003
Ruby CLR Project - Funded by Microsoft / Queensland Univ of Tech
RubyCLR - John Lam’s first attempt
Yep, it’s all about the magic. What kind of magic?
Yep, it’s all about the magic. What kind of magic?
This kind of magic
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
So, Why Ruby? What’s so great about Ruby?
But I hear many of you are quite skeptical.
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
But I’m going to sidestep all of these with one statement
Performance Implications next
Nor am I going to dive into performance implications. Compiled code is going to be faster. But I am going to talk about something very cool in Ruby
This allows us to build DSLs. If we think about what we use on a daily basis, it equates to lots of DSLs - MSBuild scripts, proj files, SQL Queries.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.
Discuss installing, and the layout of the project, then show a simple IronRuby form and talk about how the request was processed through the system.