3 ms·
You don't need to recompile a typesafe config. Application.conf overrides reference.conf - the latter only provides defaults. Recompiling a Config.scala file i
by yummyfajitas 13y ago
You don't need to recompile a typesafe config. Application.conf overrides reference.conf - the latter only provides defaults.
Recompiling a Config.scala file is fast anyway unless you change the type signature.
- taeric 13y agoConsider all of the code that goes into making typesafe config work. Then contrast that with the code necessary to store configuration as sexps.
- yummyfajitas 13y agoYes, typesafe config is an external library rather than using the built in interpreter. That is extra code. If you wanted to do things in equivalent lisp style, you'd just compile a Config.java/Config.scala file and add it to the classpath. That's only a few extra lines in your ansible script. Your configuration will be statically typedchecked - failure to include a required parameter or including a param of the wrong type will result in a compile failure. This is unconventional but a very reasonable way to go. At the moment I'm just using typesafe config because it's more or less the standard, but the more I think about it the more I like the idea of compiling my config.
- taeric 13y agoI think the point is often best regarded as annoyance by lispers that it has taken so much code and time to get back to where they were at the start.
- MoosePlissken 13y ago> If you wanted to do things in equivalent lisp style, you'd just compile a Config.java/Config.scala file and add it to the classpath. That's really not equivalent though. With Java and Scala, there's a sharp divide between what's code and what's data. Even if you create a Config.java class, you can still point to some bits and say "that's Java code" and other bits (like primitives or array literals) and say "that's data". Java doesn't know how to treat the code bits like data, or the data bits like code. This means that there's a whole load of cool stuff that you just can't do with your Config.java that you could with a config file holding Lisp code. For one, you couldn't use macros to easily pre-process your config file. Or, as Yegge pointed out, you couldn't just turn the tag names (in an xml like structure) into functions that transform themselves. Newer versions of Spring use Java for configuration. As you said, it's pretty cool to be able to compile and type check your config. As cool as that is though, it's not at all the same as putting your config in Lisp code.
- taeric 13y agoIn addition to my other comment. One giant difference is creating said file. It is trivial to output files like this from lisp. Not so much for java/scala/whatever. Consider, if you were to do this the way you are describing. How would you support saving updates to the configuration from within the application?