Ruby (programming language): Difference between revisions

Content deleted Content added
RsRado (talk | contribs)
m Updated the URL of the "Reasons behind Ruby" talk
m WP:ADOPTYPO boolean -> Boolean
Line 2:
{{distinguish|Ruby on Rails}}
{{Technical|introduction|date=June 2022}}
 
{{infobox programming language
| logo = Ruby logo.svg
Line 105 ⟶ 106:
* Unify ''Fixnum'' and ''Bignum'' into ''Integer'' class
* String supports Unicode case mappings, not just ASCII
* A new method, Regexp#match?, which is a faster booleanBoolean version of Regexp#match
* Thread deadlock detection now shows threads with their backtrace and dependency
 
Line 147 ⟶ 148:
}}
 
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]], booleansBooleans, and "[[null pointer|null]]"). Because everything in Ruby is an object, everything in Ruby has certain built-in abilities called methods. Every [[function (programming)|function]] is a [[Method (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 [[Modular 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]], [[reflective programming]], [[metaprogramming]], and interpreter-based [[Thread (computer science)|threads]]. Ruby features [[Type system|dynamic typing]], and supports [[parametric polymorphism]].
Line 167 ⟶ 168:
* [[Garbage collection (computer science)|Garbage collection]]
* [[First-class continuation]]s
* Strict booleanBoolean [[Implicit type conversion|coercion]] rules (everything is ''true'' except <code>false</code> and <code>[[Null pointer|nil]]</code>)
* [[Exception handling]]
* [[Operator overloading]]<ref name="Methods"/>