Decorators are definitely NOT needed for achieving the current functionality.
That being said, some people feel very strongly that languages are better tools when they are less elegant, when they are collections of specialized tools that communicate very specific intentions to readers.
> But still not sure if it was really needed.
That depends on your definition of "needed" of course. Do we need any abstractions? Why not just write assembly, nay, machine code?
Static analysis enables a lot of tooling (accurate auto-completion, compile-time type checking, null-analysis, ) and can also make life easier for the JIT compilers[1].
On the one end of the spectrum it's not needed because as long as a language is turing-complete it can do anything any other turing-complete language can do. On the other end it is needed to make your life easier and be more productive by offloading work from your brain to the CPU.
you can't really do that (easily) with ad-hoc typecheck wrappers.
Object.assign Connection.prototype,
hostname: memoize () -> @host.getRemoteName()Having the descriptor means for instance that you can switch a value to use a getter function, and that enables a bunch of interesting functionality that you couldn't otherwise do.
One example that I like is automatically binding methods to the current instance on first property access.
But having syntactical support improves readability.
If we were doing classes/functions the old imperative style, we could have simply wrapped the RHS in a standard function that does what the decorator does.
I get that the class syntax makes things easier for people coming from other languages. And maybe makes static analysis easier. But still not sure if it was really needed.