Semana Interop: Trabalhando com IronPython e com Ironruby
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Semana Interop: Trabalhando com IronPython e com Ironruby

  • 695 views
Uploaded on

Apresentação do IronPython e IronRuby ...

Apresentação do IronPython e IronRuby
O que é ? Rodamap, funcionalidades, Exemplos

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
695
On Slideshare
695
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 3
  • 2. Dynamic Languages Static Languages Simple and succinct Robust Implicitly typed Performant Meta-programming Intelligent tools No compilation Better scaling Late bound Type safety Loosely type Compile-time checking Highly expressive RunTime Performance 4
  • 3. Linguagem Tipagem Compilação Objetos Tipos C# Forte Estática Estáticos Estáticos VB.NET Forte ou Fraca Estática Estáticos Dinânicos Boo Forte Dinâmica Dinâmicos Dinâmicos Python Fraca Dinâmica Dinâmicos Dinâmicos Ruby Fraca Dinâmica Dinâmicos Dinâmicos 5
  • 4. 6
  • 5. 7
  • 6. print “Alo mundo” 8
  • 7. 9
  • 8. 10
  • 9. 11
  • 10. http://www.codeplex.com/IronPython 12
  • 11. 13
  • 12. http://blogs.msdn.com/hugunin/ http://blogs.msdn.com/hugunin/archive/2006/09/05/741605.aspx 14
  • 13. 15
  • 14. − I R O N 16
  • 15. 17
  • 16. 18
  • 17. Python Source File or Code Snippet Python Scanner Tokens Python Parser AST IL Generator IL CLR refs IronPython. Objects 19
  • 18. def factorial(n): if n == 1: return 1 return n * factorial(n-1) 0 LOAD_FAST 0 (n) IL_0000: ldarg.0 3 LOAD_CONST 1 (1) IL_0001: ldsfld object __main__::c$0$PST04000002 6 COMPARE_OP 2 (==) IL_0006: call object IronPython…Ops::Equal(object,object) 9 JUMP_IF_FALSE 8 (to 20) IL_000b: call bool IronPython...Ops::IsTrue(object) IL_0010: brfalse IL_0020 12 POP_TOP 13 LOAD_CONST 1 (1) IL_0015: ldsfld object __main__::c$0$PST04000002 16 RETURN_VALUE IL_001a: ret 20
  • 19. def factorial(n): if n == 1: return 1 return n * factorial(n-1) public static object factorial_f1(object n) { if (Ops.EqualIsTrue(n, 1)) return Main.c_1; return Ops.Multiply(n, Ops.Call(Main.factorial, Ops.Subtract(n, Main.c_1))); } 21
  • 20. 0 LOAD_FAST 0 (n) 3 LOAD_CONST 1 (1) 0000001b mov 0000001d mov ecx,esi edx,1 6 COMPARE_OP 2 (==) 00000023 call dword ptr ds:[036E3184h] 9 JUMP_IF_FALSE 8 (to 20) 00000028 mov 0000002a test 0000002c je edi,eax edi,edi 00000038 12 POP_TOP 13 LOAD_CONST 1 (1) 00000039 mov eax,dword ptr ds:[01B054E4h] 16 RETURN_VALUE <pop 4 registers and ret> 22
  • 21. Milhões de testes por segundo def t2(): for i in L: if i == 1000000: break <snip 18 identical lines> if i == 1000000: break 80 70 60 50 40 69 30 20 10 7 11 16 Python-2.1 Python-2.3 Python-2.4 15 21 0 IronPython on IronPython on IronPython on 1.1 2.0 2.0 w/opt 23
  • 22. 2 4
  • 23. 26
  • 24. 28
  • 25. Adding Dynamic to .NET IronPython IronRuby C# VB.NET Others… Dynamic Language Runtime Expression Trees Object Binder JavaScript Binder Dynamic Dispatch Python Binder Call Site Caching Ruby Binder COM Binder 29
  • 26. IronPython Consumindo C# public class Calculator { … public int Add(int x, int y) { return x + y; } } class Calculator: … def Add(self, x, y): return x + y calc = GetCalculator() sum = calc.Add(10, 20) 30
  • 27. C# 3.0 Consumindo IronPython public class Calculator { … public int Add(int x, int y) { return x + y; } } class Calculator: … def Add(self, x, y): return x + y PyObject calc = GetCalculator(); Calculator calc = GetCalculator(); object res = calc.Invoke("Add", 10, 20); int sum = calc.Add(10, 20); int sum = Convert.ToInt32(res); object calc = GetCalculator(); Type calcType = calc.GetType(); object res = calcType.InvokeMember("Add", BindingFlags.InvokeMethod, null, new object[] { 10, 20 }); int sum = Convert.ToInt32(res); 31
  • 28. 32
  • 29. 33
  • 30. 34
  • 31. binhara@monobrasil.org 3 5