jimmy hacking (at) Microsoft
-
Upload
jimmy-schementi -
Category
Technology
-
view
988 -
download
0
Transcript of jimmy hacking (at) Microsoft
jimmy hacking (at) microsoftjimmy 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 TreeReturn
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 2box [mscorlib]System.Int32ldarg.0 // load “a”call object LangHelpers::Add(object, object)ret
IL
public static object Add (object x, object y) { ... }
public static object Add (object x, object y) { ... }
Runtime Library
compiler back-end on DLR
Syntax Tree
Return
Add
Named(a)Const(2)
GenerateDLR Tree
DLR TreeReturn
MethodCallLangHelpers.Add
BoundExpression
ConstantExpression2
ConvertToObject
Variablea: Object
two ways to call
def yo (name): "hello " + nameprint yo("jimmy")
MethodCallExpression
Method : {RuntimeMethodInfo {Name: "Print"}}Arguments : [0] ActionExpression
MethodCallExpression
Method : {RuntimeMethodInfo {Name: "Print"}}Arguments : [0] ActionExpression
ActionExpressionyo("jimmy")
Action : CallActionArguments : [0] {BoundExpression {Variable: Local{yo}}} [1] {ConstantExpression {"jimmy"}}
ActionExpressionyo("jimmy")
Action : CallActionArguments : [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
"eval" of any language, in any language
Auto CompletionStatic Language: Easy
Auto CompletionDynamic Language: Holy Crap
class Foo def bar endendFoo.class_eval do def baz endendf = Foo.newclass << f def bang endend
f.
WTF?WTF?
REPL
Lisp
ReadEvalPrint
read eval print loopread eval print loop
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/sdlsdkhttp://github.com/jschementi/agdlr
http://codeplex.com/ironpythonhttp://ironruby.nethttp://codeplex.com/dlr
Recap
Silverlight lets you do crazy things with Ruby/Python
REPLs are awesomeRuby is crazy
DLR: Write a language without the compiler
Open source rocks
http://peaceplusone.com/img/hippie.jpg