TechDays - IronRuby

1,697 views

Published on

Presentation of IronRuby given in Sweden at TechDays on 24th March 2010

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,697
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Dynamic language
  • Static > Dynamic. Dynamic are more flexible, can adapt the applications frameworks to fit your requirements. Produce similar results, cleaner code and provide a nicer experience for developers. As a result, the code is easier to maintain. Ruby community – testable, clean, natural, expressive => open source
  • Git branch master (demo)Git branch to_json_via_ruby (monkey patch)
  • http://www.flickr.com/photos/lastrounds/3199561205/sizes/o/
  • C:UsersBen HallDocumentsSourceControlEmbeddedIronRubyGit branch demoGit branch master (complete)
  • C:UsersBen HallDocumentsSourceControlMEFEnabledGit branch master (demo)Git branch with_ruby (complete)
  • TechDays - IronRuby

    1. 1. IronRuby – A brave new world for .Net<br />@Ben_Hall, Developer ester, 7digital.com<br />Ben@BenHall.me.uk <br />Blog.BenHall.me.uk CodeBetter.com/blogs/BenHall<br />
    2. 2. London (UK) based C# MVPWeb Developer @ 7digital.com Working on a number of Open Source Projects<br />Co-Author of <br />Testing ASP.net Web Applications<br />http://www.testingaspnet.com<br />
    3. 3. Agenda<br />Ruby<br />IronRuby<br />DLR<br />Merging IronRuby and C#<br />
    4. 4. What is Ruby?<br />
    5. 5. Why?<br />
    6. 6. Right language for the right job<br />
    7. 7. Everything is an object<br />“Hello World”.upcase<br />[5,3,4,1,6].sort<br />10.times { |i| puts “Loop count: #{i}” }<br />
    8. 8. Blocks<br />10.times do |i|<br /> puts “Loop count: #{i}”<br />end<br />Loop count: 0<br />Loop count: 1<br />Loop count: 2<br />Loop count: 3<br />Loop count: 4<br />Loop count: 5<br />Loop count: 6<br />Loop count: 7<br />Loop count: 8<br />Loop count: 9<br />
    9. 9. Blocks<br />search_engines =   %W[Google Yahoo Bing].map do |engine|    "http://www.#{engine.downcase}.com"  end<br />search_engines = [<br /> ‘http://www.google.com’, <br /> ‘http://www.yahoo.com’, <br /> ‘http://www.bing.com’<br />]<br />
    10. 10. Natural Programming<br />x = [1,2,3]<br />y = [4,5,6]<br />>>> x + y <br />=> [1,2,3,4,5,6]<br />
    11. 11. Duck Typing<br /># Message sends itself via some transport protocol<br />class Message<br /> def publish(transport)<br /> puts transport.send(self)<br /> end<br />end<br />http://www.flickr.com/photos/normis/337183421/<br />
    12. 12. Duck Typing<br />class Queue<br /> def send(message)<br /> @server.open<br /> @server.issue(message)<br /> @server.close<br /> end<br />end<br />
    13. 13. Duck Typing<br />class SmtpService<br /> def send(message)<br /> @service.post(message) <br /> end<br />end<br />
    14. 14. Duck Typing<br />m = Message.new<br />m.subject = “Hello TechDays!”<br />q = Queue.new<br />s = SmtpService.new<br />m.publish(q)<br />m.publish(s)<br />
    15. 15. Duck Typing<br />class Postman<br /> def send(message)<br />phone_number = 012398622<br />@john.call(phone_number)<br /> end<br />end<br />m.publish(Postman.new)<br />
    16. 16. Mixins<br />class ProductPage < CMS::BasePage<br />include Editable    includeThemeable<br />includeDroppableCustomisations<br />end<br />
    17. 17. Extendable<br />class Fixnum<br /> def odd?() <br /> !even?<br /> end<br /> def even?()<br /> self % 2 == 0<br /> end<br />end<br />>>> 1.odd?<br />=> true<br />>>> 1.even?<br />=> false<br />>>> 2.odd?<br />=> false<br />>>> 2.even?<br />=> true<br />
    18. 18. Blended of multiple languages<br />
    19. 19. “Ruby is simple in appearance, but is very complex inside, just like our human body”<br />Yukihiro “matz” Matsumoto – Creator of Ruby<br />
    20. 20. “trying to make Ruby natural, not simple”<br />Yukihiro “matz” Matsumoto – Creator of Ruby<br />
    21. 21. Frameworks<br />Rails (Web)<br />ActiveRecord (ORM)<br />Sinatra (Web)<br />RSpec (BDD Unit Testing)<br />Cucumber (Acceptance Testing)<br />
    22. 22. If that’s Ruby<br />What’s IronRuby?<br />http://www.flickr.com/photos/bflv/3328427869/<br />
    23. 23. DEMOs<br />
    24. 24. Static language => Dynamic language<br />http://github.com/BenHall/IronRuby_CSharp_Type_Interop<br />
    25. 25. Ruby Frameworks - Exposing NHibernate domain model in a ‘RESTful’ way<br />http://github.com/BenHall/IronRestfulRails<br />
    26. 26. @post = r.GetPost("PostID", params[:id].to_i)class PostRepository def method_missing(m, *args)columnName = m.id2name.sub(/find_by_/, "")get_postcolumnName, *args endend@post = r.find_by_PostID 1@post = r.find_by_Title “Post 1"<br />http://github.com/BenHall/IronRestfulRails<br />
    27. 27. Ruby Frameworks - erb<br />http://github.com/BenHall/IronRuby_Erb_Templating<br />
    28. 28. C# Frameworks - WPF<br />
    29. 29. C# Frameworks - MeerPush<br />http://github.com/BenHall/MeerPush<br />
    30. 30. What is the DLR?<br />http://www.flickr.com/photos/lastrounds/3199561205/sizes/o/<br />
    31. 31. IronPython<br />?<br />
    32. 32. Combing the two worlds<br />http://www.flickr.com/photos/mendhak/2117622450/sizes/o/<br />
    33. 33. Embedding IronRuby into C#<br />http://github.com/BenHall/EmbeddedIronRuby<br />
    34. 34. Extending C# applications using Ruby and MEF<br />http://github.com/BenHall/ExtendViaMEF<br />
    35. 35. Data Gen Screenshot<br />
    36. 36. Reflector Screenshot<br />
    37. 37. Resolver Systems<br />
    38. 38. C# 4.0 - dynamic<br /> static void Main(string[] args)<br /> {<br />Console.WriteLine("Executing from C#");<br />ScriptRuntime runtime = IronRuby.Ruby.CreateRuntime();<br />ScriptScope scope = runtime.ExecuteFile("person.rb");<br /> dynamic person = scope.Engine.Execute("Person.new");<br />person.say_hello();<br />Console.ReadLine();<br /> }<br />Program.cs<br />person.rb<br />class Person<br /> def say_hello<br /> puts "Hello world from IronRuby!"<br /> end<br />end<br />http://github.com/BenHall/IronRuby_CSharp_4<br />
    39. 39. Testing C# applications<br />http://github.com/BenHall/wipflash_cucumber_driven_example<br />
    40. 40. Ruby Everywhere! <br />
    41. 41. How will the DLR <br />change<br />your world?<br />
    42. 42. @Ben_Hall<br />Ben@BenHall.me.uk<br />Blog.BenHall.me.uk<br />http://lolcatgenerator.com/lolcat/120/<br />
    43. 43. Utvärdera gärna sessionen.<br /> Dina synpunkter är mycket värdefulla för oss. Därför är vi mycket tacksamma för att du tar dig någon minut att utvärdera den session som du just har lyssnat på. Besök din MINT-profil* i din mobil, gå till dina sessioner och klicka på ”utvärdera”.<br /> In English: Your feedback is very valuable to us. Therefore, we are very grateful that you take a minute to evaluate the session that you just listened to. <br />Tack!<br />*MINT är en mobil tjänst för evenemang och möten som bland annan erbjuder dig möjligheten att utvärdera de sessioner du besöker direkt i din mobil. Om du saknar mobil eller inte kan komma åt MINT av annan anledning har vi fysiska utvärderingar i pappersform. <br />

    ×