1

'Every variable is a static constant once declared'
All variables in PuppetDSL, really hard to wrap the head around if you are 'used to' re-assign a variable a new value.

Comments
  • 2
    I don't really get this "mutation is bad" thing either.
    It improves readability imo 🤷‍♂️
  • 1
    @nitwhiz that's true, but the main reason puppet doed this is to avoid unexpected results in your provisioning since variables cannot change.

    Imagine writing an 'accounts' resource and let the password get filled in by variable. Now imagine you set the password variable in your hiera or enc, and in your manifest your variable changes to something else along the way before it gets to the account resource realization....

    It's a sensible quirk, just weird and geargrinding when you're not aware of this.
  • 2
    @nitwhiz
    While sound in most cases, it's particularly useful in highly parallel, highly concurrent scenarios. Slightly increases memory pressure, dramatically reduces memory leaks due to faster collection cycles and no pins, eliminates concurrency issues, because no two things write to the same data. Future state eliminates race conditions/eventuality related to two disconnected operations updating the same data in memory. It's a natural side effect of unidirectional messaging.

    It's also not the "right answer," there is no right answer. It's just an answer.

    Readability, that's a per-team subjective measurement.
  • 0
    can you atl "del <var>"?
  • 0
    if a variable is a static constant, then it's not a variable, since it's not variable, but is a constant, since it's constant.

    so the actual accurate statement would be "PuppetDSL doesn't have variables, only constants"
Add Comment