DEV Community

Discussion on: Why Choose NgRx?

 
layzee profile image
Lars Gyrup Brink Nielsen

There's a big difference. Angular's decorators are compiler instructions and are not present at runtime.

Thread Thread
 
korbraan profile image
Cédric Rémond

Oh, never thought of that.

But once compiled the decorators are just functions no? What is the drawback of decorators, even if executed at runtime to you? Only the fact they aren't standard yet?

Thread Thread
 
layzee profile image
Lars Gyrup Brink Nielsen • Edited

Non-Angular decorators are function wrappers, yes. But the structure and semantics of decorators, even the syntax can still change. Heck, decorators might never make it into the language (that language is ECMAScript, not TypeScript).

If syntax and semantics change, don't bet on TypeScript saving our behinds. When we use decorators in TypeScript, we enable the option "experimentalDecorators", meaning: "You're on your own, pal. Good luck!". It's called experimental for a reason (that reason is Angular by the way, there used to be this language called AtScript).