RUBY by Ryan Chase.

Slides:



Advertisements
Similar presentations
Semantics Static semantics Dynamic semantics attribute grammars
Advertisements

Review for Final Exam Dilshad M. NYU. In this review Arrays Pointers Structures Java - some basic information.
Language of the Month If it’s December, it must be Ruby! Adam Coffman and Brent Beer.
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Ruby The Gem of new programming languages. An interpreted scripting language.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays –Structures of related data items –Static entity (same size throughout program) A few types –Pointer-based.
Chapter 6 C Arrays Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc. Arrays are data structures.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
String Escape Sequences
Review of C++ Programming Part II Sheng-Fang Huang.
Ruby (on Rails) CSE 190M, Spring 2009 Week 1. The Players Kelly "Everyday I'm Hustlin' " Dunn Kim "Mouse" Todd Ryan "Papa T" Tucker.
Hello AP Computer Science!. What are some of the things that you have used computers for?
CSE 341, S. Tanimoto Concepts 1- 1 Programming Language Concepts Formal Syntax Paradigms Data Types Polymorphism.
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.
General Purpose Language Ruby Kit Chan COMP3351 Programming Languages November 9, 2007.
CIS Computer Programming Logic
Programming With Java ICS201 University Of Ha’il1 Chapter 8 Polymorphism and Abstract Classes.
Chapter 1 - Introduction
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
JAVA 0. HAFTA Algorithms FOURTH EDITION Robert Sedgewick and Kevin Wayne Princeton University.
Ruby on Rails. What is Ruby? Programming Language Object-oriented Interpreted.
An Introduction to Python Blake Brogdon. What is Python?  Python is an interpreted, interactive, object-oriented programming language. (from python.org)
Interpretation Environments and Evaluation. CS 354 Spring Translation Stages Lexical analysis (scanning) Parsing –Recognizing –Building parse tree.
C# Programming Fundamentals Control Flow Jim Warren, COMPSCI 280 S Enterprise Software Development.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Smalltalk (and Squeak) Aida Dungan and Rick Shreve.
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.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
CSE 154 LECTURE 5: INTRO TO PHP. URLs and web servers usually when you type a URL in your browser: your computer looks up the.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
+ Ruby and other programming Languages Ronald L. Ramos.
CS105 Computer Programming PYTHON (based on CS 11 Python track: lecture 1, CALTECH)
Hello Computer Science!. Below is an example of a Hello World program in JAVA. While it is only three lines of code, there are many things that are happening.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Interfaces and Inner Classes
By Mr. Muhammad Pervez Akhtar
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
© 2007 Pearson Addison-Wesley. All rights reserved2-1 Character Strings A string of characters can be represented as a string literal by putting double.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
1 PHP Intro PHP Introduction After this lecture, you should be able to: Know the fundamental concepts of Web Scripting Languages in general, PHP in particular.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
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,
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Python Programming Language by Vasu Chetty. Origins of Python Created by: Guido van Rossum, a Dutch Programmer Created during: Christmas Break, 1989 Created.
Definition of the Programming Language CPRL
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.
Representation, Syntax, Paradigms, Types
CS230 Tutorial Week 3.
Programming Language Concepts (CIS 635)
Arrays, For loop While loop Do while loop
Introduction to Python
PHP.
Representation, Syntax, Paradigms, Types
Representation, Syntax, Paradigms, Types
Representation, Syntax, Paradigms, Types
Arrays Arrays A few types Structures of related data items
Presentation transcript:

RUBY by Ryan Chase

Yukihiro “Matz” Matsumoto The name “Ruby” was chosen before any of the coding for the language was started. It is said to have been the birthstone of a colleague of Matz. When he was first introduced to programming as a student he believed that he could be the designer of an ideal programming language. After having researched further, Matz imagined he could create a language more powerful than Perl and even more object-oriented than Python. This is the motivation that drove Matz to the development of Ruby.

History of Ruby Object-oriented Interpreted Compilation is not required Ruby 1.0 released in 1996 Current Version: Ruby 1.9.1

Uses of Ruby Ruby is an all-purpose language. Here is a list of applications that Ruby would be a suitable programming language to use for development: Text processing  CGI programming Network programming  XML programming  GUI applications AI and Exploratory Mathematics General programming  Prototyping  Programming education  eXtreme programming Fast Web Development

Unique Features Everything is an object – Ruby is a pure object-oriented programming language in that everything is automatically an object. This isn’t true in other object-oriented languages. Here is an example: 5.times { puts "Hello World" }   This simple code will print out “Hello World” five times in a row, each one with a new line. Implicit return value in methods – The value of the last expression in a method becomes the return value of the method. In Ruby, the return keyword is optional. In the following example, 8 is the return value: def testMethod      x = 4+4   end Missing unary operators in Ruby – Unary operators ++ and — are not supported in Ruby. Instead you can use += operator.

Unique Features Ruby supports parallel assignment – It is possible to change multiple variables in a single assignment. A good example is the swapping of two variables as given below:   a, b = b, a   In Ruby strings are mutable – In Ruby it is possible to change a string variable in place. So, unlike Java, the same string when used multiple times will point to different object instances: print "hello".object_id   print "hello".object_id   # prints a different value   a = "hello"   a[1] = "a"   print a  # prints hallo  

Unique Features True and false in Ruby – In Ruby only nil and false evaluate to false. This means that everything else evaluates to true. Hence even the value 0 evaluates to true in ruby. The following code will output “Hello World”:   if (0) then      print "Hello World"   end  Method indicators – In Ruby the last character of a method name can indicate its behavior. If the method ends with a question mark it indicates that the return value is boolean. If the method ends with an exclamation, it indicates that the method can change the state of the object. In many cases a non exclamation version of the method is provided which modifies a copy of the object.

Ruby is a Hybrid Ruby is a hybrid of iterative, functional, and declarative, just like C++ and Java because it is object oriented. Ruby can do declarative things, but also can do much more. Therefore, it is definitely a hybrid.

Primitives Everything is an object with a type associated with it. These include: Numbers Fixnum Bignum Float String Boolean

Combining Features Ruby combines its features in a very standard way. Here is an example from a factorial program that shows how different features can be combined: def factorial(y) if y==0 return 1 else return (y*factorial(y-1)) end

Abstraction Methods of abstraction can be features of the language that allow you to focus on the algorithm and be less worried about the computer’s needs. Examples of Methods of Abstraction: Variables Objects Arrays Classes Functions Loops

Return Values Ruby does not have to return values in its methods and it can return values just like we are used to with other languages like Java and C++. If the return value is not specified (by the keyword “return”) at the end of a method, the value of the last expression in the method is defined as the return value of the method.

First Class In Ruby you can pass functions into other functions. You can return functions from other functions Ruby allows you to nest functions inside of other functions.

More Features The way Ruby passes its variables in by value, not by reference, result, or name. Has type errors, cannot perform arithmetic expressions on strings, etc. Ruby does NO automatic type checking Ruby is a strong dynamic typed language Ruby does coerce types, but it does change the type for you in the background Ruby uses type inference

Dynamic, Static, and Inheritance Ruby provides single inheritance All classes inherit from a common parent. The variable inheritance is static The method inheritance is dynamic Super-method invocation is handled statically

Conclusion Ruby Rocks! Get it? It is a wonderful, all-purpose programming language It is a very simple-to-use language that gets right to the point puts “ ” is a lot easier to type than system.out.println(“ “); Hardly any brackets and no semicolons I would use this language again!