Hi everyone,
I wonder what is the reason clojure uses XML standard wise and not
JSON. In the past I've found that JSON is much cleaner to read, and
much easier to represent data structures in. I know XML is a buzzword,
but JSON is on it's way to become one too. And yes I know Java uses
XML extensively, in my eyes too extensively in many parts, but isn't
one goal of Clojure not to repeat Javas mistakes?
On another note, wouldn't Clojure itself or rather a subset of clojure
be best to represent data? So to say something like CON?
Or do I miss something that makes it important for Clojure to be
bundled so tightly with XML?
On Aug 25, 4:24 pm, Licenser <heinz.g...@gmail.com> wrote:
> I wonder what is the reason clojure uses XML standard wise and not
> JSON. In the past I've found that JSON is much cleaner to read, and
> much easier to represent data structures in. I know XML is a buzzword,
> but JSON is on it's way to become one too. And yes I know Java uses
> XML extensively, in my eyes too extensively in many parts, but isn't
> one goal of Clojure not to repeat Javas mistakes?
> On another note, wouldn't Clojure itself or rather a subset of clojure
> be best to represent data? So to say something like CON?
> Or do I miss something that makes it important for Clojure to be
> bundled so tightly with XML?
The "usual" approach is to use print and read to (de-)serialise
Clojure values (see also *print-dup*). The only place where Clojure is
in some way "bundled" with XML is clojure.xml. But you don't have to
use it. Clojure works perfectly fine without it. In clojure-contrib
there is also a JSON reader/writer.
So Clojure actually provides you with all three ways, without forcing
or prefering one style.
I mostly use XML for serialisation because I have to interface into
Java libraries, which use it. Hence in my situation XML has the least
impedance mismatch.
On Tue, Aug 25, 2009 at 10:24 AM, Licenser <heinz.g...@gmail.com> wrote:
> I wonder what is the reason clojure uses XML standard wise and not > JSON.
I don't think Clojure has standardized in any way on XML. There just happens to be an XML parsing lib in Clojure proper because it's a useful thing to have. There is a JSON parser in Clojure Contrib. There's another one floating around too, if I'm not mistaken.
> On another note, wouldn't Clojure itself or rather a subset of clojure > be best to represent data? So to say something like CON?
This is certainly possible and if you control both the reader and the writer, I would argue it's the best way to go. For interoperability with other services, however, I don't think there's any getting away from XML and JSON in the near future.
> Or do I miss something that makes it important for Clojure to be > bundled so tightly with XML?
I don't see any tight bundling between Clojure and XML.
On Tue, Aug 25, 2009 at 16:24, Licenser<heinz.g...@gmail.com> wrote:
> Hi everyone, > I wonder what is the reason clojure uses XML standard wise and not > JSON. In the past I've found that JSON is much cleaner to read, and > much easier to represent data structures in. I know XML is a buzzword, > but JSON is on it's way to become one too. And yes I know Java uses > XML extensively, in my eyes too extensively in many parts, but isn't > one goal of Clojure not to repeat Javas mistakes?
Alas, XML has long past the point of being merely a buzzword. Some ability to consume and produce XML is a necessity for interoperability in many domains. Also beyond data-exchange XML also supports document authoring applications and mixed content, where solutions like JSON aren't so great. (In fairness, XML's not so great either. I'd rather use ResturctedText).
JSON has turned out well, for what it does. If there isn't already a JSON parser in clojure-contrib, perhaps you'd like to contribute one? I'm sure it would find takers.
> On another note, wouldn't Clojure itself or rather a subset of clojure > be best to represent data? So to say something like CON?
Yup, for clojure-only applications though there's no need for either XML or JSON: we can just use clojure's (prn) (read).
> Or do I miss something that makes it important for Clojure to be > bundled so tightly with XML?
I wouldn't consider Clojure to be bundled tightly with XML. There's a single (rather simplistic) clojure.xml module included with the language, which provides rudimentary namespace-ignorant XML support.
> On Tue, Aug 25, 2009 at 16:24, Licenser<heinz.g...@gmail.com> wrote:
> > Hi everyone,
> > I wonder what is the reason clojure uses XML standard wise and not
> > JSON. In the past I've found that JSON is much cleaner to read, and
> > much easier to represent data structures in. I know XML is a buzzword,
> > but JSON is on it's way to become one too. And yes I know Java uses
> > XML extensively, in my eyes too extensively in many parts, but isn't
> > one goal of Clojure not to repeat Javas mistakes?
> Alas, XML has long past the point of being merely a buzzword. Some
> ability to consume and produce XML is a necessity for interoperability
> in many domains. Also beyond data-exchange XML also supports document
> authoring applications and mixed content, where solutions like JSON
> aren't so great. (In fairness, XML's not so great either. I'd rather
> use ResturctedText).
I like JSON for pulling data out of web apis, combined with the parser
it becomes very convenient.
> JSON has turned out well, for what it does. If there isn't already a
> JSON parser in clojure-contrib, perhaps you'd like to contribute one?
> I'm sure it would find takers.
There is one in contrib, I've used it a bit and it is quite good.
> > On another note, wouldn't Clojure itself or rather a subset of clojure
> > be best to represent data? So to say something like CON?
> Yup, for clojure-only applications though there's no need for either
> XML or JSON: we can just use clojure's (prn) (read).
Yeah, I made my own ad-hoc transactional caching thing, and it was
quite nice being able to simply print stuff out line by line and then
read it in with { } wrapped around it.
The code is similar to the code for memoise, just with an extra step
of writing stuff to file and reading it in at a certain time.
(interestingly means you can disk cache any fn that is referentially
transparent and returns a clojure structure).
> > Or do I miss something that makes it important for Clojure to be
> > bundled so tightly with XML?
> I wouldn't consider Clojure to be bundled tightly with XML. There's a
> single (rather simplistic) clojure.xml module included with the
> language, which provides rudimentary namespace-ignorant XML support.