130 likes | 266 Views
A Tour of ruby. 2011 ACM Class, Dong Xie. What is Ruby?. Dynamic programming language Complex but expressive grammar A core class library with rich and powerful APIs Draws inspiration from Lisp , Smalltalk and Perl Easy for C and Java programmers to learn
E N D
A Tour of ruby 2011 ACM Class, Dong Xie
What is Ruby? • Dynamicprogramming language • Complex but expressive grammar • A core class library with rich and powerful APIs • Draws inspiration from Lisp, Smalltalk and Perl • Easy for C and Java programmers to learn • Ruby is designed to make programmers happy. ——By Yukihiro Matsumoto
Simplified Expressions • Optionalparentheses • Parallel assignment • Punctuation Suffixes and Prefixes
Everything is an Object • Completelyobject-oriented language • Seeing Everything as an Object • even simple numeric literals and the values true, false and nil • Only single inheritance, the Mixin(Module)
Everything has a value • NOdifference between expressionsand statements • Everything has a value, even if that value is nil • Even control structures have their own value such as if, while, etc.
Classes are Open • Dynamic Programming Language • Not only dynamic-typed (like python, PHP, etc.) • Allows its users to freely alter its parts • Add, Remove, Redefine
Singleton methods • Per-object methods • Only available on the Object you defined it on
Iterators and Blocks • “A truly expressive feature” • Iterators —— loops • Blocks—— associate with a method invocation
Procs and Lambdas • Class Proc, Kernel.Lambda • Functions that can be manipulated as objects • Block as a single parameter • Instances of class Proc as parameters
And more… • Symbols are not lightweight strings • “Variable” constants • Fake keyword parameters • The universal truth • Missing methods • Metaprogramming capability • Packages —— RubyGems • ……
To learn more… • Official Site: http://www.ruby-lang.org/en/ • Ruby in a Nutshell • The Ruby Programming Language • The Book of Ruby • Programming Ruby • Ruby Cookbook
Q&A Any questions are welcomed…
Thanks for Listening Contact: xiedong1993@gmail.com