
Instance-First Development (2004) - gruseom
https://blog.osteele.com/2004/03/classes-and-prototypes/
======
DonHopkins
I love Oliver Steele's work with dynamic languages, and have really enjoyed
doing "instance first development" with OpenLaszlo, and miss it now that it's
gone obsolete, because I haven't found anything quite like it.

[https://en.wikipedia.org/wiki/OpenLaszlo](https://en.wikipedia.org/wiki/OpenLaszlo)

It's about iteratively programming from the ground up, avoiding premature and
unnecessary abstraction, smoothly and rapidly developing prototypes into
reusable components and working products, and organically growing and easily
abstracting only when needed.

I think there's still a lot to be learned from OpenLaszlo and applied to new
systems. It would be great to inspire somebody to take the idea of instance
first development, and run with it in a modern framework.

Oliver is an old school Lisp Machine hacker, so OpenLaszlo had a very
declarative prototypical Lispy feel to it! Another "dynamic language" Oliver
created was Dylan at Apple.

[https://en.wikipedia.org/wiki/Dylan_(programming_language)](https://en.wikipedia.org/wiki/Dylan_\(programming_language\))

OpenLaszlo was a VERY enjoyable system to work with, because of the way
instance first development dovetailed with constraints, prototypes, and data
binding, that really got me into an extremely productive groove.

Of all the frameworks I've learned about, Svelte seems the most like
OpenLaszlo, philosophically. They both have a JavaScript to JavaScript
compiler that wires up reactive constraint dependences automatically, for
example. But I don't think Svelte has an instance creation syntax that
parallels its class definition syntax, to enable the "instance substitution
principal" that supports instance first development: An instance of a class
can be replaced by the definition of the instance, without changing the
program semantics.

[https://svelte.dev/](https://svelte.dev/)

Here's some stuff I recently (and not so recently) posted about OpenLaszlo
(with some broken links fixed):

[https://news.ycombinator.com/item?id=22025026](https://news.ycombinator.com/item?id=22025026)

Oliver Steele describes "Instance First Development", which the language he
designed, OpenLaszlo, supported through the "Instance Substitution Principle".
I've written about it here before, and here are some links and excerpts.

[https://news.ycombinator.com/item?id=14418108](https://news.ycombinator.com/item?id=14418108)

In the right context, prototypes can enable Instance-First Development, which
is a very powerful technique that allows you to quickly and iteratively
develop working code, while delaying and avoiding abstraction until it's
actually needed, when the abstraction requirements are better understood and
informed from experience with working code.

That approach results in fewer unnecessary and more useful abstractions,
because they follow the contours and requirements of the actual working code,
instead of trying to predict and dictate and over-engineer it before it even
works.

Instance-First Development works well for user interface programming, because
so many buttons and widgets and control panels are one-off specialized
objects, each with their own small snippets of special purpose code, methods,
constraints, bindings and event handlers, so it's not necessary to make
separate (and myriad) trivial classes for each one.

Oliver Steele describes Instance-First Development as supported by OpenLaszlo
here:

Instance-First Development

[http://blog.osteele.com/2004/03/classes-and-
prototypes/](http://blog.osteele.com/2004/03/classes-and-prototypes/)

[...]

[https://news.ycombinator.com/item?id=21841054](https://news.ycombinator.com/item?id=21841054)

[...] The mantle of constraint based programming (but not Instance First
Development) has been recently taken up by "Reactive Programming" craze (which
is great, but would be better with a more homoiconic language that supported
Instance First Development and the Instance Substitution Principle, which are
different but complementary features with a lot of synergy). The term
"Reactive Programming" describes a popular old idea: what spreadsheets had
been doing for decades. [...]

[https://news.ycombinator.com/item?id=7756215](https://news.ycombinator.com/item?id=7756215)

Oliver Steele (one of the architects of OpenLaszlo, and a great Lisp
programmer) describes how OpenLaszlo supports "instance first development" and
"rethinking MVC":

[http://blog.osteele.com/2004/03/classes-and-
prototypes](http://blog.osteele.com/2004/03/classes-and-prototypes)

[http://blog.osteele.com/2003/08/rethinking-
mvc](http://blog.osteele.com/2003/08/rethinking-mvc)

[...] I've used OpenLaszlo a lot, and I will testify that the "instance first"
technique that Oliver describes is great fun, works very well, and it's
perfect for the kind of exploratory / productizing programming I like to do.
(Like tacking against the wind, first exploring by creating instances, then
refactoring into reusable building block classes, then exploring further with
those...)

OpenLaszlo's declarative syntax, prototype based object system, xml data
binding and constraints support that directly and make it easy.

OpenLaszlo's declarative syntax and compiler directly support instance first
development (with a prototype based object system) and constraints (built on
top of events and delegates -- the compiler parses the constraint expressions
and automatically wires up dependences), in a way that is hard to express
elegantly in less dynamic, reflective languages. (Of course it was
straightforward for Garnet to do with Common Lisp macros!)

[https://news.ycombinator.com/item?id=17360883](https://news.ycombinator.com/item?id=17360883)

Instance-First Development:

[https://blog.osteele.com/2004/03/classes-and-
prototypes/](https://blog.osteele.com/2004/03/classes-and-prototypes/)

>The equivalence between the two programs above supports a development
strategy I call instance-first development. In instance-first development, one
implements functionality for a single instance, and then refactors the
instance into a class that supports multiple instances.

>[...] In defining the semantics of LZX class definitions, I found the
following principle useful:

>Instance substitution principal: An instance of a class can be replaced by
the definition of the instance, without changing the program semantics.

In OpenLaszlo, you can create trees of nested instances with XML tags, and
when you define a class, its name becomes an XML tag you can use to create
instances of that class.

That lets you create your own domain specific declarative XML languages for
creating and configuring objects (using constraint expressions and XML data
binding, which makes it very powerful).

The syntax for creating a bunch of objects is parallel to the syntax of
declaring a class that creates the same objects.

So you can start by just creating a bunch of stuff in "instance space", then
later on as you see the need, easily and incrementally convert only the parts
of it you want to reuse and abstract into classes.

What is OpenLaszlo, and what's it good for?

[https://web.archive.org/web/20080211173607/http://www.donhop...](https://web.archive.org/web/20080211173607/http://www.donhopkins.com/drupal/node/124)

Constraints and Prototypes in Garnet and Laszlo:

[https://web.archive.org/web/20080211173607/http://www.donhop...](https://web.archive.org/web/20080211173607/http://www.donhopkins.com/drupal/node/69)

