Decorators for functions

Andreas Rossberg rossberg at
Thu Oct 22 11:44:29 UTC 2015

On 22 October 2015 at 06:34, Jordan Harband <ljharb at> wrote:
> One thing that seems to be missing from this thread is acknowledgement that
> decorators are not just simple function wrappers. They take a property
> descriptor as an argument, and they can return a new property descriptor -
> which allows an object or "class" to have its shape determined at creation
> time, allowing for massive engine optimization,

Er. I don't know where this myth is coming from, but let me debunk it
right there:

Decorators do not enable optimisations. If anything, they _prevent_

What enables optimisations is a more declarative semantics with more
invariants, less mutation, less reflection, and less intercession.
That was one significant advantage of class syntax over previous
imperative JS patterns.

Decorators pretty much revert that (hard-fought) progress, because
despite their looks, they are all but declarative, and just as
imperative as the old-style patterns. Or function wrappers. A class
that uses decorators will very likely have to go through all the same
(or even worse) runtime overhead.


More information about the es-discuss mailing list