I'd also argue for using thrift, protobuf or even WS-* to put a little more strong typing into what goes over the network. Such schemata won't catch everything (they have to have a lowest-common-denominator notion of type) but distributed bugs are the hardest bugs to track down; anything that helps you spot a bad network request earlier is well worth having.
Arguments against JSON-driven development
11–20 of 306 posts
Re: Arguments against JSON-driven development
#12Not the fault of the technology, but of the developer who failed to consider alternate ways of accomplishing the same task.
Re: Arguments against JSON-driven development
#13This is not to say that one tool is better than the others, but tools do have opinions, and while being more permissive/ambivalent makes throwing together a quick script easier, a tool that nudges you in the direction of building something in a more-sustainable way is useful when building nontrivial systems.
Re: Arguments against JSON-driven development
#14If this was XML, you'd write a very simple RELAX NG grammar (use the compact syntax: http://relaxng.org/compact-tutorial-20030326.html ) that describes the structure of the incoming data, then use it to validate the input data before processing it.
After that, you know data is valid and in the right structure, so you can throw away most of the "is this in the right place?" checks.
JSON and YAML's various schema implementations can't hold a candle to this, and it's been around for over a decade.
The XML ecosystem does have some very bad parts, but it's not all bad, so it's worth learning from places where it actually works well.
Re: Arguments against JSON-driven development
#15The main reason this happens in Python is that creating actual datatypes is incredibly clunky (by Python standards) because of the tedious "def __init__(self, x): self.x = x". The solution here is to have a very lightweight syntax for more specific types, e.g. Scala's "case class". I'd also argue for using thrift, protobuf or even WS-* to put a little more strong typing into what goes over the network. Such schemata…
https://docs.python.org/2/library/collections.html#collectio...
Re: Arguments against JSON-driven development
#16In the example in the article, OO seems like a good way to go.
Re: Arguments against JSON-driven development
#17In that case, you want values rather than objects. Alas, Python doesn't have compound values.
Re: Arguments against JSON-driven development
#18The main reason this happens in Python is that creating actual datatypes is incredibly clunky (by Python standards) because of the tedious "def __init__(self, x): self.x = x". The solution here is to have a very lightweight syntax for more specific types, e.g. Scala's "case class". I'd also argue for using thrift, protobuf or even WS-* to put a little more strong typing into what goes over the network. Such schemata…
Re: Arguments against JSON-driven development
#19And this is where we end up without easy to use and well supported schemas... If this was XML, you'd write a very simple RELAX NG grammar (use the compact syntax: http://relaxng.org/compact-tutorial-20030326.html ) that describes the structure of the incoming data, then use it to validate the input data before processing it. After that, you know data is valid and in the right structure, so you can throw away most of…
Re: Arguments against JSON-driven development
#20The main reason this happens in Python is that creating actual datatypes is incredibly clunky (by Python standards) because of the tedious "def __init__(self, x): self.x = x". The solution here is to have a very lightweight syntax for more specific types, e.g. Scala's "case class". I'd also argue for using thrift, protobuf or even WS-* to put a little more strong typing into what goes over the network. Such schemata…