Generated by DeepSeek V3.2| Ruby (programming language) | |
|---|---|
| Name | Ruby |
| Paradigm | Multi-paradigm: object-oriented, imperative, functional, reflective |
| Designer | Yukihiro Matsumoto |
| Developer | Yukihiro Matsumoto and others |
| Released | 21 December 1995 |
| Latest release version | 3.3.3 |
| Latest release date | 12 June 2024 |
| Typing | Duck, dynamic, strong |
| Influenced by | Smalltalk, Perl, Lisp, Ada, Eiffel |
| Influenced | Crystal, Elixir, Swift, Groovy |
| Operating system | Cross-platform |
| License | Ruby License or BSD License (2-clause) |
| Website | https://www.ruby-lang.org/ |
Ruby (programming language). Ruby is a dynamic, open-source programming language with a focus on simplicity and productivity. It was created in the mid-1990s by Yukihiro Matsumoto in Japan, blending parts of his favorite languages like Perl, Smalltalk, and Lisp. The language is renowned for its elegant syntax that is natural to read and easy to write, and it powers the popular Ruby on Rails web application framework.
The language was conceived by Yukihiro Matsumoto in the early 1990s, with the first public release in 1995. Matsumoto, often known as "Matz," sought to create a language more powerful than Perl and more object-oriented than Python. Initial development was centered in Japan, and the language gained its first English-language book, *Programming Ruby* (the "PickAxe" book), in 2000, which helped spark international interest. A pivotal moment in its history was the 2004 release of the Ruby on Rails framework by David Heinemeier Hansson, which dramatically accelerated its adoption for web development worldwide. Since then, development has been guided by the Ruby Core Team, with major versions introducing significant performance and concurrency improvements.
Ruby is a purely object-oriented language where every value is an object, including primitive data types like integers. It supports multiple inheritance through the use of mixins and modules, providing a flexible way to share code. The language emphasizes developer happiness and productivity, offering features like automatic memory management and an extensive standard library. Other key characteristics include its support for introspection and metaprogramming, allowing programs to modify their own structure and behavior dynamically. The block and yield constructs enable powerful closures and are central to its iterator pattern.
Ruby's syntax is designed for readability, often resembling pseudocode or plain English. It uses keywords like `def` for defining methods and `class` for defining classes, and it typically omits parentheses where possible. The language employs sigils such as `$` for global variables and `@` for instance variables. A distinctive feature is its handling of code blocks, which can be written between `do...end` or curly braces `{...}`. Semantically, it is dynamically typed and uses duck typing, where an object's suitability is determined by the presence of methods rather than its class. The syntax also supports heredoc for multi-line strings and offers numerous syntactic sugar features, like shorthand notation for hash tables and symbols.
The primary and reference implementation is MRI (Matz's Ruby Interpreter), also known as CRuby, which is written in C. Another significant implementation is JRuby, which runs on the Java Virtual Machine and provides seamless integration with Java libraries. TruffleRuby is a high-performance implementation built on the GraalVM and the Truffle framework. Historically, Rubinius was an influential implementation written largely in Ruby itself, using a LLVM-based just-in-time compiler. Other notable implementations include mruby, a lightweight version designed for embedding, and Opal, which compiles Ruby to JavaScript.
The ecosystem is primarily distributed via RubyGems, its package management system. The most famous framework is Ruby on Rails, a full-stack model–view–controller framework that revolutionized web development with conventions like DRY and Convention over configuration. Other prominent web frameworks include Sinatra, a lightweight domain-specific language for creating web applications, and Hanami, a modern framework focusing on simplicity. Beyond web development, libraries like RSpec for behavior-driven development, Capybara for web application testing, and Sidekiq for background job processing are widely used. The ecosystem also includes tools like Bundler for dependency management and Jekyll for generating static websites.
The community is known for its strong ethos of collaboration and craftsmanship, often summarized in the MINASWAN ("Matz is nice and so we are nice") principle. Major annual conferences include RubyConf and RailsConf, which attract developers from around the globe. The language is the foundation for many high-traffic websites and companies, including GitHub, Shopify, Airbnb, and Twitch. While its adoption in data science and system programming is less dominant than in web development, ongoing work on performance in MRI and alternative implementations continues to expand its use cases. Development is stewarded by the Ruby Core Team and discussed through channels like the ruby-talk mailing list and the #ruby IRC channel.