Ruby (programming language): Difference between revisions

Content deleted Content added
m replaced: it's → its (2)
m WP:LINKs: add, update-standardizes, needless WP:PIPE > WP:NOPIPE. Small WP:COPYEDITs WP:EoS WP:TERSE.
Line 80:
Ruby 2.0 was intended to be fully backward compatible with Ruby 1.9.3. As of the official 2.0.0 release on February 24, 2013, there were only five known (minor) incompatibilities.<ref name="2-0-release-incompatibilities"/> Ruby 2.0 added several new features, including:
 
* method[[Method (computer programming)|Method]] keyword arguments,
* aA new method, <code>Module#prepend</code>, forto extendingextend a class,
* aA new literal forto creatingcreate an array of symbols,
* newNew API for the [[lazy evaluation]] of Enumerables, and
* aA new convention of using #to_h to convert objects to Hashes.<ref name="Endoh"/>
 
Starting with 2.1.0, Ruby's versioning policy changed to be more similar to [[semantic versioning]].<ref name="semantic-versioning"/>
Line 146:
}}
 
Ruby is [[Object-oriented programming|object-oriented]]: every value is an object, including classes and instances of types that many other languages designate as primitives (such as [[Integer (computer science)|integers]], booleans, and "[[null pointer|null]]"). Variables always hold references to objects. Every [[function (programming)|function]] is a [[methodMethod (computer programming)|method]] and methods are always called on an object. Methods defined at the top level scope become methods of the Object class. Since this class is an ancestor of every other class, such methods can be called on any object. They are also visible in all scopes, effectively serving as "global" procedures. Ruby supports [[inheritance (object-oriented programming)|inheritance]] with [[dynamic dispatch]], [[mixin]]s and singleton methods (belonging to, and defined for, a single [[instance (computer science)|instance]] rather than being defined on the class). Though Ruby does not support [[multiple inheritance]], classes can import [[moduleModular (programming)|modules]] as mixins.
 
Ruby has been described as a [[multi-paradigm programming language]]: it allows procedural programming (defining functions/variables outside classes makes them part of the root, 'self' Object), with object orientation (everything is an object) or [[functional programming]] (it has [[anonymous function]]s, [[Closure (computer science)|closures]], and [[continuation]]s; statements all have values, and functions return the last evaluation). It has support for [[Introspection (computer science)|introspection]], [[Reflectionreflective (computer science)|reflectionprogramming]] and, [[metaprogramming]], as well as support forand interpreter-based [[Thread (computer science)|threads]]. Ruby features [[Type system|dynamic typing]], and supports [[parametric polymorphism]].
 
According to the Ruby FAQ, the syntax is similar to [[Perl]]'s and the semantics are similar to [[Smalltalk|Smalltalk's]], but the design philosophy differs greatly from [[Python (programming language)|Python]]'s.<ref name="faq-comparison" />
Line 158:
* Everything is an [[Expression (programming)|expression]] (even [[Statement (programming)|statements]]) and everything is executed [[Imperative programming|imperatively]] (even [[Declaration (computer science)|declarations]])
* Succinct and flexible syntax<ref name="venners-productivity" /> that minimizes [[syntactic noise]] and serves as a foundation for [[___domain-specific languages]]<ref name="fowler-dsl" />
* Dynamic [[ReflectionReflective (computer science)programming|reflection]] and [[Dynamic programming language#Object runtime alteration|alteration]] of objects to facilitate [[metaprogramming]]<ref name="codeproject-dynamic" />
* [[Closure (computer science)|Lexical closures]], [[iterator]]s and [[Generator (computer science)|generators]], with a [[Ruby syntax#Blocks and iterators|block syntax]]<ref name="venners-closures" />
* Literal notation for [[Dynamic array|arrays]], [[Associative array|hashes]], [[regular expression]]s and [[Symbol (Lisp)|symbols]]