Page 1 Ruby by Tim Hanson & Mamadou Seck. Page 2 Philosophy "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming,

Slides:



Advertisements
Similar presentations
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Introduction to Ruby.
Advertisements

Names and Bindings.
Language of the Month If it’s December, it must be Ruby! Adam Coffman and Brent Beer.
And other languages….  The Ruby Programming Language, Flanagan & Matsumoto (creator of Ruby)
Ruby The Gem of new programming languages. An interpreted scripting language.
Chapter 2 - Java Programming Fundamentals1 Chapter 2 Java Programming Fundamentals.
ASP.NET Programming with C# and SQL Server First Edition
JavaScript, Third Edition
Scripting with Ruby What is a scripting language? What is Ruby?
VB .NET Programming Fundamentals
Introduction to Ruby CSE 413 Autumn 2008 Credit: Dan Grossman, CSE341.
Introduction to PHP. PHP PHP is the Hypertext Pre-processor –Script language –Embedded into HTML –Runs as Apache module –Can use DB (MySQL, Oracle, Microsoft.
A TOUR OF RUBY 2011 ACM Class, Dong Xie. What is Ruby?  Dynamic programming language  Complex but expressive grammar  A core class library with rich.
SCRIPTING IN RUBY By Amber Bennett “Ruby is simple in appearance, but is very complex inside, just like our human body.” --Yukihiro Matsumoto.
Ruby! Useful as a scripting language – script: A small program meant for one time use – Targeted towards small to medium size projects Use by: – Amazon,
Programming Language C++ Xulong Peng CSC415 Programming Languages.
Ruby. Who am I? 1- Bunlong Van 2- Sreyleap Lay, 3- Chhon Meily Blog:
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Introduction to Scheme Lectures on The Scheme Programming Language, 2 nd Ed. R. Kent Dybvig.
Computer Science 101 Introduction to Programming.
CPS120: Introduction to Computer Science
A very basic overview of Server-Side Scripting Or what is PHP, Perl, Python, Ruby and what can they do for me?
Trends in Scripting Languages History For me the purpose of life is partly to have joy. Programmers often feel joy when they can concentrate on the creative.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
USING RUBY An Introduction By Evgeny Rahman. About Me Principal Engineer at FirstFuel Software 10+ years in Software Engineering 5 years working with.
Perl Language Yize Chen CS354. History Perl was designed by Larry Wall in 1987 as a text processing language Perl has revised several times and becomes.
And other languages….  Array literals/initialization a = [1,2,3] a2 = [-10..0, 0..10] a3 = [[1,2],[3,4]] a4 = [w*h, w, h] a5 = [] empty = Array.new zeros.
Data TypestMyn1 Data Types The type of a variable is not set by the programmer; rather, it is decided at runtime by PHP depending on the context in which.
Introducing Python CS 4320, SPRING Resources We will be following the Python tutorialPython tutorial These notes will cover the following sections.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
+ Ruby and other programming Languages Ronald L. Ramos.
Copyright Curt Hill Variables What are they? Why do we need them?
Python Primer 1: Types and Operators © 2013 Goodrich, Tamassia, Goldwasser1Python Primer.
Scripting with Ruby What is a scripting language? What is Ruby?
CS105 Computer Programming PYTHON (based on CS 11 Python track: lecture 1, CALTECH)
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
RUBY by Ryan Chase.
Chapter 4 Literals, Variables and Constants. #Page2 4.1 Literals Any numeric literal starting with 0x specifies that the following is a hexadecimal value.
Scripting with Ruby What is a scripting language? What is Ruby?
PHP vs. Python. Similarities are interpreted, high level languages with dynamic typing are Open Source are supported by large developer communities are.
Python Let’s get started!.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
CPS120: Introduction to Computer Science Variables and Constants.
1 Getting Started with Ruby. 2 What’s Ruby? Ruby is an OO, dynamic, agile language –Everything’s an object For example, try puts -1.abs –Derives strengths.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Introduction to information systems RUBY dr inż. Tomasz Pieciukiewicz.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Ruby Tien Ho and Brandon Hostetter. Overview ▸ Object-oriented, functional, imperative, and reflective ▸ Interpreted language ▸ Influenced by Perl, Smalltalk,
Presented By P.SRIVIDYA 085D1A0552 Programming Language.
Information and Computer Sciences University of Hawaii, Manoa
Ruby: An Introduction Created by Yukihiro Matsumoto in 1993 (named after his birthstone) Pure OO language (even the number 1 is an instance of a class)
Scope History of Ruby. Where can you use Ruby? General Features.
Python Let’s get started!.
Introduction Python is an interpreted, object-oriented and high-level programming language, which is different from a compiled one like C/C++/Java. Its.
Ruby and other languages….
Introduction to Python
Introduction to C++ Programming
Introduction to Python
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
Python Primer 1: Types and Operators
The C Language: Intro.
PHP an introduction.
Presentation transcript:

Page 1 Ruby by Tim Hanson & Mamadou Seck

Page 2 Philosophy "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language.” - Yukihiro « Matz » Matsumoto

Page 3 History Created in Japan in the mid-1990s Christmas 1996: Version 1 released 2000: First English book printed 2005: Ruby on Rails popularized it 2008: Ruby version released 2010: Ruby version released (not fully compatible with Rails 3.0)

Page 4 Overview Influenced by Perl, Smalltalk, Eiffel, and Lisp Supports Multiple Programming Paradigms Functional Object-Oriented Imperative Reflective Dynamic typing Automatic Memory Management Interactive Ruby Shell Centralized Package Management via RubyGems

Page 5 TIOBE Index

Page 6 Multiple Implementations  Ruby MRI – Matz’ Ruby Interpreter Written in C Single pass interpreted language Slow Compatible with Rails 3  Just-in-time Compilation implementations YARV, JRuby, Rubinius, Iron Ruby, HotRuby MacRuby (ahead-of -time compilation too)  Ruby Based on YARV Unicode support Changes broke many unmaintained gems Rails 3 not fully supported

Page 7 Performance

Page 8 Command Line Utilities  ri – ruby index works like man in linux  irb – interactive ruby shell  gem – RubyGem package manager works like apt-get or yum in linux but installs ruby packages (gems) likes rails  ruby – runs ruby scripts ruby script.rb shebang line : #! /usr/bin env ruby

Page 9 Identifiers and Scope  Identifiers  Can’t include white space  Can’t include nonprinting characters  Case sensitive  First character denotes scope $ - global - instance variables - class variables Lower case letter or underscore - local variables Upper case letter – constant Capital letter – constant (convention – all caps) Capital letter – class (convention – CamelCase) Method ending with: ? - return boolean value (convention) ! – use with caution (convention for mutators) = - can be invoxed using assignment syntax

Page 10 Data Types  Numeric Integer – automatically converts between subtypes Fixnum Bignum – arbitrary precision Float Digit has to appear on both sides of decimal point i.e. can’t write just.1 BigDecimal – arbitrary precision Complex Rational  No primitives – everything is an object

Page 11 Data Types Continued  Symbols prefixed by : Lightweight strings  Strings Many methods for String processing Can be single quoted or double quoted Can use any non-alphanumeric delimiter %!Also a valid string!  Hashes Key – Value pairs like Dictionaries in Python  Arrays Untyped Mutable Elements don’t have to be from same class 0 is the first element and -1 is the last element Methods size and length both return size Self expanding Nil extended if assign element beyond the end

Page 12 Assignment  Parallel assignment  No pre or post increment or decrement operators  Conditional Assignment  x || = “default” #assigned if x is nil or false  x && = “other” #assigned if x is NOT nil or false  Self Assignment Operators x += 2 x - = 2 x *= 2 x /= 2 x **= 2

Page 13 Flow Control  If statement Keywords if, then, elseif, else, end Parentheses optional Multiple forms  Ternary Operator

Page 14 Loops  Many Different Ways to Write Loops

Page 15 Loops Continued  One line loops use braces

Page 16 Loops Continued  More Ways to Do the Same Loop

Page 17 Loops Continued  Even More Ways

Page 18 Example Programs

Page 19 Readability  Pros  Identifier naming conventions denote scope  Methods ending in ? are boolean  Methods ending in ! are dangerous  Braces used for one liners  Begin and End used for blocks  Doesn’t require semicolons  Cons  Many different ways to do the same thing  Precedence in arguments to function calls can be confusing because () are optional  There are no keywords or reserved words - You can override everything

Page 20 Writability  Pros  Many ways to do the same thing  Dynamic Typing  Can write really compact code  Functional Programming is powerful  Debugging is easy with interpreter  Extensive Libraries Available  Cons  None

Page 21 Reliability  Pros  Supports Exception Handling  Interpreter allows for rapid testing  Cons  Dynamically Typed  Allows Aliasing  Many third party libraries are not maintained  Multiple language implementations that do not work exactly the same

Page 22 Cost  Pros  Open Source  Free Compilers  Rapid Development Cycle  Netbeans adds IDE support  Feature multiplicity makes learning basics of Ruby easy for new developers  Cons  Mastering all of Ruby takes a long time  Slow Execution  you might have to rewrite your code in a new language at some point

Page 23 Who uses Ruby? Amazon Basecamp BBC CISCO EA Funnyordie.com IBM JP Morgan Lucent NASA Oakley Penny-arcade.com Pitchforkmedia.com Oracle Scribd.com Siemens Twitter Yahoo!

Page 24 References  en.wikipedia.org/wiki/Ruby_%28programming_la nguage%29 en.wikipedia.org/wiki/Ruby_%28programming_la nguage%29  BLOG.OBIEFERNANDEZ.COM BLOG.OBIEFERNANDEZ.COM  loops-and-iterators/ loops-and-iterators/   ruby-lang.org ruby-lang.org