1. What is Ruby?
Ruby is a simple object-oriented programming language that is easy to get started with and powerful. She was a Japanese Yukihiro Matsumoto (everyone called him Matz.) was first released in 1995. Ruby has borrowed a lot from the Perl language (some people say that Ruby is the beautiful sister of Perl:), like Perl, Ruby is also good at text processing, system management, and more. Like Smalltalk, Ruby is a purely object-oriented language, and everything is an object. Here are some features of the Ruby language:
Simple and elegant grammar
Explanatory-type execution, quick and easy
Fully Object oriented
Built-in regular engine for text processing
has many advanced features (operator overloading, mix-ins, Singleton Methods, ...). )
Elegant and perfect exception handling mechanism
Automatic garbage collection
Highly portable (can be run on Windows, Unix, Linux, MacOS)
2. What does Ruby do? Let me see some ruby language code!
As a general-purpose programming language, Ruby, like other common programming languages, can write most of the tasks we encounter on a day-to-day basis, and do it in a simpler and more elegant way. She has been used to write Web server programs, scientific computing programs, video game software, and other interesting applications. More people use her to do the prototype experiment and deal with the trivial programming tasks encountered every day.
You want to see the ruby code? OK, here's the code for a few simple programs written in Ruby:
# 1-Print 3 times "Hello, world!"
3.times do
print "Hello, world!\n"
end
# 2-Compute "1 + 2 + 3 + ... + 100"sum = 0
for i in 1..100
sum += i
end
print "1+2+3+...+100 = ", sum, "\n"
# 3-Simple method calldef hello(name)
print "Hello, ", name, "\n"
end
hello("jellen")