jimmy hacking (at) Microsoft

1,243 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,243
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
22
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • jimmy hacking (at) Microsoft

    1. 1. jimmy hacking (at) microsoft wpi | flaud | 2008-11-24 open source programming languages
    2. 2. I'm back!
    3. 3. Jimmy Schementi http://blog.jimmy.schementi.com
    4. 5. 2002-2007
    5. 18. Jimmy, show Logo Demo!
    6. 24. .testing
    7. 25. Terminology Java Language  C# Java Platform  .NET Platform (CLR) Flash + Java applets + JavaFX  Silverlight
    8. 26. IronPython 1.0
    9. 27. September 2006
    10. 28. Python 2.4 Compatible
    11. 29. CLR great for dynamic languages But requires a lot of work
    12. 30. DLR Dynamic Language Runtime
    13. 31. Compiler Infrastructure
    14. 32. compiler front-end return Syntax Tree Return def add2(a) { return 2 + a; } Scan 2 + a ; Parse Token stream Add Named(a) Const(2)
    15. 33. 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
    16. 34. 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
    17. 35. two ways to call <ul><li>def yo (name): </li></ul><ul><li>&quot;hello &quot; + name </li></ul><ul><li>print yo(&quot;jimmy&quot;) </li></ul>MethodCallExpression Method : {RuntimeMethodInfo {Name: &quot;Print&quot;}} Arguments : [0] ActionExpression ActionExpression yo(&quot;jimmy&quot;) Action : CallAction Arguments : [0] {BoundExpression {Variable: Local{yo}}} [1] {ConstantExpression {&quot;jimmy&quot;}}
    18. 36. <ul><li>public static object Handle ( </li></ul><ul><li>object[] args, DynamicSite<object, object, object> site1, </li></ul><ul><li>object obj1, object obj2) </li></ul><ul><li>{ </li></ul><ul><li>if (obj1 != null && obj1.GetType() == typeof(string) && </li></ul><ul><li>obj2 != null && obj2.GetType() == typeof(string)) </li></ul><ul><li>{ </li></ul><ul><li>return StringOps.Add(Converter.ConvertToString(obj1), </li></ul><ul><li> Converter.ConvertToString(obj2)); </li></ul><ul><li>} </li></ul><ul><li>return site1.UpdateBindingAndInvoke(obj1, obj2); </li></ul><ul><li>} </li></ul>
    19. 37. <ul><li>public static object Handle ( </li></ul><ul><li>object[] args, DynamicSite<object, object, object> site1, </li></ul><ul><li>object obj1, object obj2) </li></ul><ul><li>{ </li></ul><ul><li>if (obj1 != null && obj1.GetType() == typeof(int) && </li></ul><ul><li>obj2 != null && obj2.GetType() == typeof(int)) </li></ul><ul><li>{ </li></ul><ul><li>return Int32Ops.Add(Converter.ConvertToInt(obj1), </li></ul><ul><li> Converter.ConvertToInt(obj2)); </li></ul><ul><li>} </li></ul><ul><li>if (obj1 != null && obj1.GetType() == typeof(string) && </li></ul><ul><li>obj2 != null && obj2.GetType() == typeof(string)) </li></ul><ul><li>{ </li></ul><ul><li>return StringOps.Add(Converter.ConvertToString(obj1), </li></ul><ul><li> Converter.ConvertToString(obj2)); </li></ul><ul><li>} </li></ul><ul><li>return site1.UpdateBindingAndInvoke(obj1, obj2); </li></ul><ul><li>} </li></ul>
    20. 38. Hosting &quot;eval&quot; of any language, in any language
    21. 39. Auto Completion Static Language: Easy
    22. 40. 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?
    23. 41. REPL
    24. 42. Lisp Read Eval Print
    25. 43. r ead e val p rint l oop
    26. 49. Jimmy, show Ruby Demo!
    27. 50. Jimmy, show DLRConsole Demo!
    28. 52. Jimmy, show console=true Demo!
    29. 53. Jimmy, show embedding Demo!
    30. 56. rails + silverlight demo
    31. 57. http://www.flickr.com/photos/marchange/444184871/
    32. 59. <ul><li>http://silverlight.net </li></ul><ul><li>http://codeplex.com/sdlsdk </li></ul><ul><li>http://github.com/jschementi/agdlr </li></ul><ul><li>http://codeplex.com/ironpython </li></ul><ul><li>http://ironruby.net </li></ul><ul><li>http://codeplex.com/dlr </li></ul>
    33. 60. 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
    34. 61. http://peaceplusone.com/img/hippie.jpg

    ×