InfoQ

InfoQ

Presentation

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Recorded at:
Recorded at

Classes Are Premature Optimization

Presented by Justin Love on Feb 10, 2011 Length 00:36:51     Download: MP3
     Slides
Sections
Architecture & Design,
Development
Topics
Javascript ,
Dynamic Languages ,
OOP ,
Strange Loop 2010 ,
Languages ,
Strange Loop ,
Methodologies ,
Conferences ,
Language Design ,
Programming ,
Architecture ,
Prototype
 

How would you like to view the presentation?

In case you are having issues watching this video, please follow these simple steps to help us investigate the issue:
1. Right click on the video player and select Copy log
2. Paste the copied information in an email to video-issue@infoq.com (clicking this link will fill in the default details in most email clients).
Note: in case your email client hasn't automatically picked up the email subject, please include in your email the URL of the video too.
3. Done.
We will investigate the issue and get back to you as soon as possible. Thanks for helping us improve our site!
Summary
Justin Love discusses the difference between the classic OOP programming model based on classes and prototypal inheritance built on objects as done in JavaScript, and how they affect performance.

Bio
Justin Love's creed is, in part "To tease order from disorder. To make right what is wrong and make a visible difference in the lives of people I care about." Justin left a steady job in embedded software and IT support for the wild blue yonder. He is an analytical artist and martial artist who presents regularly at ChicagoRuby and JS.chi user groups.

