Iron Ruby for the NET Developer Cory Foy
+ + = Iron. Ruby for the. NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy. com - @cory_foy
• Hello, Iron. Ruby!
History Ruby and. NET Ruby to. NET Ruby CLR Project Ruby. CLR All attempted to run Ruby on top of the CLR
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@N 04/4278580062
History alias_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: : To. Clr. Object(VALUE)' call 'Array. List: : get_Count()' call 'static Marshal: : To. Ruby. Number(Int 32)' ret end self. Count end
History CLR 4. 0 Dynamic keyword (C#) object calc = Get. Calculator(); var calc = Get. Calculator(); Calculator dynamic calc = Get. Calculator(); Type calc. Type = calc. Get. Type(); int sumres == calc. Add(1, 3); object = calc. Type. Invoke. Member("Add", Binding. Flags. Invoke. Method, null, new object[] { 10, 20 }); int sum = Convert. To. Int 32(res);
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
History Iron. Ruby John Lam hired by Microsoft in 2006 Announced in 2007 at MIX 7 Goal to make Ruby a first-class citizen Completely rewritten to take advantage of the DLR
History DLR Dynamic Language Runtime (DLR) Common Hosting Model Runtime Language Implementation Common Language Runtime (CLR)
History Ruby VB C# Dynamic Language Runtime Common Language Runtime
WHY RUBY?
CREDIT: http: //www. flickr. com/photos/19684 903@N 00/317182464 CREDIT: http: //www. flickr. com/photos/wwwo rks/3800306463 RUBY IS Love! CREDIT: http: //www. flickr. com/photos/stuckincu stoms/2366980580 CREDIT: http: //www. flickr. com/photos/expressm onorail/2631659122
CREDIT: http: //www. flickr. com/photos/billburris/2822607830
TYPE SAFETY CODE SAFETY OBJECT GRAPHS DEBUGGING STATIC CODE ANALYSIS SEALED TYPES INTELLISENSE COMPILER CATCHES ERRORS
TEST ALL THE FRICKIN’ TIME
CREDIT: http: //www. flickr. com/photos/fatboyke/2668411239
Metaprogramming CREDIT: HTTP: //WWW. FLICKR. COM/PHO TOS/CHOCONANCY/2470073711 All Classes Are Open Definitions are active All method calls have a receiver Classes are objects
Duck Typing
Open Classes CREDIT: HTTP: //COMMONS. WIKIMEDIA. ORG/WIKI/FILE: N EON_OPEN_SIGN. JPG
Monkey Patching
Dynamism CREDIT: HTTP: //WWW. FLICKR. COM/PHOTOS/LABG UEST/3510995344/
method_missing CREDIT: HTTP: //WWW. FLICKR. COM/PHO TOS/TAITOH/3029653729/
Ruby. Gems Standardized Packaging System Central Repository for hosting packages Allows for installation and management of multiple installed versions
Ruby. Gems THAT’S IT!
Iron. Ruby Basics Installing http: //ironruby. net/Download Windows Installer ? ? ? Profit!!!
Iron. Ruby Basics. . and what did we just install? bin - Iron. Ruby 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
Iron. Ruby Basics. . and, how the heck did it just do that? Dynamic Language Common Language Runtime Implementation Hosting Runtime Model(DLR) Common Language Script. Runtime Call ASTs sites Script. Engine Runtime Binders Script. Scope Compiler Script. Source Rules Hosting Model Context Implementation Common Language Runtime (CLR)
Integration Calling. NET from Iron. Ruby Calling Iron. Ruby from. NET Win. Forms / WPF / Silverlight Cucumber / RSpec
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
- Slides: 31