Code Monkey home page Code Monkey logo

Comments (5)

worldmind avatar worldmind commented on July 17, 2024

Addition: not just for porting, but for reusing schema between languages.

from strictyaml.

crdoconnor avatar crdoconnor commented on July 17, 2024

Hi @worldmind

I have a documentation page on why I don't define schemas in YAML : https://hitchdev.com/strictyaml/why/turing-complete-schema/

I do think that the base should be ported to other languages - the ability to parse mappings, sequences and strings (multiline and single line) but I'd be happy to see other languages implement their own schema language - or even not have a schema at all (strictyaml technically doesn't need a schema).

As far as I'm concerned the "data format" of StrictYAML and the schema validation are entirely separate entities. The former is very simple (kind of like JSON) while the latter is pretty complex and evolving and probably won't translate all that well away from python.

I also think that it's a good idea to make a jsonschema -> StrictYAML validator converter (the other way is not possible). I started a project last year where you could input a jsonschema and get a valid strictyaml schema object out ( https://github.com/hitchdev/strictyamljsonschema ) but I lost steam - partly because I don't have a use for such a thing myself. I'd love to see it exist, to aid it and promote it though.

from strictyaml.

worldmind avatar worldmind commented on July 17, 2024

Yes, JSONSchema it's a beautiful way.

probably won't translate all that well away from python

Maybe I misunderstood something, you says that some data structures can't be implemented in other languages?

from strictyaml.

crdoconnor avatar crdoconnor commented on July 17, 2024

No, I think that they can but I can't see a way of creating a language independent schema without sacrificing flexibility and/or strictness. For instance in strictyaml you can:

  • Revalidate whole portions of the document based upon what is in other portions of the document (there's an example of this in the revalidation docs).
  • Easily pull in external data (e.g. a frequently updated list of country codes, time zones and international dial codes) from externally managed sources and use them to validate.
  • Create custom validators that use custom logic - e.g. create a Hong Kong ID card validator based upon the standard ID card validation algorithm.
  • Create a custom validator/typecaster that uses the python-slugify package (I use this one a lot).

A framework to do all of this requires the validation to be done with turing complete code. It's basically not possible with JSON schema (at least, not without using nasty hacks).

Personally I have found the above kind of flexibility to be absolutely vital for the purposes I have used strictyaml for while portability of schemas across programming languages simply isn't a requirement I've ever had.

You could duplicate the way it's done in some other languages and so the schemas look very similar (and perhaps share names - like map and mappattern) but they'd still look substantially different in the end.

If other languages do implement their own version of strictyaml (and I very much hope that they do) I'd ideally like to see them follow a similar pattern for similar reasons. Turing complete schemas are underrated IMHO. I'd be somewhat less fussed about them being consistent with strictyaml (e.g. if the javascript version had a MapPattern but called it something else I think that'd be okay).

from strictyaml.

worldmind avatar worldmind commented on July 17, 2024

Thank for explanation, sorry I miss https://hitchdev.com/strictyaml/why/turing-complete-schema/
I suppose that will be great if you make link to this page from main page for example by adding new item in priorities list, may be something like "Data schema is Python code because flexibility is matter, details here".

from strictyaml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.