Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To me the solution seems like it's adding complexity that could cause more issues further down the line.

The specific problems in the example could be solved by changing how the data is represented. Consider the following alternative representation, written in edn:

    {:aws.s3/buckets
     {:aws.region/eu-west
      {:alpha-hourly  {:lifecycle/policy {:delete-after #interval/days 4}}
       :alpha-daily   {:lifecycle/policy {:delete-after #interval/days 30}}
       :alpha-monthly {:lifecycle/policy {:delete-after #interval/days 365}}

       :bravo-hourly  {:lifecycle/policy {:delete-after #interval/days 4}}
       :bravo-daily   {:lifecycle/policy {:delete-after #interval/days 30}}
       :bravo-monthly {:lifecycle/policy {:delete-after #interval/days 365}}}}}
This prevents issues where the region is mistyped for a single bucket, makes the interval more readable by using a custom tag, and as a bonus prevents duplicate bucket names via the use of a map.

Obviously this doesn't prevent all errors, but it does prevent the specific errors that the RCL example solves, all without introducing a Turing-complete language.



> The specific problems in the example could be solved by changing how the data is represented.

Finding the "right" representation for a given set of data is an interesting problem, but most (all) of the time the representation is specified by someone/something else.

In the past I've written a [preprocessor][1] that adds some power to the representation while avoiding general purpose computation. For example,

    (buckets
      (let ([(regional region (name policy) ...)
             ((['name name] ['region region] ['lifecycle_policy policy]) ...)])
        (regional us-west
          (alpha-hourly (delete_after_seconds 345600))
          (alpha-daily (delete_after_seconds 2592000))
          (alpha-monthly (delete_after_seconds 31536000))
          (bravo-hourly (delete_after_seconds 345600))
          (bravo-daily (delete_after_seconds 259200))
          (bravo-monthly (delete_after_seconds 31536000)))))
Macros, basically. Arithmetic would help there, but that might be too much.

[1]: https://github.com/dgoffredo/llama




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: