4 ms·
By now I shouldn't be, but I'm always a little surprised when people come to the conclusion that the best way to represent HTML is JSON or Javascript (or anythi
by jmull 6y ago
By now I shouldn't be, but I'm always a little surprised when people come to the conclusion that the best way to represent HTML is JSON or Javascript (or anything but HTML).
- Risord 6y agoWhy so? In web world we represent most of our non-UI structural data in JSON. HTML is also structural data but what makes it so special that serialization format is needed? Or why won't we represent any abstract business data as HTML even if it would have similiar structure? Therefore I think it's very understandable why people come to that conclusion so often.
- throwaway894345 6y agoWhy is XML a better way to represent HTML than any other hierarchical data representation language? “JSON doesn’t have Multiline strings” would be a good argument, but there are lots of good reasons that XML is a bad format (overly verbose, overly complicated, parsers frequently have security vulnerabilities, etc etc).
- monadic2 6y agoElement attributes are awkward to express in JSON, at the very least. Maybe if the markup language was originally designed around json it would be a more natural fit.
- throwaway894345 6y agoI think this is fine: { “type”: “div”, “style”: “...”, “children”: [ ... ] } If you really want to treat attributes specially you could put them under an “attributes” key: { “type”: “div”, “attributes”: {“style”: “...”}, “children”: [ ... ] }
- slmjkdbtl 6y agofor people who claim this most of the time another goal is having "programmable components". also there can always be ergonomic/stylistic improvements like pug
- leontrolski 6y agoHi, author here. I talked about this in more length here https://leontrolski.github.io/dom-syntax.html https://leontrolski.github.io/dom-syntax.html and to some extent here https://leontrolski.github.io/33-line-react-thoughts.html https://leontrolski.github.io/33-line-react-thoughts.html. There was also some discussion on the former here https://news.ycombinator.com/item?id=23142300 https://news.ycombinator.com/item?id=23142300