4 ms·
Echoing the article, declarative is a degree and almost all if not all DSL's do not achieve declarative purity. The best places for a declarative DSL are for do
by threatofrain 4y ago
Echoing the article, declarative is a degree and almost all if not all DSL's do not achieve declarative purity. The best places for a declarative DSL are for domains which are very elegant and well-studied, such as relational databases.
Thus I generally don't pay attention to claims about declarative programming — it is rarely actually attempted despite the frequency of advertisement. The domain which Pulumi / Terraform targets is most definitely too messy to attempt a pure declarative DSL.
- flanked-evergl 4y agoTerraform has a non entirely declarative layer which generates entirely declarative representation which is then applied using providers. This may be a tenious difference from imperative, but it is the crux of it and this is what you want when managing resources.
- suralind 4y agoBut it's also limiting, for example, you may want to run some perform an action before a resource is deleted and then you have two options: a) create your own provider that will will handle the provisioning and deprovisioning under the hood b) use provisioner (e.g. local-exec) The first option is great if you have time and resources so create your own provider. The second option is what you're more likely to use if you are small and don't have a dedicated team. Also it's convenient if you can achieve 99% with existing providers just need to run one command, but doesn't always work (Terraform has many limitations regarding this).
- tekla 4y agoUhh, why would you ever use Terraform to do that? Its wild seeing people try and force Terraform to do things that the docs more or less YELL at you to not do. Secondly, I use TF and at least on AWS you use lifecycle hooks to do what you describe. If I saw someone using TF to do that,I would think they are incompetant.
- ryukafalz 4y agoNot every provider has lifecycle hooks.
- paulryanrogers 4y agoRight, and (as I understand it) vendor neutral is a selling point of Terraform
- 1letterunixname 4y agoIn terms of DSLs, this is the crux of Puppet vs. Chef. The danger (and power) of the Chef DSL is it allows imperative Ruby anywhere, including shops that liberally use monkeypatching "to put out fires". Puppet is a custom DSL that doesn't have this problem but it lacks the power of Chef. Declarative is generally even more limited than DSLs like Puppet and can't support complex logic. It maybe worth externalizing complex logic into "helpers" or other systems, but this creates a "Javascript frontend + something else backend" code-synchronization problem. Declarative seems "easy" and "looks like data" but it rapidly runs into limitations. (The other confusion with Chef is without unified_mode, there are 2 main execution phases that run on clients: compile-time and converge-time. unified_mode makes it easier for novices whereas 2 phase allows for the compile phase to adjust node settings when using an "API" model without databags or run_state.)
- eru 4y ago> Declarative is generally even more limited than DSLs like Puppet and can't support complex logic. Functional and logic languages would disagree. For configuration, have a look at https://dhall-lang.org/ https://dhall-lang.org/
- colordrops 4y agoNix is fully declarative (with flakes), supports complex logic, and is more powerful that chef and puppet. It is a bit more difficult to learn for those reasons as well.
- 1attice 4y ago+1. YAML is a terrible foundation for a declarative config. You need a language designed for declarative config. Some commenter above said that this space is too messy for a purely declarative language; someone else said Pulumi should be thought of as a macro language to generate a declarative spec. Instead of bolting on a whole Python interpreter to work as a macro language to generate a theoretical declarative spec, why not instead just write a declarative spec in a sanely declarative language? It's not that hard to learn Nix. Stop procrastinating, everyone, and go learn Nix :)