ironruby for the.net developer cory foy - cory foy, llc foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy...

Post on 18-Jan-2016

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

IronRuby for the .NET DeveloperCory Foy - Cory Foy, LLCfoyc@coryfoy.com - @cory_foy

+ +

=

• Hello, IronRuby!

History

Ruby and .NET

Ruby to .NET

Ruby CLR Project

RubyCLR

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@N04/4278580062

Historyalias alias_method_missing method_missing

def method_missing(name, *params)alias_method_missing(name, *params) unless name == :Countcreate_ruby_instance_method(self.class, 'Count') doinclude 'System.Collections'ldarg_2call 'static Marshal::ToClrObject(VALUE)'call 'ArrayList::get_Count()'call 'static Marshal::ToRubyNumber(Int32)'retendself.Countend

History

CLR 4.0

Dynamic keyword (C#)

Calculator calc = GetCalculator();int sum = calc.Add(1, 3);var calc = GetCalculator();int sum = calc.Add(1, 3);

object calc = GetCalculator();Type calcType = calc.GetType();object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 });int sum = Convert.ToInt32(res);

dynamic calc = GetCalculator();int sum = calc.Add(1, 3);

HistoryDLR

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

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

History

DLR

Dynamic Language Runtime (DLR)

Common Language Runtime (CLR)

Common Hosting Model

RuntimeLanguage

Implementation

History

Ruby

Common Language Runtime

Dynamic Language RuntimeC#VB

WHY RUBY?

RUBY IS Love!CREDIT: http://www.flickr.com/photos/wwworks/3800306463

CREDIT: http://www.flickr.com/photos/19684903@N00/317182464

CREDIT: http://www.flickr.com/photos/expressmonorail/2631659122

CREDIT: http://www.flickr.com/photos/stuckincustoms/2366980580

CREDIT: http://www.flickr.com/photos/billburris/2822607830

TYPE SAFETY

STATIC CODE ANALYSIS

COMPILER CATCHES ERRORS

INTELLISENSE

OBJECT GRAPHS

DEBUGGING

CODE SAFETY

SEALED TYPES

TESTALLTHE FRICKIN’TIME

CREDIT: http://www.flickr.com/photos/fatboyke/2668411239

Metaprogramming

All Classes Are Open

Definitions are active

All method calls have a receiver

Classes are objects

CREDIT: HTTP://WWW.FLICKR.COM/PHOTOS/CHOCONANCY/24700737

11

Duck Typing

Open Classes

CREDIT: HTTP://COMMONS.WIKIMEDIA.ORG/WIKI/FILE:

NEON_OPEN_SIGN.JPG

Monkey Patching

Dynamism

CREDIT: HTTP://WWW.FLICKR.COM/PHOTOS/LABG

UEST/3510995344/

method_missing

CREDIT: HTTP://WWW.FLICKR.COM/PHOTOS/TAITOH/3029653729/

RubyGems

Standardized Packaging System

Central Repository for hosting packages

Allows for installation and management of multiple installed versions

RubyGems

THAT’S IT!

IronRuby Basics

Installing

http://ironruby.net/Download

Download Windows Installer

???

Profit!!!

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

IronRuby Basics

..and, how the heck did it just do that?

Common Language Runtime (CLR)

Dynamic Language Runtime (DLR)

Common Hosting Model

RuntimeLanguage

Implementation

Language Implementation

ASTsLanguage Context Compiler

Runtime

Call sites Binders Rules

Common Hosting Model

ScriptRuntime

ScriptEngine

ScriptScope

ScriptSource

Integration

Calling .NET from IronRuby

Calling IronRuby from .NET

WinForms / 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

© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,

it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

top related