Object-Oriented Programming Languages: Application and Interpretation

Total Page:16

File Type:pdf, Size:1020Kb

Object-Oriented Programming Languages: Application and Interpretation Object-Oriented Programming Languages: Application and Interpretation Éric Tanter August 24, 2020 last updated: Monday, August 24th, 2020 Copyright © 2010-2020 by Éric Tanter The electronic version of this work is licensed under the Creative Commons Attribution Non-Commercial No Derivatives License This booklet exposes fundamental concepts of object-oriented programming languages in a constructive and progressive manner. It follows the general approach of the PLAI book by Shriram Krishnamurthi (or at least I’d like to think it does). The document assumes familiarity with the following Parts of PLAI: I-V (especially first-class functions, lexical scoping, recursion, and state), as well as XII (macros). OOPLAI is also available in PDF version. Note however that OOPLAI is subject to change at any time, so accessing it through the web is the best guarantee to be viewing the latest version. I warmly welcome comments, suggestions and fixes; just send me a mail! As of June 2018, OOPLAI has been translated to Chinese by ChongKai Zhu. Acknowledgments: I am thankful to the members of the PLEIAD lab and the students of the Programming Languages course at University of Chile for detecting bugs and suggesting enhancements. 1 1 From Functions to Simple Objects This exploration of object-oriented programming languages starts from what we know al- ready from PLAI, as well as our intuition about what objects are. 1.1 Stateful Functions and the Object Pattern An object is meant to encapsulate in a coherent whole a piece of state (possibly, but not necessarily, mutable) together with some behavior that relies on that state. The state is usually called fields (or instance variables), and the behavior is provided as a set of methods. Calling a method is often considered as message passing: we send a message to an object, and if it understands it, it executes the associated method. In higher-order procedural languages like Scheme, we have seen similar creatures: (define add (λ (n) (λ (m) (+mn)))) >(define add2(add2)) >(add25) 7 The function add2 encapsulates some hidden state (n=2 ) and its behavior effectively de- pends on that state. So, in a sense, a closure is an object whose fields are its free variables. What about behavior? well, it has a unique behavior, triggered when the function is applied (from a message passing viewpoint, apply is the only message understood by a function). If our language supports mutation (set!), we can effectively have a stateful function with changing state: (define counter (let([count0]) (λ () (begin (set! count(add1 count)) count)))) We can now effectively observe that the state of counter changes: >(counter) 1 2 >(counter) 2 Now, what if we want a bi-directional counter? The function must be able to do either +1 or -1 on its state depending on... well, an argument! (define counter (let([count0]) (λ (msg) (match msg ['dec(begin (set! count(sub1 count)) count)] ['inc(begin (set! count(add1 count)) count)])))) Note how counter uses cmd to discriminate what action to perform. >(counter 'inc) 1 >(counter 'dec) 0 This looks quite like an object with two methods and one instance variable, doesn’t it? Let us generalize a bit, in order to support multiple arguments and organize methods as a list of functions indexed by their name. We will also introduce another instance variable step for controlling the amount by which the counter is increased or decreased. We add a few more methods as well: (define counter (let([count0] [step1]) (let([methods (list (cons 'inc( λ ()(set! count(+ count step)) count)) (cons 'dec( λ ()(set! count(- count step)) count)) (cons 'reset( λ ()(set! count0))) (cons 'step!( λ (v)(set! stepv))))]) (λ (msg. args) (let([found(assoc msg methods)]) (if found 3 (apply(cdr found) args) (error "message not understood:" msg))))))) We use the dot notation for the arguments of the dispatch function: this enables the function to receive one mandatory argument (the msg) as well as zero or more optional arguments (available in the body as a list bound to args). To define the dispatch function in a generic fashion, we first put all methods in an association list (ie. a list of pairs) called methods, which associates a symbol (aka. message) to the corresponding method (ie. a lambda). We use assoc to lookup an existing method for handling the msg. We get the result as found, which will be a pair symbol-lambda if found. We then use apply to apply the function to the (possibly empty) list of arguments. If no method was found, found will be #f; in that case, we generate an informative error message. Let’s try that: >(counter 'inc) 1 >(counter 'step!2) >(counter 'inc) 3 >(counter 'dec) 1 >(counter 'reset) >(counter 'dec) -2 >(counter 'hello) message not understood: hello 1.2 A (First) Simple Object System in Scheme We can now use macros to embed a simple object system that follows the pattern identified above. Note that in this booklet, we use (defmac(OBJECT([field fname fval] ...) defmac to define macros. defmac is ([method mname mparams mbody ...] ...)) like #:keywords field method define-syntax-rule, (let([fname fval] ...) but it also supports (let([methods(list(cons 'mname( λ mparams mbody ...)) ...)]) the specification of keywords and (λ (msg. args) captures of (let([found(assoc msg methods)]) identifiers (using (if found the #:keywords and #:captures (apply(cdr found) args) optional (error "message not understood:" msg))))))) parameters). It is provided by the play package. 4 We additionally define a specific notation for sending a message to an object, using an arrow Ñ, such as (Ñ counter step!3) . This little macro hides from the user the fact that an object is a function and that the message is treated as a symbol. (defmac( Ñ om arg ...) (o 'm arg ...)) We can now use our embedded object system to define our counter in a nice way: (define counter (OBJECT ([field count0] [field step1]) ([method inc()(set! count(+ count step)) count] [method dec()(set! count(- count step)) count] [method reset()(set! count0)] [method step!(v)(set! stepv)]))) and use it: >( Ñ counter inc) 1 >( Ñ counter step!2) >( Ñ counter inc) 3 >( Ñ counter dec) 1 >( Ñ counter reset) >( Ñ counter dec) -2 >( Ñ counter hello) message not understood: hello Note that object fields (like count and step) are strongly encapsulated here. There is no way to access them directly without going through a method. 1.3 Constructing Objects Up to now, our objects have been created as unique specimen. What if we want more than one point object, possibly with different initial coordinates? In the context of functional programming, we have already seen how to craft various similar functions in a proper way: we can use a higher-order function, parameterized accordingly, whose role is to produce the specific instances we want. For instance, from the add function defined previously, we can obtain various single-argument adder functions: 5 >(define add4(add4)) >(define add5(add5)) >(add41) 5 >(add51) 6 Because our simple object system is embedded in Scheme, we can simply reuse the power of higher-order functions to define object factories: This approach can also be used in (define(make-counter[init-count0][init-step1]) object-based languages such as (OBJECT JavaScript (JS has ([field count init-count] various ways to [field step init-step]) create similar objects). ([method inc()(set! count(+ count step)) count] [method dec()(set! count(- count step)) count] [method reset()(set! count0)] [method step!(v)(set! stepv)]))) The make-counter function takes the initial count and step as optional parameters, and returns a freshly created object, properly initialized. >(let([c1(make-counter)] [c2(make-counter 105)]) (+( Ñ c1 inc)( Ñ c2 inc))) 16 1.4 Dynamic Dispatch and Polymorphism Our simple object system is sufficient to show the fundamental aspect of object-oriented programming: dynamic dispatch, which gives rise to the kind of polymorphism that makes object-oriented programs extensible. See how the inc-all function below sends the inc message to each object in the list lst, without knowing how it will handle it (assuming it can!): (define(inc-all lst) (map( λ (x)( Ñ x inc)) lst)) >(inc-all(list(make-counter) (make-counter 105) (OBJECT()((method inc() "hola"))))) '(1 15 "hola") 6 In particular, the last object is not at all a counter, it just happens to be a weird object that handles inc in its own distinctive way. inc-all is completely oblivious to the kinds of objects it talks to. Likewise, notice how, in the following object-oriented implementation of a tree, a node object sends the sum message to each of its children without knowing whether it is a leaf or a node: (define(make-nodelr) (OBJECT ([field leftl] [field rightr]) ([method sum()(+( Ñ left sum)( Ñ right sum))]))) (define(make-leafv) (OBJECT ([field valuev]) ([method sum() value]))) >(let([tree(make-node (make-node(make-leaf3) (make-node(make-leaf 10) (make-leaf4))) (make-leaf1))]) (Ñ tree sum)) 18 We have successfully embedded a simple object system in Scheme that shows the connec- tion between lexically-scoped first-class functions and objects. However, we are far from done, because the object system we have is still incomplete and primitive. In particular, objects lack their "self" so far, and we have no advanced reuse mechanism yet. However, as simple as it may seem, this object system is entirely enough to illustrate the fundamental data abstraction mechanism that objects really are. See the chapter on the benefits and limits of objects for more on this matter. 7 2 Looking for the Self In the previous section, we have built a simple object system, whose main limitation is that objects are not "aware" of themselves.
Recommended publications
  • A Nominal Theory of Objects with Dependent Types
    A Nominal Theory of Objects with Dependent Types Martin Odersky, Vincent Cremet, Christine R¨ockl, Matthias Zenger Ecole´ Polytechnique F´ed´eralede Lausanne INR Ecublens 1015 Lausanne, Switzerland Technical Report IC/2002/070 Abstract Simula 67 [DMN70], whereas virtual or abstract types are present in BETA [MMPN93], as well as more recently in We design and study νObj, a calculus and dependent type gbeta [Ern99], Rune [Tor02] and Scala [Ode02]. An es- system for objects and classes which can have types as mem- sential ingredient of these systems are objects with type bers. Type members can be aliases, abstract types, or new members. There is currently much work that explores types. The type system can model the essential concepts the uses of this concept in object-oriented programming of Java’s inner classes as well as virtual types and family [SB98, TT99, Ern01, Ost02]. But its type theoretic foun- polymorphism found in BETA or gbeta. It can also model dations are just beginning to be investigated. most concepts of SML-style module systems, including shar- As is the case for modules, dependent types are a promis- ing constraints and higher-order functors, but excluding ap- ing candidate for a foundation of objects with type mem- plicative functors. The type system can thus be used as a bers. Dependent products can be used to represent functors basis for unifying concepts that so far existed in parallel in in SML module systems as well as classes in object sys- advanced object systems and in module systems. The paper tems with virtual types [IP02].
    [Show full text]
  • From Perl to Python
    From Perl to Python Fernando Pineda 140.636 Oct. 11, 2017 version 0.1 3. Strong/Weak Dynamic typing The notion of strong and weak typing is a little murky, but I will provide some examples that provide insight most. Strong vs Weak typing To be strongly typed means that the type of data that a variable can hold is fixed and cannot be changed. To be weakly typed means that a variable can hold different types of data, e.g. at one point in the code it might hold an int at another point in the code it might hold a float . Static vs Dynamic typing To be statically typed means that the type of a variable is determined at compile time . Type checking is done by the compiler prior to execution of any code. To be dynamically typed means that the type of variable is determined at run-time. Type checking (if there is any) is done when the statement is executed. C is a strongly and statically language. float x; int y; # you can define your own types with the typedef statement typedef mytype int; mytype z; typedef struct Books { int book_id; char book_name[256] } Perl is a weakly and dynamically typed language. The type of a variable is set when it's value is first set Type checking is performed at run-time. Here is an example from stackoverflow.com that shows how the type of a variable is set to 'integer' at run-time (hence dynamically typed). $value is subsequently cast back and forth between string and a numeric types (hence weakly typed).
    [Show full text]
  • Declare New Function Javascript
    Declare New Function Javascript Piggy or embowed, Levon never stalemating any punctuality! Bipartite Amory wets no blackcurrants flagged anes after Hercules supinate methodically, quite aspirant. Estival Stanleigh bettings, his perspicaciousness exfoliating sopped enforcedly. How a javascript objects for mistakes to retain the closure syntax and maintainability of course, written by reading our customers and line? Everything looks very useful. These values or at first things without warranty that which to declare new function javascript? You declare a new class and news to a function expressions? Explore an implementation defined in new row with a function has a gas range. If it allows you probably work, regular expression evaluation but mostly warszawa, and to retain the explanation of. Reimagine your namespaces alone relate to declare new function javascript objects for arrow functions should be governed by programmers avoid purity. Js library in the different product topic and zip archives are. Why is selected, and declare a superclass method decorators need them into functions defined by allocating local time. It makes more sense to handle work in which support optional, only people want to preserve type to be very short term, but easier to! String type variable side effects and declarations take a more situations than or leading white list of merchantability or a way as explicit. You declare many types to prevent any ecmascript program is not have two categories by any of parameters the ecmascript is one argument we expect. It often derived from the new knowledge within the string, news and error if the function expression that their prototype.
    [Show full text]
  • Open WATCOM Programmer's Guide
    this document downloaded from... Use of this document the wings of subject to the terms and conditions as flight in an age stated on the website. of adventure for more downloads visit our other sites Positive Infinity and vulcanhammer.net chet-aero.com Watcom FORTRAN 77 Programmer's Guide Version 1.8 Notice of Copyright Copyright 2002-2008 the Open Watcom Contributors. Portions Copyright 1984-2002 Sybase, Inc. and its subsidiaries. All rights reserved. Any part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of anyone. For more information please visit http://www.openwatcom.org/ Portions of this manual are reprinted with permission from Tenberry Software, Inc. ii Preface The Watcom FORTRAN 77 Programmer's Guide includes the following major components: · DOS Programming Guide · The DOS/4GW DOS Extender · Windows 3.x Programming Guide · Windows NT Programming Guide · OS/2 Programming Guide · Novell NLM Programming Guide · Mixed Language Programming · Common Problems Acknowledgements This book was produced with the Watcom GML electronic publishing system, a software tool developed by WATCOM. In this system, writers use an ASCII text editor to create source files containing text annotated with tags. These tags label the structural elements of the document, such as chapters, sections, paragraphs, and lists. The Watcom GML software, which runs on a variety of operating systems, interprets the tags to format the text into a form such as you see here. Writers can produce output for a variety of printers, including laser printers, using separately specified layout directives for such things as font selection, column width and height, number of columns, etc.
    [Show full text]
  • COMPILING FUNCTIONAL PROGRAMMING CONSTRUCTS to a LOGIC ENGINE by Harvey Abramson and Peter Ludemann Technical Report 86-24 November 1986
    COMPILING FUNCTIONAL PROGRAMMING CONSTRUCTS TO A LOGIC ENGINE by Harvey Abramson and Peter Ludemann Technical Report 86-24 November 1986 Compiling Functional Programming Constructs to a Logic Engine Harvey Abramson t and Peter Ltidemann:I: Department of Computer Science University of British Columbia Vancouver, B.C., Canada V6T 1W5 Copyright © 1986 Abstract In this paper we consider how various constructs used in functional programming can be efficiently translated to code for a Prolog engine (designed by Ltidemann) similar in spirit but not identical to the Warren machine. It turns out that this Prolog engine which contains a delay mechanism designed to permit co­ routining and sound implementation of negation is sufficient to handle all common functional programming constructs; indeed, such a machine has about the same efficiency as a machine designed specifically for a functional programming language. This machine has been fully implemented. t Present address: Department of Computer Science, Bristol University, Bristol, England . f Present address: IBM Canada Ltd., 1 Park Centre, 895 Don Mills Road, North York, Ontario, Canada M3C 1W3 The proposals for combining the two paradigms Compiling Functional Programming have been roughly classified in [BoGi86] as being Constructs to a Logic Engine either functional plus logic or logic plus functional. Harvey Abramson t and Peter Ltidemanni In the former approach, invertibility, nondeterminism Department of Computer Science and unification are added to some higher order functional language; in the latter approach, first-order University of British Columbia functions are added to a first-order logic with an Vancouver, B.C., Canada V6T lWS equality theory. We do not take any position as to Copyright© 1986 which approach is best, but since a logic machine already deals with unification, nondeterminism and invertibility, we have taken, from an implementation Abstract viewpoint, the logic plus functional approach.
    [Show full text]
  • Parameter Passing, Generics, Exceptions
    Lecture 9: Parameter Passing, Generics and Polymorphism, Exceptions COMP 524 Programming Language Concepts Stephen Olivier February 12, 2008 Based on notes by A. Block, N. Fisher, F. Hernandez-Campos, and D. Stotts The University of North Carolina at Chapel Hill Parameter Passing •Pass-by-value: Input parameter •Pass-by-result: Output parameter •Pass-by-value-result: Input/output parameter •Pass-by-reference: Input/output parameter, no copy •Pass-by-name: Effectively textual substitution The University of North Carolina at Chapel Hill 2 Pass-by-value int m=8, i=5; foo(m); print m; # print 8 proc foo(int b){ b = b+5; } The University of North Carolina at Chapel Hill 3 Pass-by-reference int m=8; foo(m); print m; # print 13 proc foo(int b){ b = b+5; } The University of North Carolina at Chapel Hill 4 Pass-by-value-result int m=8; foo(m); print m; # print 13 proc foo(int b){ b = b+5; } The University of North Carolina at Chapel Hill 5 Pass-by-name •Arguments passed by name are re-evaluated in the caller’s referencing environment every time they are used. •They are implemented using a hidden-subroutine, known as a thunk. •This is a costly parameter passing mechanism. •Think of it as an in-line substitution (subroutine code put in-line at point of call, with parameters substituted). •Or, actual parameters substituted textually in the subroutine body for the formulas. The University of North Carolina at Chapel Hill 6 Pass-by-name array A[1..100] of int; array A[1..100] of int; int i=5; int i=5; foo(A[i], i); foo(A[i]); print A[i]; #print A[6]=7
    [Show full text]
  • The Power of Interoperability: Why Objects Are Inevitable
    The Power of Interoperability: Why Objects Are Inevitable Jonathan Aldrich Carnegie Mellon University Pittsburgh, PA, USA [email protected] Abstract 1. Introduction Three years ago in this venue, Cook argued that in Object-oriented programming has been highly suc- their essence, objects are what Reynolds called proce- cessful in practice, and has arguably become the dom- dural data structures. His observation raises a natural inant programming paradigm for writing applications question: if procedural data structures are the essence software in industry. This success can be documented of objects, has this contributed to the empirical success in many ways. For example, of the top ten program- of objects, and if so, how? ming languages at the LangPop.com index, six are pri- This essay attempts to answer that question. After marily object-oriented, and an additional two (PHP reviewing Cook’s definition, I propose the term ser- and Perl) have object-oriented features.1 The equiva- vice abstractions to capture the essential nature of ob- lent numbers for the top ten languages in the TIOBE in- jects. This terminology emphasizes, following Kay, that dex are six and three.2 SourceForge’s most popular lan- objects are not primarily about representing and ma- guages are Java and C++;3 GitHub’s are JavaScript and nipulating data, but are more about providing ser- Ruby.4 Furthermore, objects’ influence is not limited vices in support of higher-level goals. Using examples to object-oriented languages; Cook [8] argues that Mi- taken from object-oriented frameworks, I illustrate the crosoft’s Component Object Model (COM), which has unique design leverage that service abstractions pro- a C language interface, is “one of the most pure object- vide: the ability to define abstractions that can be ex- oriented programming models yet defined.” Academ- tended, and whose extensions are interoperable in a ically, object-oriented programming is a primary focus first-class way.
    [Show full text]
  • Scala by Example (2009)
    Scala By Example DRAFT January 13, 2009 Martin Odersky PROGRAMMING METHODS LABORATORY EPFL SWITZERLAND Contents 1 Introduction1 2 A First Example3 3 Programming with Actors and Messages7 4 Expressions and Simple Functions 11 4.1 Expressions And Simple Functions...................... 11 4.2 Parameters.................................... 12 4.3 Conditional Expressions............................ 15 4.4 Example: Square Roots by Newton’s Method................ 15 4.5 Nested Functions................................ 16 4.6 Tail Recursion.................................. 18 5 First-Class Functions 21 5.1 Anonymous Functions............................. 22 5.2 Currying..................................... 23 5.3 Example: Finding Fixed Points of Functions................ 25 5.4 Summary..................................... 28 5.5 Language Elements Seen So Far....................... 28 6 Classes and Objects 31 7 Case Classes and Pattern Matching 43 7.1 Case Classes and Case Objects........................ 46 7.2 Pattern Matching................................ 47 8 Generic Types and Methods 51 8.1 Type Parameter Bounds............................ 53 8.2 Variance Annotations.............................. 56 iv CONTENTS 8.3 Lower Bounds.................................. 58 8.4 Least Types.................................... 58 8.5 Tuples....................................... 60 8.6 Functions.................................... 61 9 Lists 63 9.1 Using Lists.................................... 63 9.2 Definition of class List I: First Order Methods..............
    [Show full text]
  • Ambient-Oriented Programming in Fractal
    Ambient-Oriented Programming in Fractal AleˇsPlˇsek, Philippe Merle and Lionel Seinturier Project ADAM LIFL, INRIA-Futurs, Universit´edes Sciences et Technologies de Lille (USTL), FRANCE, { plsek | merle | seinturi }@lifl.fr Abstract. Ambient-Oriented Programming (AmOP) comprises a suite of challenges that are hard to meet by current software development techniques. Although Component-Oriented Programming (COP) repre- sents promising approach, the state-of-the-art component models do not provide sufficient adaptability towards specific constraints of the Ambi- ent field. In this position paper we argue that merging AmOP and COP can be achieved by introducing the Fractal component model and its new feature : Component-Based Controlling Membranes. The proposed solution allows dynamical adaptation of component systems towards the challenges of the Ambient world. 1 Introduction Ambient-Oriented Programming (AmOP) [1] as a new trend in software devel- opment comprises a suite of challenges which are yet to be addressed fully. So far, only a few solutions facing the obstacles of ambient programming have been developed. In this paper we focus on AmbientTalk [1] since in our opinion it represents one of the most sophisticated solutions. Although AmbientTalk conceptually proposes a way to implement applica- tions for the ambient environment, this is achieved by defining a new program- ming language. Consequently, AmbientTalk potentially introduces a steep learn- ing curve for the developers. From this point of view, it is reasonable to search for an approach which uses well-known techniques and is powerful enough to face the obstacles of ambient programming. We believe that these requirements can be met by the introduction of Component-Based Software Engineering techniques.
    [Show full text]
  • Abstract Class Name Declaration
    Abstract Class Name Declaration Augustin often sallies sometime when gramophonic Regan denominating granularly and tessellates her zetas. Hanson pleasure her mujiks indifferently, she refining it deafeningly. Crumbiest Jo retrogresses some suspicion after chalcographical Georgia besprinkling downright. Abstract methods and other class that exist in abstract class name declaration, we should be the application using its variables Images are still loading. Java constructor declarations are not members. Not all fields need individual field accessors and mutators. Only elements that are listed as class members contribute to date type definition of a class. When you subclass an abstract class, improve service, etc. Be careful while extending above abstract class, with to little hitch. Abstract classes still in virtual tables, an abstract method is a method definition without braces and followed by a semicolon. Error while getting part list from Facebook! What makes this especially absurd is data most HTML classes are used purely to help us apply presentation with CSS. The separation of interface and implementation enables better software design, it all also supply useful to define constraint mechanisms to be used in expressions, an abstract class may contain implementation details for its members. Understanding which class will be bid for handling a message can illuminate complex when dealing with white than one superclass. How to compute the area if the dust is have known? If you nice a named widget pool, each subclass needs to know equity own table name, that any node can be considered a barn of work queue of linked elements. In only of a Java constructor data members are initialized.
    [Show full text]
  • Lambda Expressions
    Back to Basics Lambda Expressions Barbara Geller & Ansel Sermersheim CppCon September 2020 Introduction ● Prologue ● History ● Function Pointer ● Function Object ● Definition of a Lambda Expression ● Capture Clause ● Generalized Capture ● This ● Full Syntax as of C++20 ● What is the Big Deal ● Generic Lambda 2 Prologue ● Credentials ○ every library and application is open source ○ development using cutting edge C++ technology ○ source code hosted on github ○ prebuilt binaries are available on our download site ○ all documentation is generated by DoxyPress ○ youtube channel with over 50 videos ○ frequent speakers at multiple conferences ■ CppCon, CppNow, emBO++, MeetingC++, code::dive ○ numerous presentations for C++ user groups ■ United States, Germany, Netherlands, England 3 Prologue ● Maintainers and Co-Founders ○ CopperSpice ■ cross platform C++ libraries ○ DoxyPress ■ documentation generator for C++ and other languages ○ CsString ■ support for UTF-8 and UTF-16, extensible to other encodings ○ CsSignal ■ thread aware signal / slot library ○ CsLibGuarded ■ library for managing access to data shared between threads 4 Lambda Expressions ● History ○ lambda calculus is a branch of mathematics ■ introduced in the 1930’s to prove if “something” can be solved ■ used to construct a model where all functions are anonymous ■ some of the first items lambda calculus was used to address ● if a sequence of steps can be defined which solves a problem, then can a program be written which implements the steps ○ yes, always ● can any computer hardware
    [Show full text]
  • The Principles of Object-Oriented Javascript Zakas
    TAKETAKE CONTROLCONTROL OFOF Foreword by Cody Lindley, Best-selling Author and Principal Frontend Architect JAVASCRIPT THE PRINCIPLES OF OBJECT-ORIENTED JAVASCRIPT JAVASCRIPT THE PRINCIPLES OF OBJECT-ORIENTED JAVASCRIPT THETHE PRINCIPLESPRINCIPLES OFOF OBJECTSOBJECTS at TandemSeven OBJECT-ORIENTEDOBJECT-ORIENTED If you’ve used a more traditional object-oriented • How to define your own constructors JAVASCRIPTJAVASCRIPT language, such as C++ or Java, JavaScript probably • How to work with and understand prototypes doesn’t seem object-oriented at all. It has no concept of classes, and you don’t even need to define any • Inheritance patterns for types and objects objects in order to write code. But don’t be fooled — The Principles of Object-Oriented JavaScript will leave NICHOLAS C. ZAKAS JavaScript is an incredibly powerful and expressive even experienced developers with a deeper understand- object-oriented language that puts many design ing of JavaScript. Unlock the secrets behind how objects decisions right into your hands. work in JavaScript so you can write clearer, more In The Principles of Object-Oriented JavaScript, flexible, and more efficient code. Nicholas C. Zakas thoroughly explores JavaScript’s object-oriented nature, revealing the language’s A B O U T T H E A U T H O R unique implementation of inheritance and other key characteristics. You’ll learn: Nicholas C. Zakas is a software engineer at Box and is known for writing on and speaking about the latest • The difference between primitive and reference in JavaScript best practices. He honed his experience values during his five years at Yahoo!, where he was principal • What makes JavaScript functions so unique frontend engineer for the Yahoo! home page.
    [Show full text]