PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Ruby

Ruby

Ruby is a programming language created in 1995 by Yukihiro Matsumoto.

Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan. According to its creator, Ruby was influenced by Perl, Smalltalk, Eiffel, Ada, and Lisp. Read more on Wikipedia...

Try now: Riju ยท TIO ยท Replit

#10on PLDB 27Years Old 357.7kUsers

Example code from Riju:

puts "Hello, world!"

Example code from hello-world:

#!/usr/bin/env ruby print "Hello World"

Example code from the Hello World Collection:

# Hello World in Ruby puts "Hello World!"

Example code from Linguist:

module Foo end

Example code from Wikipedia:

"Hello, World!".in_blue => "<span style=\"color: #00f\">Hello, World!</span>"

Keywords in Ruby

__ENCODING__ __FILE__ __LINE__ alias and BEGIN begin break case class def defined do else elsif END end ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield

Language features

Feature Supported Example Token
Conditionals โœ“
Functions โœ“
While Loops โœ“
Case Sensitivity โœ“
Range Operator โœ“
(3...6)
Line Comments โœ“
# A comment
#
Print() Debugging โœ“
puts "Hi"
puts
Operator Overloading โœ“
Multiline Strings โœ“
Mixins โœ“
module A
   def a1
   end
   def a2
   end
end
module B
   def b1
   end
   def b2
   end
end
class Sample
include A
include B
   def s1
   end
end
samp = Sample.new
samp.a1
samp.a2
samp.b1
Iterators โœ“
(0...42).each do |n|
  puts n
end
File Imports โœ“
load 'filename.rb'
require 'filename'
require 'trig.rb'
Directives โœ“
coding: UTF-8
Generators โœ“
# Generator from an Enumerator object
chars = Enumerator.new(['A', 'B', 'C', 'Z'])

4.times { puts chars.next }

# Generator from a block
count = Enumerator.new do |yielder|
  i = 0
  loop { yielder.yield i += 1 }
end

100.times { puts count.next }
Garbage Collection โœ“
MultiLine Comments โœ“
=begin
A comment.
=end
=begin =end
Comments โœ“
# This is a single line comment.
Classes โœ“
# A tiny Person class in Ruby:
class Person
  attr_accessor :name, :age, :   # getter and setter methods
  def initialize(name, age)
    @name = name
    @age = age
  end
end

# Create a new Person object:
person = Person.new("John", 30)
puts person.name
puts person.age

# Change the age of the person:
person.age = 35
puts person.age
Constants โœ“
# Constants in Ruby being with a capital letter. Will throw a warning or error, depending on runtime settings.
Name = "John"  
# Not a constant
name = "John"
Exceptions โœ“
def hello
 puts "Hello, World!"
   # start an exception handler
   begin
       raise "This is an exception"
   rescue => e
       puts "Exception caught: #{e}"
   end
 end
hello
Assignment โœ“
score = 100
Booleans โœ“ true false
Integers โœ“
score = 100
Duck Typing โœ“
Regular Expression Syntax Sugar โœ“
puts "Hello World".match(/\w/)
Strings โœ“
"hello world"
"
Semantic Indentation ฯด
Async Await ฯด
Function Overloading ฯด
Dispose Blocks Pattern ฯด
Dependent types ฯด

Trending Ruby repos on GitHub

repo stars description
dev.to 10232 Where programmers share ideas and help each other grow
rails 44018 Ruby on Rails
faker 8005 "A library for generating fake data such as names addresses and phone numbers."
jekyll 38586 ๐ŸŒ Jekyll is a blog-aware static site generator in Ruby
metasploit-framework 17501 Metasploit Framework
liquid 7357 "Liquid markup language. Safe customer facing template language for flexible web apps."
mastodon 18765 "Your self-hosted globally interconnected microblogging community"
devise_token_auth 2818 Token based authentication for Rails JSON APIs. Designed to work with jToker and ng-token-auth.
homebrew-core 6353 ๐Ÿป Default formulae for the missing package manager for macOS
devise 20171 Flexible authentication solution for Rails with Warden.
explore 1303 Community-curated topic and collection pages on GitHub
fastlane 26631 ๐Ÿš€ The easiest way to automate building and releasing your iOS and Android apps
awesome-space 637 ๐Ÿ›ฐ๏ธ๐Ÿš€A list of awesome space-related packages and resources maintained by The Orbital Index
discourse 28975 "A platform for community discussion. Free open simple."
rest-client 4728 "Simple HTTP and REST client for Ruby inspired by microframework syntax for specifying actions."
huginn 22091 Create agents that monitor and act on your behalf. Your agents are standing by!
logstash 10512 "Logstash - transport and process your logs events or other data"
sidekiq 9802 "Simple efficient background processing for Ruby"
solidus 2706 "Solidus Rails eCommerce System"
brew 18868 ๐Ÿบ The missing package manager for macOS (or Linux)
classroom 1116 "GitHub Classroom automates repository creation and access control making it easy for teachers to distribute starter code and collect assignments on GitHub."
factory_bot 6596 A library for setting up Ruby objects as test data.
CocoaPods 11889 The Cocoa Dependency Manager.
ruby 16129 The Ruby Programming Language [mirror]
sinatra 10680 Classy web-development dressed in a DSL (official / canonical repo)

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements ยท Email ยท GitHub