Ruby: Josh Parker, Jay Stinso, Ryan Krcelic

Download Report

Transcript Ruby: Josh Parker, Jay Stinso, Ryan Krcelic

Ruby
The Gem of new programming
languages.
An interpreted scripting
language
Introductions
Speakers: Ryan Krcelic, Jay Stinson, and
Josh Parker
Recipe for Ruby
• Take a true object oriented language
• Give it a “clean” syntax. No
semicolons, brackets, or need to
declare variables.
• Add in a good measure of the flexibility
and convenience of languages such as
Python and Perl
The Evolution of Ruby
• Written by Yukihiro Matsumoto
• Evolved mainly from Perl and Python
• Designed to make programming easy
and fun.
• Ruby allows you to concentrate on the
creative side of programming, with less
stress about complicated syntax
More History
• 1993: conception, work begins
• Early 1995: implementation of the
interpreter (Japanese only)
• 1997: Version 1.0 released
• 1998: Development version released
• 2003: Version 1.6.8, large community
support and development
Some Features
• Object Oriented
language with
scripting
• Allows you to
access
underlying OS
features
• Variables declare
themselves
automatically
depending on the
data that is
assigned to them
• Strings can use
operators
More Features
• exception handling features, like Java
or Python, to make it easy to handle
errors
• Writing C extensions in Ruby is easier
than in Perl or Python
• Ruby features OS independent
threading. Thus, for all platforms on
which Ruby runs, you also have
multithreading, regardless of if the OS
supports it or not, even on MS-DOS!
Example A
hello = “Hello world/n”
hello = hello * 3
puts hello
This statement prints:
Hello world
Hello world
Hello world
The /n denotes the start of a new line.
EXAMPLE B
def sayGoodnight(name)
result = “Goodnight ” + name
return result
end
#This is a comment
puts sayGoodnight(“John”)
Example C
count = 0
sum = 10
#example of a for loop
5.times do
count += 1
sum += count
end
#Convert number to a string
puts sum.to_s
Compared to C++
Typing
Run Time
access to
method
names
Ruby
C++
Dynamic
Static
Yes
No
Metaclasses
Yes
No
Garbage
Collection
Yes
No
Sources
• http://www.rubycentral.com/book/
• http://www.ruby-lang.org/en/20020103.html