Meet Ryan: elegant data format which is also kinda programming language

Even missed something more programmable than JSON or YAML, but not quite as powerful as Python? Meet Ryan: a configuration language for the practical programmer!

This a small (-ish?) project I created based on my experience with other configuration languages, such as Dhall and Jsonnet. These languages are pretty useful for writing configuration files, even for small applications. It really helps in offloading your CLI.

I also believe that there might be other use cases waiting to be found in this grey area between data and code. Ryan can be a good choice to execute untrusted... things... since it's not Turing complete and its access to the "outside world" can be tightly controlled.

About using in your code, it's the easiest thing! The Rust crate is basically drop-in replacement for serde_json and will work with any deserializable type.

To learn more about Ryan, you can read the article in Medium, read The Book or even try it out online without any commitment. Of course, Pull Requests and discussion in the repository are very welcome when constructive.

4 Likes

I've ended up creating scraggly config setups for my work over and over, so I'm always partial to new configs system options, but I'm not sure this matches my quirky preferences:

  • yaml-ey "light" syntax
  • good, debuggable, support for multiple levels of defaulting/overriding variables (production envs, local dev setups, preset variations)
  • programmable variable sources

etc. Always good to have more options though, maybe I can take a deeper look later...

Well, aside from the YAML-ly syntax, I believe the other stuff are a match! You can do stuff like this:

let env = import "env:ENV" as text or "dev";

This will read the envvar ENV as a string and, if not set, use "dev". And then, you can start using the variable env around the file (and even around multiple files).

About programmable variable sources, you cannot make a dynamic import, but you can use `if-else':

let params = if env == "prod" then
    import "prod_settings.json" 
else 
    import "env_settings.json";

.... maybe I should add a match block in the future...

EDIT: I am looking for "next steps" for this project. You are welcome to open an issue in the repo!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.