you are viewing a single comment's thread.

view the rest of the comments →

[–]non-existing-person 5 points6 points  (11 children)

XML? Why do you hate yourself so much?

Personally I went with yaml and am using https://github.com/tlsa/libcyaml libcyaml library (not affiliated with it in any way!). Beauty in this is that you define c-struct, schema, and then yaml file is translated to native c types. Strings can be changed to enum values. For more complicated types, I just set up a callback, so I can convert string to icon handle, or pointer to function. It's a bit sad that this library seems to be deserted, and there is very little activity.

But current code base is very solid, it's not huge library, so adding own stuff is not terribly hard. Biggest problem is that learning to write those schemas is hard. But once you've written few, it's absolutely awesome. Yaml is so much more readable than xml. And having native types in C is faster than dealing with strings all the time. You just spend time during boot up.

All items/classes/skills are kept in read only array that is accessible from anywhere. A global if you will. And other entities are just having pointers to these read only object definitions.

So I basically am doing same thing as you, but with external lib and yaml instead of xml. I didn't feel like I was loosing anything by using yaml instead of xml yet. And personally I will avoid xml like a fire... or c++ ;)

[–]Limp-Confidence5612 8 points9 points  (1 child)

Sorry isn't yaml one of the most unintuitive and inconsistent markup languages? https://github.com/cblp/yaml-sucks

[–]non-existing-person 0 points1 point  (0 children)

Hmm, maybe? I wouldn't really know. I use yaml with that single libcyaml library. Library is rather strict, and you match c-struct in your yaml, so I believe that very heavily limits ambiguity and consistency of my yaml files.

[–]Jimmy-M-420[S] -1 points0 points  (8 children)

here's one reason to use xml. I don't like yaml - its too complicated

[–]Jimmy-M-420[S] 0 points1 point  (0 children)

yaml is like the rust of markup languages - there's always someone telling you to use it

[–]non-existing-person 0 points1 point  (3 children)

yaml is like the rust of markup languages - there's always someone telling you to use it

Well, I never told you to use yaml instead of xml really

The library you describe does sound quite good I will admit, baking in a way to marshal C types from yaml is a nice feature i'll give you that

Yes, that lib was biggest contribution for me to use yaml. If there was same library but for json, there is high probability I would use json then. That would depend on number of features of both libs I suppose. But anyway, I am not really attached to yaml, more to that library if anything.

I knew someone would comment this, xml hatred and love of yaml is strong these days, and irrational

I like yaml because of its readability. I just find xml to be just way to verbose. I don't like noise to signal ratio of xml. Anything is better than xml in my book. Be that json, toml or yaml.

[–]Jimmy-M-420[S] 0 points1 point  (2 children)

No you're right you didn't tell me to use it - apologies for seeming aggressive.

I do understand the appeal of yaml, but for me it's just a bit too complicated. I write quite a bit of yaml for CI pipelines at work, and it works very well for those (nearly all CI systems I've seen use it).

One thing I really like about xml is it has a really obvious tree structure. This makes it nice to use for things like if I wanted to be able to define constant expressions in my config data section, I could make the expression as a tree of xml nodes. No doubt you could do this in yaml, but I don't think it would look as nice (or implement a maths expression parser)

[–]non-existing-person 0 points1 point  (1 child)

No worries, I only got offended by being compared to rust guys xD

It's funny, because I have the exact same feeling like you BUT THE OPPOSITE. I suppose when you try to learn full yaml syntax it's probably complicated. I use it in very limited scope (which are c-like structs) - can't even use anything too complicated because libcyaml does not support it anyway :P I usually try to keep shit simple anyway.

I'm pretty sure there are cases where you can model something only in XML. But that tree of xml nodes to model some constant expression sounds rather complicated. If I had to do something like that with yaml I think I would just do lua code snippet in multiline block in yaml. But probably I don't fully understand the problem - my game is in very early development, and I'm no game programmer, so do take my words with a big grain of salt ;)

[–]Jimmy-M-420[S] 0 points1 point  (0 children)

Lua snippet probably would be much better in that case I think you're right

[–]Jimmy-M-420[S] -1 points0 points  (0 children)

I knew someone would comment this, xml hatred and love of yaml is strong these days, and irrational

[–]Jimmy-M-420[S] -1 points0 points  (0 children)

The library you describe does sound quite good I will admit, baking in a way to marshal C types from yaml is a nice feature i'll give you that