nitrictech / nitric

Nitric is a multi-language framework for cloud applications with infrastructure from code.
https://nitric.io
Apache License 2.0
1.23k stars 52 forks source link

Proposal: use `new` keyword for resource construction #525

Closed jyecusch closed 5 months ago

jyecusch commented 1 year ago

An early decision when creating Nitric was to use functions, rather than constructors, to create resources. One of the reasons for this decision was the challenge creating fluent interfaces off constructors in some languages (e.g. new Topic("test").for("publishing")) isn't always possible.

In hindsight, the avoidance of constructors made resource creation somewhat less intuitive. Let's explore these tradeoffs in more detail.

davemooreuws commented 1 year ago

For javascript/ts using a more modular approach would improve tree-shaking, reducing the size of our bundles. Example of this being used: https://firebase.google.com/docs/web/modular-upgrade

Not saying we do this, just something to think about.