Ruby (programming language): Difference between revisions

Content deleted Content added
use a sensible date format
Removed 6 redlinks via script.
 
(13 intermediate revisions by 11 users not shown)
Line 1:
{{Short description|General-purpose programming language}}
{{distinguish|Ruby on Rails}}
 
{{infobox programming language
| logo = Ruby logo.svg
Line 29 ⟶ 28:
== History ==
=== Early concept ===
According to Matsumoto, Ruby was conceived in 1993. In a 1999 post to the Ruby-Talk mailing list, he shared some of his early ideas about the language:<ref>{{cite web|url=https://www.ruby-doclang.org/docsen/ruby-doc-bundledocumentation/FAQfaq/FAQ.html|title=TheOfficial Ruby Language FAQ|author=Shugo Maeda|date=17 December 2002|access-date=2 March 2014}}</ref>
 
{{Blockquote|I was talking with my colleague about the possibility of an object-oriented scripting language. I knew Perl (Perl4, not Perl5), but I didn't like it really, because it had the smell of a [[toy language]] (it still has). The object-oriented language seemed very promising. I knew [[Python (programming language)|Python]] then. But I didn't like it, because I didn't think it was a true object-oriented language{{snd}} OO features appeared to be add-on to the language. As a language maniac and OO fan for 15 years, I really wanted a genuine object-oriented, easy-to-use scripting language. I looked for but couldn't find one. So I decided to make it.}}
Line 45 ⟶ 44:
After the release of Ruby 0.95 in 1995, several stable versions of Ruby were released in these years.<ref name="rubyconf-history-of-ruby"/>
 
In 1997, the first article about Ruby was published on the Web. In the same year, Matsumoto was hired by [[Network Applied Communication Laboratory|netlab.jp]] to work on Ruby as a full-time developer.<ref name="rubyconf-history-of-ruby"/>
 
In 1998, the Ruby Application Archive was launched by Matsumoto, along with a simple English-language homepage for Ruby.<ref name="rubyconf-history-of-ruby"/>
Line 96 ⟶ 95:
=== Ruby 3 ===
 
Ruby 3.0.0 was released on [[Christmas]] Day in 2020.<ref name="Ruby 3.0.0 Released"/> It is known as Ruby 3x3, which meanssignifies that programs would run three times faster in Ruby 3.0 comparing to Ruby 2.0.<ref>{{cite web |last=Scheffler |first=Jonan |date=10 November 2016 |title=Ruby 3x3: Matz, Koichi, and Tenderlove on the future of Ruby Performance |url=https://blog.heroku.com/ruby-3-by-3 |access-date=18 May 2019 |website=Ruby |language=en-US |archive-date=10 May 2019 |archive-url=https://web.archive.org/web/20190510225935/https://blog.heroku.com/ruby-3-by-3 |url-status=live }}</ref> and some had already implemented in intermediate releases on the road from 2 to 3. To achieve 3x3, Ruby 3 comes with MJIT, and later YJIT, Just-In-Time Compilers, to make programs faster, although they are described as experimental and remain disabled by default (enabled by flags at runtime).
 
Another goal of Ruby 3.0 is to improve [[Concurrency (computer science)|concurrency]] and two more utilities Fibre Scheduler, and experimental Ractor facilitate the goal.<ref name="Ruby 3.0.0 Released"/> Ractor is light-weight and thread-safe as it is achieved by exchanging messages rather than shared objects.
Line 106 ⟶ 105:
Ruby 3.1 was released on 25 December 2021.<ref name="Ruby 3.1.0 Released" /> It includes YJIT, a new, experimental, Just-In-Time Compiler developed by [[Shopify]], to enhance the performance of real world business applications. A new [[debugger]] is also included. There are some syntax enhancements and other improvements in this release. Network libraries for [[FTP]], [[SMTP]], [[IMAP]], and [[Post Office Protocol|POP]] are moved from default gems to bundled gems.<ref>{{cite web|url=https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released//|title=Ruby 3.1.0 Released|access-date=2021-12-26|archive-date=2021-12-26|archive-url=https://web.archive.org/web/20211226065055/https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released//|url-status=live}}</ref>
 
Ruby 3.2 was released on 25 December 2022.<ref name="Ruby 3.2.0 Released">{{Cite web|url=https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/|title=Ruby 3.2.0 Released|access-date=2022-12-25|archive-date=2022-12-25|archive-url=https://web.archive.org/web/20221225084459/https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/|url-status=live}}</ref> It brings support for being run inside of a [[WebAssembly]] environment via a WASI interface. [[Regular expression]]s also receives some improvements, including a faster, [[Memoizationmemoization|memoized]] matching algorithm to protect against certain [[ReDoS]] attacks, and configurable timeouts for regular expression matching. Additional debugging and syntax features are also included in this release, which include syntax suggestion, as well as error highlighting. The MJIT compiler has been re-implemented as a standard library module, while the YJIT, a [[Rust (programming language)|Rust]]-based [[Just-in-time compilation|JIT]] compiler now supports more architectures on Linux.
 
Ruby 3.3 was released on 25 December 2023.<ref name="Ruby 3.3.0 Released">{{Cite web|url=https://www.ruby-lang.org/en/news/2023/12/25/ruby-3-3-0-released/|title=Ruby 3.3.0 Released|access-date=2023-12-25|archive-date=2023-12-25|archive-url=https://web.archive.org/web/20231225071449/https://www.ruby-lang.org/en/news/2023/12/25/ruby-3-3-0-released/|url-status=live}}</ref> Ruby 3.3 introduces significant enhancements and performance improvements to the language. Key features include the introduction of the Prism parser for portable and maintainable parsing, the addition of the pure-Ruby JIT compiler RJIT, and major performance boosts in the YJIT compiler. Additionally, improvements in memory usage, the introduction of an M:N thread scheduler, and updates to the standard library contribute to a more efficient and developer-friendly Ruby ecosystem.
Line 137 ⟶ 136:
== Features ==
 
* Thoroughly [[Object-oriented programming|object-oriented]] with [[Inheritance (object-oriented programming)|inheritance]], [[mixin]]s and [[metaclass]]es<ref name="stewart" />
* [[Dynamic typing]] and [[duck typing]]
* Everything is an [[Expression (programming)|expression]] (even [[Statement (programming)|statements]]) and everything is executed [[Imperative programming|imperatively]] (even [[Declaration (computer science)|declarations]])
Line 160 ⟶ 159:
* Centralized package management through [[RubyGems]]
* Implemented on all major platforms
* Large standard library, including modules for [[YAML]], [[JSON]], [[XML]], [[Common Gateway Interface|CGI]], [[OpenSSL]], [[HTTP]], [[FTP]], [[RSS]], [[curses (programming library)|curses]], [[zlib]] and [[Tk (software)|Tk]]<ref name="stdlib-2.0.0master" />
* [[Just-in-time compilation]]
 
Line 184 ⟶ 183:
 
=== Alternative implementations ===
 
{{Cleanup red links|section|date=April 2025}}
 
{{As of|2018}}, there are a number of alternative implementations of Ruby, including [[JRuby]], [[Rubinius]], and [[mruby]]. Each takes a different approach, with JRuby and Rubinius providing [[just-in-time compilation]] and mruby also providing [[ahead-of-time compilation]].
Line 191 ⟶ 190:
 
* [[JRuby]], a mixed [[Java (programming language)|Java]] and Ruby implementation that runs on the [[Java virtual machine]]. JRuby currently targets Ruby 3.1.x.
* [[TruffleRuby]], a Java implementation using the Truffle language implementation framework with [[GraalVM]]
* [[Rubinius]], a [[C++]] bytecode virtual machine that uses [[LLVM]] to compile to machine code at runtime. The bytecode compiler and most core classes are written in pure Ruby. Rubinius currently{{when|date=April 2025}} targets Ruby 2.3.1.
 
Other Ruby implementations include:
Line 198 ⟶ 197:
* [[MagLev (software)|MagLev]], a [[Smalltalk]] implementation that runs on [[GemTalk Systems]]' [[Gemstone (database)|GemStone/S]] VM
* [[mruby]], an implementation designed to be embedded into C code, in a similar vein to [[Lua (programming language)|Lua]]. It is currently being developed by [[Yukihiro Matsumoto]] and others
* [[RGSS]], or Ruby Game Scripting System, a [[Proprietary software|proprietary]] implementation that is used by the [[RPG Maker]] series of [[role-playing game creation software]] for game design and modification of the RPG Maker [[game engine]]
* [[julializer]], a [[transpiler]] (partial) from Ruby to [[Julia (programming language)|Julia]]. It can be used for a large speedup over e.g. Ruby or JRuby implementations (may only be useful for numerical code).<ref name="virtual-module"/>
* [[Topaz (Ruby)|Topaz]], a Ruby implementation written in [[Python (programming language)|Python]]
* [[Opal (Ruby)|Opal]], a web-based interpreter that compiles Ruby to [[JavaScript]]
 
Other now defunct Ruby implementations were:
Line 208 ⟶ 207:
* Cardinal, an implementation for the [[Parrot virtual machine]]
* [[Ruby Enterprise Edition]], often shortened to ''ree'', an implementation optimized to handle large-scale [[Ruby on Rails]] projects
* [[HotRuby]], a [[JavaScript]] and [[ActionScript]] implementation of the [[Ruby programming language]]
 
The maturity of Ruby implementations tends to be measured by their ability to run the [[Ruby on Rails]] (Rails) framework, because it is complex to implement and uses many Ruby-specific features. The point when a particular implementation achieves this goal is called "the Rails singularity". The reference implementation, JRuby, and Rubinius<ref name="Rubinius"/> are all able to run Rails unmodified in a production environment.
Line 216 ⟶ 215:
Matsumoto originally developed Ruby on the [[BSD|4.3BSD]]-based [[Sony NEWS|Sony NEWS-OS]] 3.x, but later migrated his work to [[SunOS]] 4.x, and finally to [[Linux]].<ref name="Stodte"/><ref name="initial-development"/> By 1999, Ruby was known to work across many different [[operating system]]s. Modern Ruby versions and implementations are available on all major desktop, mobile and server-based operating systems. Ruby is also supported across a number of cloud hosting platforms like [[Jelastic]], [[Heroku]], [[Google Cloud Platform]] and others.
 
Tools such as [[Ruby Version Manager|RVM]] and [[RBEnv]], facilitate installation and partitioning of multiple ruby versions, and multiple 'gemsets' on one machine.
 
== Repositories and libraries ==
Line 240 ⟶ 239:
<ref name="Julia">{{cite web | url = https://docs.julialang.org/en/stable/ | title = Julia 1.0 Documentation: Introduction | access-date = 6 October 2018 | archive-date = 16 August 2018 | archive-url = https://web.archive.org/web/20180816025550/https://docs.julialang.org/en/stable/ | url-status = dead }}</ref>
<ref name="Burks">{{cite web | url = http://programming.nu/about | title = About Nu™ | last = Burks | first = Tim | work = Programming Nu™ | publisher = Neon Design Technology, Inc. | access-date = 2011-07-21 | archive-date = 2018-12-25 | archive-url = https://web.archive.org/web/20181225131630/http://programming.nu/about%0A%20 | url-status = live }}</ref>
<ref name="Ring and other languages">{{cite web | url = httphttps://ring-lang.sourceforge.net/doc1.6/introduction.html#ring-and-other-languages | title = Ring and other languages | author = Ring Team | date = 3 December 2017 | work = ring-lang.net | publisher = [[ring-lang]] | access-date = 3 December 2017 | archive-date = 25 December 2018 | archive-url = https://web.archive.org/web/20181225175312/http://ring-lang.sourceforge.net/doc1.6/introduction.html#ring-and-other-languages | url-status = live }}</ref>
<ref name="rust">{{Cite web |url=https://doc.rust-lang.org/reference/influences.html |title=Influences - The Rust Reference |website=The Rust Reference |access-date=2023-04-18 |archive-date=2019-01-26 |archive-url=https://web.archive.org/web/20190126051127/https://doc.rust-lang.org/reference/influences.html |url-status=live }}</ref>
<ref name="lattner2014">{{cite web | url = http://nondot.org/sabre/ | title = Chris Lattner's Homepage | last = Lattner | first = Chris | date = 2014-06-03 | access-date = 2014-06-03 | publisher = Chris Lattner | quote = The Swift language is the product of tireless effort from a team of language experts, documentation gurus, compiler optimization ninjas, and an incredibly important internal dogfooding group who provided feedback to help refine and battle-test ideas. Of course, it also greatly benefited from the experiences hard-won by many other languages in the field, drawing ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list. | archive-date = 2018-12-25 | archive-url = https://web.archive.org/web/20181225175312/http://nondot.org/sabre/ | url-status = live }}</ref>
Line 247 ⟶ 246:
<ref name="bini">{{ cite book | last = Bini | first = Ola | title = Practical JRuby on Rails Web 2.0 Projects: Bringing Ruby on Rails to Java | year = 2007 | publisher = APress | ___location = Berkeley | isbn = 978-1-59059-881-8 | page = [https://archive.org/details/practicaljrubyon0000bini/page/3 3] | quote = It draws primarily on features from Perl, Smalltalk, Python, Lisp, Dylan, and CLU. | url = https://archive.org/details/practicaljrubyon0000bini/page/3}}</ref>
<ref name="about">{{cite web|url=https://www.ruby-lang.org/en/about/|title=About Ruby|access-date=15 February 2020|archive-date=9 October 2014|archive-url=https://web.archive.org/web/20141009090312/https://www.ruby-lang.org/en/about/|url-status=live}}</ref>
<!-- <ref name="FAQ">{{cite web|url=https://www.ruby-doclang.org/docsen/ruby-doc-bundledocumentation/FAQfaq/FAQ.html|title=TheOfficial Ruby Language FAQ|author=Shugo Maeda|date=17 December 2002|access-date=2 March 2014|archive-date=27 February 2014|archive-url=https://web.archive.org/web/20140227064945/http://www.ruby-doc.org/docs/ruby-doc-bundle/FAQ/FAQ.html|url-status=live}}</ref> -->
<ref name="lisp-features">{{ cite web | url = http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/179642 | title = Re: Ruby's lisp features. | last = Matsumoto | first = Yukihiro | author-link = Yukihiro Matsumoto | date = 13 February 2006 | access-date = 15 February 2020 | url-status = dead | archive-url = https://web.archive.org/web/20181027195101/http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/179642 | archive-date = 2018-10-27}}</ref>
<ref name="rubyconf-history-of-ruby">{{cite web|url=http://blog.nicksieger.com/articles/2006/10/20/rubyconf-history-of-ruby|title=History of Ruby|access-date=2008-08-14|archive-date=2011-07-14|archive-url=https://web.archive.org/web/20110714181409/http://blog.nicksieger.com/articles/2006/10/20/rubyconf-history-of-ruby|url-status=live}}</ref>
<ref name="ruby-name">{{cite web|url=http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/88819|title=[FYI: historic] The decisive moment of the language name Ruby. (Re: [ANN] ruby 1.8.1)|type=E-mail from Hiroshi Sugihara to ruby-talk|access-date=2008-08-14|archive-date=2011-07-17|archive-url=https://web.archive.org/web/20110717205734/http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/88819|url-status=dead}}</ref>
<ref name="faq-name">{{cite web | url = https://www.ruby-doclang.org/docsen/ruby-doc-bundledocumentation/FAQfaq/1/FAQ.html | title = 1.3 Why the name 'Ruby'? | work = TheOfficial Ruby Language FAQ | publisher = Ruby-Doc.org | access-date = April 10, 2012 | archive-date = May 28, 2012 | archive-url = https://web.archive.org/web/20120528140926/http://www.ruby-doc.org/docs/ruby-doc-bundle/FAQ/FAQ.html | url-status = live }}</ref>
<ref name="ruby-talk-name">{{cite mailing list | url = http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/394 | title = Re: the name of Ruby? | mailing-list = Ruby-Talk | date = June 11, 1999 | author = [[Yukihiro Matsumoto]] | access-date = April 10, 2012 | archive-date = December 25, 2018 | archive-url = https://web.archive.org/web/20181225131629/http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/394%0A%20 | url-status = dead }}</ref>
<ref name="0.95">{{ cite web|url=http://eigenclass.org/hiki/ruby+0.95|title=More archeolinguistics: unearthing proto-Ruby|access-date=2 May 2015|url-status=dead|archive-url=https://web.archive.org/web/20151106023204/http://eigenclass.org/hiki/ruby+0.95|archive-date=6 November 2015}}</ref>
Line 267 ⟶ 266:
<ref name="2-0-release-incompatibilities">Endoh, Yusuke. (2013-02-24) [http://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/#label-8 Ruby 2.0.0-p0 is released] {{Webarchive|url=https://web.archive.org/web/20130227014031/http://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/#label-8 |date=2013-02-27 }}. Ruby-lang.org. Retrieved on 2013-07-17.</ref>
<ref name="semantic-versioning">{{cite web|url=https://www.ruby-lang.org/en/news/2013/12/21/semantic-versioning-after-2-1-0/|title=Semantic Versioning starting with Ruby 2.1.0|date=December 21, 2013|access-date=December 27, 2013|archive-date=February 13, 2014|archive-url=https://web.archive.org/web/20140213000634/https://www.ruby-lang.org/en/news/2013/12/21/semantic-versioning-after-2-1-0/|url-status=dead}}</ref>
<ref name="obsolete-or-gone-in-2.2">{{cite web|url=https://github.com/ruby/ruby/blob/v2_2_0/NEWS|title=ruby/NEWS at v2_2_0 · ruby/ruby · GitHub|work=GitHub|access-date=2 May 2015|archive-date=1 January 2015|archive-url=https://web.archive.org/web/20150101005836/https://github.com/ruby/ruby/blob/v2_2_0/NEWS|url-status=live}}</ref>
<ref name="2-2-1-release">{{cite web|url=https://www.ruby-lang.org/en/news/2015/03/03/ruby-2-2-1-released|title=Ruby 2.2.1 Released|access-date=12 July 2016|author=Gustavo Frederico Temple Pedrosa, Vitor de Lima, Leonardo Bianconi|year=2015|archive-date=16 May 2016|archive-url=https://web.archive.org/web/20160516080955/https://www.ruby-lang.org/en/news/2015/03/03/ruby-2-2-1-released/|url-status=live}}</ref>
<ref name="2-2-1-changelog">{{cite web|url=https://svn.ruby-lang.org/repos/ruby/tags/v2_2_1/ChangeLog|title=v2.2.1 ChangeLog|access-date=12 July 2016|author=Gustavo Frederico Temple Pedrosa, Vitor de Lima, Leonardo Bianconi|year=2015|archive-date=26 February 2017|archive-url=https://web.archive.org/web/20170226231425/http://svn.ruby-lang.org/repos/ruby/tags/v2_2_1/ChangeLog|url-status=dead}}</ref>
Line 287 ⟶ 286:
<ref name="venners-closures">{{cite web|url=http://www.artima.com/intv/closures.html|title=Blocks and Closures in Ruby|author=Bill Venners|access-date=2 May 2015|archive-date=18 April 2015|archive-url=https://web.archive.org/web/20150418162505/http://www.artima.com/intv/closures.html|url-status=live}}</ref>
<ref name="Methods">{{cite web|title=Methods|url=https://www.ruby-lang.org/en/documentation/faq/7/|website=Official Ruby FAQ|access-date=2021-06-20|archive-date=2022-06-28|archive-url=https://web.archive.org/web/20220628194402/https://www.ruby-lang.org/en/documentation/faq/7/|url-status=live}}</ref>
<ref name="stdlib-2.0.0master">{{cite web | url = https://wwwdocs.ruby-doclang.org/stdlib-2en/master/standard_library_md.0.0/html | title = Ruby 2.0.0 Standard Library Documentation | access-date = 2013-12-09 | last = Britt | first = James | archive-date = 2013-11-13 | archive-url = https://web.archive.org/web/20131113002837/http://www.ruby-doc.org/stdlib-2.0.0/ | url-status = live }}</ref>
<ref name="faq-comparison">{{cite web|url=http://www.rootr.net/rubyfaq-2.html|title=The Ruby Language FAQ: How Does Ruby Stack Up Against...?|access-date=2 May 2015|archive-date=8 May 2015|archive-url=https://web.archive.org/web/20150508051623/http://www.rootr.net/rubyfaq-2.html|url-status=live}}</ref>
<ref name="while">{{cite web|title=[ruby-talk:01120] Re: The value of while...|quote=In Ruby's syntax, statement is just a special case of an expression that cannot appear as an argument (e.g. multiple assignment).|url=http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/1120|access-date=2008-12-06|archive-date=2011-07-17|archive-url=https://web.archive.org/web/20110717205553/http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/1120|url-status=dead}}</ref>
Line 329 ⟶ 328:
 
* {{official website|https://www.ruby-lang.org/en/}}
* [https://wwwdocs.ruby-doclang.org/ Ruby documentation]
 
{{Ruby programming language}}