About the conference
Strange Loop is a developer-run software conference. Innovation, creativity, and the future happen in the magical nexus "between" established areas. Strange Loop eagerly promotes a mix of languages and technologies in this nexus, bringing together the worlds of bleeding edge technology, enterprise systems, and academic research. Of particular interest are new directions in data storage, alternative languages, concurrent and distributed systems, front-end web, semantic web, and mobile apps.
Two books may be missing from your collection by Adam Nemeth Posted
Re: Two books may be missing from your collection by Justin Love Posted
Re: Two books may be missing from your collection by Adam Nemeth Posted
Re: Two books may be missing from your collection by Justin Love Posted
A few missing slides by Justin Love Posted
Clearer, simpler is often faster. by Peter Lawrey Posted
  1. Back to top

    Two books may be missing from your collection

    by Adam Nemeth

    You talked about Plato, and talked about Simula-67.

    Let me recommend you two books, and let me tell you why are they important:

    One of them is Categories from Aristoteles.

    The second is Structured Programming from - amongst Dijsktra and Hoare - Dahl, the creator of Simula.

    Even if you have never read Categories itself, what should be understood is that our culture was influenced by it for centuries, and also that code is written for humans as well. It's strange however, that even in cultures unaffected by the greeks in theory show a strikingly similar system sometimes.

    So I think Categories gives us an overview on how humans - of the western culture - think about things around us in the last 2500 years, and therefore, how we should model those things for them.

    In structured programming, Dahl and his co-authors introduce the construct of a class; they don't do it to gain performance, this wasn't an aim, nor is there some philosophical object-passing: they do it to have scalable understanding of problems.

    What is missing from Alan Kay's object-philosophy is - albeit I've never read any of his books directly yet - that it doesn't scale on comprehension; as I understand, it was thought that programs will, in some time of the future, evolve above human recognition anyway, and we should create a system which is able to do so.

    In contrast, Structured Programming was made as an effort to make people understand the limitations "of their own skull", and being able to design programs reliably with the given constraint of a human brain; that they're still understandable, even if incomprehensible as a whole.

    What is funny, that how we use classes usually is how it was written in Structured Programming; it wasn't overridden by OOP, never. Sometimes I think people liked to say this because of the arrogant personal style of Dijsktra - "arrogance should be measured in nanodijsktra", as Kay once metioned.

    So, I think it's a pretty human activity to classify the things around us, it has roots before OOP, and maybe such kind of classification should be mirrored in the code - and in the coding language itself.

    And I believe this pattern is there to be used in order to scale well; a program shouldn't scale only in performance; it should scale in recognition as well.

  2. Back to top

    A few missing slides

    by Justin Love

    Looks like the 20-minute slides were used. The full version is available at wondible.com/2010/10/15/objects-are-premature-o... In many cases it's just words too go along with what I'm saying, but there are also some additional images and diagrams.

  3. Back to top

    Clearer, simpler is often faster.

    by Peter Lawrey

    Along the thread of your argument; If your code is clearer and simpler it will often be the fastest both initially and over time.

    IMHO A program which is difficult to maintain will run slower over time. It is reasonably well understood that simple code is often optmised best (by the compiler/VM/CPU), but it worth remembering that as an application matures, it has many changes, sometimes by different developers and the clearer the code, the more likely those changes will be efficient as well. (i.e. you don't end up with work-around on top of work-around)

    "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away."
    -- Antoine de Saint-Exuper --

  4. Back to top

    Re: Two books may be missing from your collection

    by Justin Love

    While a review of Categories and other literature would probably be beneficial, I'm not arguing that humans don't think in terms of broader generalizations. Prototypal does it bottom up instead of top down. One could probably spend an entire presentation at least as long on the history of the philosophy and psychology of such generalization. In particular, I didn't get into the work of Eleanor Rosch and others which points towards prototypes or exemplars as a better model for how humans actually think.

  5. Back to top

    Re: Two books may be missing from your collection

    by Adam Nemeth

    Prototypal does it bottom up instead of top down


    I don't think classification is a top-bottom approach.

    The most ingenious step of Grady Boochs ever did was to introduce generalization as a relationship, as opposed to inheritance.

    I remember how hard time I had at Uni to explain to freshmen why the arrow is that way, and not the opposite, and it took years after to realize its ingeniusness.

    Boochs at that time was a consultant, a guy who helped companies write specifications basically. What he did realize that customers think about the specific cases first, and it's up to the analyzer (software designer) to realize the general idea behind them, and show this to the clients to prove or deny it.

    My question is, wether prototypes would scale upwards, that means, when I introduce cats alongside dogs in my pet store (or turtles!), will a prototypical system help me cope with this change in the existing software easier or harder?

    The exemplar-based point is valid, though :) Still my concerns are about conceptual scalability. I'm not saying that I know the answers...

    Wether my concerns about conceptual scalability are valid could be also a matter of debate; I would like a program which doesn't turn into spaghetti once outsourced to India after some years of internal maintenance, while still doesn't look like a full operation system with 1000s of classes. What is the best way to cope with this?

  6. Back to top

    Re: Two books may be missing from your collection

    by Justin Love

    top-bottom: I was referring to the fact that a class must exist before an instance.

    Thinking about specific cases first seems perfect for prototypes. Cats might start out as clones of dogs, adding some sort of animal prototype if (and only if) that became awkward.

    I can attest that I heavily refactored a small (compared to 'scale') Javascript program, with it running at pretty much every step, and I don't recall any great pain in doing so. I can't make any personal empirical claims about very large programs.

Educational Content

Eventually Consistent HTTP with Statebox and Riak

Bob Ippolito explains how to solve concurrent update conflicts with Statebox, an open source library for automatic conflict resolution, running on top of Riak.

Java.next

Erik Onnen attempts to demonstrate that Java is still the best programming language for the JVM if simplified idioms are used along with proper tooling.

Evolution in Data Integration From EII to Big Data

Approaches to integrating data are changing with emergence of cloud computing.

Winning Hearts and Minds: How to Embed UX from Scratch in a Large Organization

Michele Ide-Smith presents the lessons learned in the process of introducing UX principles and techniques into a large organization through a series of small steps.

LMAX Disruptor: 100K TPS at Less than 1ms Latency

Dave Farley and Martin Thompson discuss solutions for doing low-latency high throughput transactions based on the Disruptor concurrency pattern.

Thoughts on Test Automation in Agile

Rajneesh Namta shares his thoughts, experiences, and some of the critical lessons learned while implementing software test automation on a recent Agile project.

Actor Interaction Patterns

Dale Schumacher presents several patterns of actor interaction that can be used in collaborative programs written in any language.

Scalaz: Functional Programming in Scala

Rúnar Bjarnason discusses Scalaz, a Scala library of pure data structures, type classes, highly generalized functions, and concurrency abstractions to perform functional programming in Scala.