Programming Languages Dan Grossman 2013 Everything is an Object.

Slides:



Advertisements
Similar presentations
Programming Languages Section 1 1 Programming Languages Section 1. SML Fundamentals Xiaojuan Cai Spring 2015.
Advertisements

C12, Polymorphism “many forms” (greek: poly = many, morphos = form)
CSE341: Programming Languages Lecture 19 Introduction To Ruby; Dynamic OOP; "Duck Typing" Dan Grossman Fall 2011.
CSE341: Programming Languages Lecture 20 Blocks & Procs; Inheritance & Overriding Dan Grossman Fall 2011.
CSE341: Programming Languages Lecture 26 Subtyping for OOP Dan Grossman Fall 2011.
Lisp. Versions of LISP Lisp is an old language with many variants –LISP is an acronym for List Processing language Lisp is alive and well today Most modern.
10 November JavaScript. Presentation Hints What do YOU think makes a good presentation Some of my suggestions Don’t write full sentences on slides Talk,
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
CSE341: Programming Languages Introduction To Ruby; Dynamic OOP; "Duck Typing" Alan Borning Autumn 2012 (slides borrowed from Dan Grossman)
Introduction to Ruby CSE 413 Autumn 2008 Credit: Dan Grossman, CSE341.
Ruby (on Rails) CSE 190M, Spring 2009 Week 1. The Players Kelly "Everyday I'm Hustlin' " Dunn Kim "Mouse" Todd Ryan "Papa T" Tucker.
Engr 691 Special Topics in Engineering Science Software Architecture Spring Semester 2004 Lecture Notes.
Ruby on Rails. What is Ruby? Programming Language Object-oriented Interpreted.
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Late binding and dynamic dispatch (Based on CSE 341 slides by Dan Grossman) 1.
CSE341: Programming Languages Lecture 20 Arrays and Such, Blocks and Procs, Inheritance and Overriding Dan Grossman Winter 2013.
CSE 341 Programming Languages Introduction to Ruby Zach Tatlock Spring 2014.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
CSE 413 Programming Languages & Implementation Hal Perkins Autumn 2012 Introduction to Ruby (adapted from CSE 341, Dan Grossman) 1.
CMSC330 Summer 2009 Kinga Dobolyi Introduction to Ruby.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
RUBY by Ryan Chase.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods Dan Grossman Spring 2013.
1 Javascript CS , Spring What is Javascript ? Browser scripting language  Dynamic page creation  Interactive  Embedded into HTML pages.
Wel come To Seminar On C#.
1 / 71 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 4 Programming Fundamentals using Java 1.
CMSC 330: Organization of Programming Languages Operational Semantics.
Programming Languages Dan Grossman 2013 ML Expressions and Variable Bindings.
Programming Languages Dan Grossman 2013 Classes and Objects.
FASTFAST All rights reserved © MEP Make programming fun again.
Programming Languages Dan Grossman 2013 Datatype-Programming in Racket Without Structs.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Spring 2016.
Programming Languages Dan Grossman 2013
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)
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Winter 2013.
CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods James Wilcox Winter 2017.
Programming Languages Dan Grossman 2013
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Spring 2017.
CSE 341 Section 9 Nick Mooney Spring 2017
CS230 Tutorial Week 3.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Autumn 2017.
ATS Application Programming: Java Programming
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods Zach Tatlock Winter 2018.
Alan Borning Spring 2018 (slides borrowed from Dan Grossman)
Java Programming Language
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Autumn 2018.
CSE341: Programming Languages Lecture 20 Arrays and Such, Blocks and Procs, Inheritance and Overriding Dan Grossman Autumn 2018.
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods Dan Grossman Autumn 2018.
CSE 341 Section 9 Winter 2018 Adapted from slides by Eric Mullen, Nick Mooney, Nicholas Shahan, Cody Schroeder, and Dan Grossman.
Ruby Testing 2, 11/9/2004.
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods Dan Grossman Spring 2016.
Throwing and catching exceptions
CSE 341 Section 2 Winter 2018 Adapted from slides by Nick Mooney, Nicholas Shahan, Patrick Larson, and Dan Grossman.
CSE341: Programming Languages Lecture 20 Arrays and Such, Blocks and Procs, Inheritance and Overriding Dan Grossman Spring 2017.
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Zach Tatlock Winter 2018.
CSE341: Programming Languages Section 9 Dynamic Dispatch Manually in Racket Zach Tatlock Winter 2018.
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods Dan Grossman Spring 2017.
CSE341: Programming Languages Lecture 20 Arrays and Such, Blocks and Procs, Inheritance and Overriding Dan Grossman Spring 2013.
Nicholas Shahan Spring 2016
CSE341: Programming Languages Lecture 20 Arrays and Such, Blocks and Procs, Inheritance and Overriding Dan Grossman Autumn 2017.
CSE 341 Section 9 Fall 2017 Adapted from slides by Nick Mooney, Nicholas Shahan, Cody Schroeder, and Dan Grossman.
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods Dan Grossman Autumn 2017.
Programming Languages Dan Grossman 2013
Exceptions and Exception Handling
CSE341: Programming Languages Lecture 21 Dynamic Dispatch Precisely, and Manually in Racket Dan Grossman Spring 2019.
CSE341: Programming Languages Lecture 23 Multiple Inheritance, Mixins, Interfaces, Abstract Methods Dan Grossman Spring 2019.
CSE341: Programming Languages Lecture 20 Arrays and Such, Blocks and Procs, Inheritance and Overriding Dan Grossman Spring 2019.
Brett Wortzman Summer 2019 Slides originally created by Dan Grossman
Brett Wortzman Summer 2019 Slides originally created by Dan Grossman
Presentation transcript:

Programming Languages Dan Grossman 2013 Everything is an Object

Pure OOP Ruby is fully committed to OOP: Every value is a reference to an object Simpler, smaller semantics Can call methods on anything –May just get a dynamic “undefined method” error Almost everything is a method call –Example: Jan-Mar 20132Dan Grossman, Programming Languages

Some examples Numbers have methods like +, abs, nonzero?, etc. nil is an object used as a “nothing” object –Like null in Java/C#/C++ except it is an object –Every object has a nil? method, where nil returns true for it –Note: nil and false are “false”, everything else is “true” Strings also have a + method –String concatenation –Example: "hello" + 3.to_s Jan-Mar 20133Dan Grossman, Programming Languages

All code is methods All methods you define are part of a class Top-level methods (in file or REPL) just added to Object class Subclassing discussion coming later, but: –Since all classes you define are subclasses of Object, all inherit the top-level methods –So you can call these methods anywhere in the program –Unless a class overrides (roughly-not-exactly, shadows) it by defining a method with the same name Jan-Mar 20134Dan Grossman, Programming Languages

Reflection and exploratory programming All objects also have methods like: –methods –class Can use at run-time to query “what an object can do” and respond accordingly –Called reflection Also useful in the REPL to explore what methods are available –May be quicker than consulting full documentation Another example of “just objects and method calls” Jan-Mar 20135Dan Grossman, Programming Languages