jimmy hacking (at) microsoft wpi | flaud | 2008-11-24 open source programming languages
I'm back!
Jimmy Schementi http://blog.jimmy.schementi.com
 
2002-2007
 
 
 
 
 
 
 
 
 
 
 
 
Jimmy, show Logo Demo!
 
 
 
 
 
.testing
Terminology Java Language  C# Java Platform  .NET Platform (CLR) Flash + Java applets + JavaFX  Silverlight
IronPython 1.0
September 2006
Python 2.4 Compatible
CLR great for dynamic languages But requires a lot of work
DLR Dynamic Language Runtime
Compiler Infrastructure
compiler front-end return Syntax Tree Return def add2(a) { return 2 + a; } Scan 2 + a ; Parse Token stream Add Named(a) Const(2)
compiler back-end on CLR Syntax Tree Return Add Named(a) Const(2) Generate IL ldc.i4.2 // load 2 box [mscorlib]System.Int32 ldarg.0 // load “a” call object LangHelpers::Add(object, object) ret IL public static object Add (object x, object y) { ... } Runtime Library
compiler back-end on DLR Syntax Tree Return Add Named(a) Const(2) Generate DLR Tree DLR Tree Return MethodCall LangHelpers.Add BoundExpression ConstantExpression 2 ConvertTo Object Variable a: Object
two ways to call def yo (name): "hello " + name print yo("jimmy") MethodCallExpression Method : {RuntimeMethodInfo {Name: "Print"}} Arguments : [0] ActionExpression ActionExpression yo("jimmy") Action : CallAction Arguments : [0] {BoundExpression {Variable: Local{yo}}} [1] {ConstantExpression {"jimmy"}}
public static object Handle ( object[] args, DynamicSite<object, object, object> site1, object obj1, object obj2) { if (obj1 != null && obj1.GetType() == typeof(string) && obj2 != null && obj2.GetType() == typeof(string)) { return StringOps.Add(Converter.ConvertToString(obj1), Converter.ConvertToString(obj2)); } return site1.UpdateBindingAndInvoke(obj1, obj2); }
public static object Handle ( object[] args, DynamicSite<object, object, object> site1, object obj1, object obj2) { if (obj1 != null && obj1.GetType() == typeof(int) && obj2 != null && obj2.GetType() == typeof(int)) { return Int32Ops.Add(Converter.ConvertToInt(obj1), Converter.ConvertToInt(obj2)); } if (obj1 != null && obj1.GetType() == typeof(string) && obj2 != null && obj2.GetType() == typeof(string)) { return StringOps.Add(Converter.ConvertToString(obj1), Converter.ConvertToString(obj2)); } return site1.UpdateBindingAndInvoke(obj1, obj2); }
Hosting &quot;eval&quot; of any language, in any language
Auto Completion Static Language: Easy
Auto Completion Dynamic Language: Holy Crap class Foo def bar end end Foo .class_eval do def baz end end f = Foo.new class << f def bang end end f. WTF?
REPL
Lisp Read Eval Print
r ead e val p rint l oop
 
 
 
 
 
Jimmy, show Ruby Demo!
Jimmy, show DLRConsole Demo!
 
Jimmy, show console=true Demo!
Jimmy, show embedding Demo!
 
 
rails + silverlight demo
http://www.flickr.com/photos/marchange/444184871/
 
http://silverlight.net http://codeplex.com/sdlsdk http://github.com/jschementi/agdlr http://codeplex.com/ironpython http://ironruby.net http://codeplex.com/dlr
Recap Silverlight lets you do crazy things with Ruby/Python REPLs are awesome Ruby is crazy DLR: Write a language without the compiler Open source rocks
http://peaceplusone.com/img/hippie.jpg
 

jimmy hacking (at) Microsoft