Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

20061216 rubyvspython


Published on

  • Be the first to comment

  • Be the first to like this

20061216 rubyvspython

  1. 1. Why not Ruby? vs. python Wang Yu Hui Porss Inc., Ltd [email_address]
  2. 2. History and Motivation <ul><li>• Ruby is a programming language developed by Yukihiro </li></ul><ul><li>Matsumoto (a.k.a. Matz) in 1993 </li></ul><ul><li>It was originally designed to be a better Perl than Perl (that‘s the reason for its name) </li></ul><ul><li>• It is available on multiple platforms such as Linux, MacOS X, </li></ul><ul><li>Windows </li></ul><ul><li>• According to Matz its primary application domains are Text </li></ul><ul><li>processing, CGI-, Network-, GUI-, XML-programming, </li></ul><ul><li>Prototyping, Programming education </li></ul><ul><li>• Ruby has adopted features from languages such as Perl, Lisp, </li></ul><ul><li>Smalltalk </li></ul><ul><li>• It is very popular in Asia, especially in Japan </li></ul>
  3. 3. What’s Ruby? <ul><li>• Paradigm: Pure OO language </li></ul><ul><li>• Simple and without surprises: Easy to learn and understand </li></ul><ul><li>• Potential: Powerful and expressive </li></ul><ul><li>• Add Ons: Rich library support </li></ul><ul><li>• Productive: Rapid development </li></ul><ul><li>• Non commercial: Open Source </li></ul><ul><li>• Robust: Garbage Collector on Board </li></ul><ul><li>• Flexible: Untyped, dynamic language </li></ul><ul><li>• And of course: It‘s cool! </li></ul>
  4. 4. Small Example <ul><li>#This is just to show you an example </li></ul><ul><li>class MyFirstRubyProgram </li></ul><ul><li>def SayHello(name=“ Cooler “) </li></ul><ul><li>puts &quot;Hello, #{name}!&quot; </li></ul><ul><li>end </li></ul><ul><li>end </li></ul><ul><li>“ Benjamin &quot;) </li></ul>Comments Define a class Default parameter Define a function
  5. 5. Everything is an object <ul><li>&quot;Hello World!&quot;.length </li></ul><ul><li>-42.abs </li></ul><ul><li>nil is a regular object </li></ul>
  6. 6. Regular expressions are well supported <ul><li>s = &quot;Hello World&quot; </li></ul><ul><li>p s.gsub(/[aeiou]/,“*&quot;) </li></ul><ul><li>H*ll* W*rld </li></ul><ul><li>t = &quot;11:55:00“ </li></ul><ul><li>if t =~ /dd:dd:dd/ </li></ul><ul><li>then </li></ul><ul><li>puts &quot;yes&quot; </li></ul><ul><li>else </li></ul><ul><li>puts &quot;no&quot; </li></ul><ul><li>end </li></ul><ul><li>yes </li></ul>
  7. 7. Ruby Vs. Python <ul><li> </li></ul><ul><li>GUI, Graphics, Web, Libs … </li></ul>
  8. 8. Overview <ul><li>HighLevel , GarbageCollected , and DynamicallyTyped </li></ul>
  9. 9. Heritage and Philosophy <ul><li>Ruby </li></ul><ul><ul><li>from Smalltalk and Perl </li></ul></ul><ul><ul><li>EverythingIsAnObject </li></ul></ul><ul><ul><li>ThereIsMoreThanOneWayToDoIt </li></ul></ul><ul><li>Python </li></ul><ul><ul><li>from Algol and Lisp </li></ul></ul><ul><ul><li>There should be one - and preferably only one - obvious way to do it. </li></ul></ul>
  10. 10. Code Style <ul><li>Red/Black Tree Implementation </li></ul><ul><li>Ruby : </li></ul><ul><li>Python: </li></ul><ul><li>Python indenting vs. Ruby explicit 'end‘ </li></ul><ul><li>Python requirement for explicit 'self' parameter to methods and instance variable access is very annoying </li></ul><ul><li>Ruby OO completeness is a win over Python </li></ul><ul><li>Ruby rescue/ensure vs. Python try/catch/finally </li></ul><ul><li>Ruby “Syntax error” vs. Python “call stack” </li></ul>
  11. 11. Community and Documentation <ul><li>Ruby </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li> </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><li>Python </li></ul><ul><ul><li>CPUG </li></ul></ul><ul><ul><li>I think ruby community is better and more friendly  </li></ul></ul>
  12. 12. Libs <ul><li>Python has better UNICODE support </li></ul><ul><li>Python's libraries are more plentiful and more mature </li></ul><ul><li>Ruby, however, can take advantage of Python libraries through the use of Ruby/Python </li></ul><ul><li>Ruby's API for C integration is much, much cleaner than Python's </li></ul>
  13. 13. GUI <ul><li>Ruby </li></ul><ul><ul><li>Tcl/tk </li></ul></ul><ul><li>Python </li></ul><ul><ul><li>Tcl/tk </li></ul></ul><ul><ul><li>wxPython </li></ul></ul><ul><ul><li>PyGTK </li></ul></ul><ul><ul><li>PyQT </li></ul></ul><ul><ul><li>PySWT </li></ul></ul>
  14. 14. Graphics and Images <ul><li>Ruby </li></ul><ul><ul><li>rmagick </li></ul></ul><ul><li>Python </li></ul><ul><ul><li>PIL: Python Imaging Library </li></ul></ul><ul><ul><li>PyOpenGL </li></ul></ul><ul><ul><li>Blender </li></ul></ul><ul><ul><li>matplotlib </li></ul></ul><ul><ul><li>yapgvb </li></ul></ul>
  15. 15. Web Development <ul><li>Ruby </li></ul><ul><ul><li>Ruby On Rails </li></ul></ul><ul><li>Python </li></ul><ul><ul><li>mod python + Apache </li></ul></ul><ul><ul><li>zope/plone </li></ul></ul><ul><ul><li>karrigell </li></ul></ul><ul><ul><li>cherrypy </li></ul></ul><ul><ul><li>django </li></ul></ul><ul><ul><li>turbogears </li></ul></ul>
  16. 16. Ruby on Rails <ul><li>full-stack, open-source web framework (support structure) in Ruby </li></ul><ul><li>Creating a weblog in 15 minutes </li></ul><ul><li>Model-View-Control pattern </li></ul><ul><li>From theAjax in the view, to the request and response in the controller, to the domain model wrapping the database </li></ul><ul><li>Web2.0 </li></ul>
  17. 17. Websites <ul><li> </li></ul><ul><li> </li></ul><ul><li>http:// </li></ul>
  18. 18. Embedded <ul><li>Ruby </li></ul><ul><ul><li>Ruby for Symbian </li></ul></ul><ul><li>Python </li></ul><ul><ul><li>Python for Symbian </li></ul></ul>
  19. 19. Lib Install <ul><li>Ruby </li></ul><ul><ul><li>RubyGems </li></ul></ul><ul><li>Python </li></ul><ul><ul><li>Every module has it’s own method </li></ul></ul>
  20. 20. Resources <ul><li>Programming Ruby </li></ul><ul><li>Learning Ruby from an Indian </li></ul><ul><li>Why Ruby? </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul><ul><li> </li></ul>