ironruby for the.net developer cory foy - cory foy, llc [email protected]@coryfoy.com - @cory_foy...

31
IronRuby for the .NET Developer Cory Foy - Cory Foy, LLC [email protected] - @cory_foy + + =

Upload: gabriel-price

Post on 18-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

IronRuby for the .NET DeveloperCory Foy - Cory Foy, [email protected] - @cory_foy

+ +

=

Page 2: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

• Hello, IronRuby!

Page 3: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

History

Ruby and .NET

Ruby to .NET

Ruby CLR Project

RubyCLR

All attempted to run Ruby on top of the CLR

Page 4: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 5: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 6: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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);

Page 7: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 8: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 9: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

History

DLR

Dynamic Language Runtime (DLR)

Common Language Runtime (CLR)

Common Hosting Model

RuntimeLanguage

Implementation

Page 10: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

History

Ruby

Common Language Runtime

Dynamic Language RuntimeC#VB

Page 11: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

WHY RUBY?

Page 12: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 13: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 14: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

TYPE SAFETY

STATIC CODE ANALYSIS

COMPILER CATCHES ERRORS

INTELLISENSE

OBJECT GRAPHS

DEBUGGING

CODE SAFETY

SEALED TYPES

Page 15: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

TESTALLTHE FRICKIN’TIME

Page 16: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 17: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 18: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

Duck Typing

Page 19: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

Open Classes

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

NEON_OPEN_SIGN.JPG

Page 20: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

Monkey Patching

Page 21: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

Dynamism

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

UEST/3510995344/

Page 22: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

method_missing

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

Page 23: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

RubyGems

Standardized Packaging System

Central Repository for hosting packages

Allows for installation and management of multiple installed versions

Page 24: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

RubyGems

THAT’S IT!

Page 25: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

IronRuby Basics

Installing

http://ironruby.net/Download

Download Windows Installer

???

Profit!!!

Page 26: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 27: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

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

Page 28: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

Integration

Calling .NET from IronRuby

Calling IronRuby from .NET

WinForms / WPF / Silverlight

Cucumber / RSpec

Page 29: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

Get Involved!Website - http://ironruby.net

http://ironruby.codeplex.com/

http://github.com/ironruby

Mailing List - http://rubyforge.org/mailman/listinfo/ironruby-core

[email protected] | @cory_foy Slides @ http://blog.coryfoy.com

Page 30: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =
Page 31: IronRuby for the.NET Developer Cory Foy - Cory Foy, LLC foyc@coryfoy.comfoyc@coryfoy.com - @cory_foy + + =

© 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.