A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.
Ruby is a language of careful balance. Its creator, Yukihiro “Matz” Matsumoto, blended parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, and Lisp) to form a new language that balanced functional programming with imperative programming.
Since its public release in 1995, Ruby has drawn devoted coders worldwide. In 2006, Ruby achieved mass acceptance. With active user groups formed in the world’s major cities and Ruby-related conferences filled to capacity.
Ruby is ranked among the top 10 on most of the indices that measure the growth and popularity of programming languages worldwide (such as the TIOBE index). Much of the growth is attributed to the popularity of software written in Ruby, particularly the Ruby on Rails web framework.
ruby一直位于编程语言top10，很多增长来自于使用ruby编写的软件，比如ruby on rails；
Initially, Matz looked at other languages to find an ideal syntax. Recalling his search, he said, “I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python.”
Ruby is seen as a flexible language, since it allows its users to freely alter its parts. Essential parts of Ruby can be removed or redefined, at will. Existing parts can be added upon. Ruby tries not to restrict the coder.
Ruby, as a language, has a few different implementations. This page has been discussing the reference implementation, in the community often referred to as MRI (“Matz’s Ruby Interpreter”) or CRuby (since it is written in C), but there are also others. They are often useful in certain situations, provide extra integration to other languages or environments, or have special features that MRI doesn’t.
JRuby is Ruby atop the JVM (Java Virtual Machine), utilizing the JVM’s optimizing JIT compilers, garbage collectors, concurrent threads, tool ecosystem, and vast collection of libraries.
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp ruby:2.6.2 ruby your-daemon-or-script.rb
# 1 install rbenv
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv $ cd ~/.rbenv && src/configure && make -C src $ echo ‘export PATH="$HOME/.rbenv/bin:$PATH"‘ >> ~/.bash_profile $ source ~/.bash_profile $ ~/.rbenv/bin/rbenv init
# 2 install ruby-build plugin $ mkdir -p "$(rbenv root)"/plugins $ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
# 3 install ruby $ rbenv install -l $ rbenv install 2.6.2
# 4 use ruby
$ rbenv shell 2.6.2
$ ruby -v
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
$ ruby test.rb
$ rbenv install 2.6.2
BUILD FAILED (CentOS 7.4.1708 using ruby-build 20190314-4-g8e70553)
Inspect or clean up the working tree at /tmp/ruby-build.20190319152414.23377
Results logged to /tmp/ruby-build.20190319152414.23377.log
Last 10 log lines:
installing html-docs: /root/.rbenv/versions/2.6.2/share/doc/ruby
installing capi-docs: /root/.rbenv/versions/2.6.2/share/doc/ruby
The Ruby readline extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `yum install -y readline-devel` to fetch missing dependencies.
yum install -y readline-devel
$ cat /tmp/test.rb puts ‘hello world‘ $ ruby /tmp/test.rb hello world
ruby有很多应用，比如logstash、ruby on rails等；