Using HOCON

I have heard Sponge was using HOCON as their configuration API.

But where do I start with it? How is it like YAML? Do I have to put the whole GitHub project into mine in order to use it?
I have also started on my Sponge plugin, so saying, “Just wait,” is not a good response. :slight_smile:

Thanks

Everything (examples, how to use) can be found inside their README https://github.com/typesafehub/config

If you’re familiar with JSON and YAML, they seem pretty similar (have not looked in depth myself yet), but HOCON is significantly less strict which is probably the biggest reason to switch. The biggest thing with Bukkit’s impl of YAML that I can think of was that everyone used parent.child.node representation, which HOCON supports natively: parent.child.node = 42 => { parent: { child: { node: 42 } } }.

Assuming Sponge team is going to use the official library, you can view how to use it in Java on their readme: https://github.com/typesafehub/config You would just include their maven dependency as a compile-time dependency; there should be no need to shade it / include it with your plugin as it will be included with the Sponge binary.

edit: inheritance and concatting other vars inline seems really nice. Looking forward to using it myself :smiley:

2 Likes

Either, you choose to wait, or you choose to do it on your own, just as I did.
I used SnakeYAML for my plugin:

Thanks guys! I forgot about dat ReadMe :stuck_out_tongue:

If it’s bundled then you’ll want to use the provided dependency scope to avoid it interacting weirdly with Sponge’s. However, even then, shading is a good idea even for bundled libraries, in order to avoid having to make sure that you and Sponge are always in sync.

Thank you, as someone who doesn’t code (other than the occasional config or rules file), I had no idea where to even start looking for information on HOCON.

They are indeed related. HOCON is, just like YAML, a JSON superset.
That means: Valid JSON code is also valid YAML or HOCON code.
So in case you know JSON and prefer it over HOCON you could just use it.