News for hackers. Stuff that matters.
Re:Ten predictions (2004) by RyanMcGreal on Friday February 15, 2013 @06:57AM (#5225720)
> We got NoSQL (esp. JSON based ones) instead of XML. Close enough though.

JSON is basically XML with 50% less bullshit. It does less but it does it so much more elegantly than XML - and has the further benefit of a syntax similar to that of structured data in such languages as Javascript (duh), Python and Ruby - that it was a shoo-in to squeeze XML out of most non-enterprise uses, at least on the data transfer format side.

However, to this day most data still resides in SQL databases, which have the net advantages of speed, stability and reliability that come from long lead time. What has changed is that object-relational mapping has gotten vastly better than it was in 2004, so programmers can mostly enjoy the best of both worlds.

There's also the fact that SQL is an easy enough DSL to understand, read and write that it isn't a barrier to use even in edge cases where ORMs fall down.

Re:Ten predictions (2004) by jimbokun on Friday February 15, 2013 @10:56AM (#5226749)
It's true that JSON document databases very closely follow the model set out by earlier XML document databases, and have succeeded for the reason Yegge spelled out.

The big lack is the equivalent of XQuery and XPath, in my opinion. Javascript plays this role in some systems, but I don't think there is anything for Javascript matching the power and flexibility of XQuery/XPath for querying and transforming data.

I would be happy to learn about query languages for JSON document databases that prove me wrong.

Re:Ten predictions (2004) by wildgift on Friday February 15, 2013 @09:18PM (#5230034)
JSON is traditional: dictionaries, arrays. OO languages have built-in syntax to deal with those, via [] and dot notation, and the array objects nowadays have ways to do map() apply() grep() etc. on the collections.

The main thing missing is that XML has attributes, so you can query against those.

I won't say that the JS stuff is better, but it's one less thing to learn, and what you learn is directly applicable to writing apps in JS.

Re:Ten predictions (2004) by SonicSoul on Friday February 15, 2013 @08:53AM (#5226119)

    > object-relational mapping has gotten vastly better than it was in 2004
Maybe so, but it still seems like it's only good for prototyping. With each new version of ORM i get excited and try to implement it, but sooner or later it comes to bite me in the ass, and long term maintenance becomes more painful than not using ORM with all the low level hacks that need to be added and tricky management of the mapping config.
Re:Ten predictions (2004) by ryanbrunner on Friday February 15, 2013 @09:47AM (#5226372)
I think the key difference, at least among most developers I work with, is that ORM has evolved from a complete abstraction of all relational querying, into more of a productivity tool that can be useful in certain circumstances.

The differences between something like Hibernate and something like ActiveRecord is pretty vast, at least in terms of usage, and I think one of the key learnings we've made since 2004 is that it's not practical or feasible to treat ORM as a silver bullet.

Honestly, no one should be surprised that ORM isn't a silver bullet. NoSQL isn't either - there's plenty of caveats that should be considered before deciding on using NoSQL. I'd still argue that about 80% of database interactions can be solved by a decent ORM. Anything that lets me ignore 80% of my trivial problems and focus on the 20% that's actually challenging is a net win in my book.

Re:Ten predictions (2004) by corresation on Friday February 15, 2013 @11:30AM (#5226943)
JSON is basically XML with 50% less bullshit.

I don't get this. XML has the capacity of being as simple as you want it to be. You don't need schemas, namespaces, xpath, and so on, and can make your XML life every bit as easy as JSON. In many ways easier given that JSON doesn't even have a bloody date or time type.

But if you do want strong-type validation, schemas and namespaces are there for you. If you want an easy, standard way to query, XPath/XQuery are there for you. If you want to wholesale completely restructure entire documents/data blobs, XSLT is there for you.

I have never gotten the hate for XML. I suspect -- and this is not some sort of slur against those who don't like something I like, but rather is an observation about general tech trends -- that many programmers were simply too lazy to understand all of XML, so rather than work in an area where they felt ignorant (again, nothing stops you from making bespoke XML at your desire), JSON and things like it seem so appealing.

Re:Ten predictions (2004) by csense on Friday February 15, 2013 @11:57AM (#5227064)
1. JSON has an easy way to specify data types. In XML you have to have multiple nested tags. In JSON my document can be:

  {"mynumber" : 5, "mylist" : ["one", "two", "three"]}
Simple, neat, and fits on one line.

In XML this has to be

  <!DOCTYPE some-magic-string-nobody-can-remember>
  <topnode>
    <mynumber><int>5</int></mynumber>
    <mylist>
      <str>one</str>
      <str>two</str>
      <str>three</str>
    </mylist>
  </topnode>
Of course, I don't know what you're talking about "JSON doesn't even have a bloody date or time type" when XML doesn't have anything but strings. In order to parse this, I'd have to have code which looks for <int> tags and runs my language's atoi() on the content.

Maybe there are libraries that do this automatically. If there are, the XML community does an excellent job of hiding them from developers; I've worked a fair bit with XML, and haven't found them.

2. Easy interface with popular languages. You can just copy-paste a JSON string into a Javascript / Python app. (Warning: If you do this programmatically, it's going to be a security vulnerability.) Whereas if you want to use XML, you have to jump through a lot of hoops. Especially with Java; AFAIK the Java standard lib only ships a specification for XML parsing. So while the org.w3c.xml namespace is there (or whatever it's called, it's been a while), you have to install some Apache lib called Xerces or Xalan or Xavier (or whatever it's called, it's been a while) in order to have XML support.

This is Java's fault, not XML's; but XML was a shiny cool thing at about the same time Java was, so a lot of peoples' main XML experience (or at least mine) is in Java.

3. Is a subset of many popular languages. A lot of people -- especially web developers -- only know one language. If you know JS, then you know JSON. But XML syntax and semantics is very different from most programming languages, and that's a barrier. (General XML is much different than HTML. In particular, you can always see what HTML "does" by loading it in the browser because everything has default styles; not so with a general XML format, unless you go through the pain of writing a complete style yourself.)

Re:Ten predictions (2004) by fusiongyro on Friday February 15, 2013 @01:11PM (#5227474)
Your ideas about Java and XML are very dated. JAXB makes it essentially transparent to convert an object to XML and back, and with JAX-RS I can give you a REST API that returns XML or JSON, your pick, for basically no effort on my part. These are part of the Java EE 6 web profile, so basically everybody gets them for free. Most of us don't "install libraries" anymore so much as add four lines to our Maven POMs.

Point #2 isn't very strong. Every language has good support for both technologies these days.

Point #3 is absurd. If you know JS and you know HTML, you're not far from the basics of XML. If you're contemplating JSON as a replacement, you're either assuming our poor web developer is really stupid or you're comparing apples to oranges.

In general, your argument here is that JSON is shorter and more popular. Sure. But unless your top concern is bandwidth (hey, maybe it is) there might exist other technical reasons to make the choice which are less childish.

Re:Ten predictions (2004) by csense on Friday February 15, 2013 @02:20PM (#5227922)
1. What's a good tutorial to learn JAXB and JAX-RS?

2. Maven is a nightmare too. Every time I've used it (usually because I'm compiling someone else's code and they wrote the build in maven), it downloads hundreds of megabytes of who-knows-what from random Internet sites. I want to pin versions of dependencies (and dependencies-of-dependencies) so my builds are repeatable, and I want to be sure everyone who's forked my git repo can still build the code if the Maven URL's for the deps have gone out of business. I recall trying to read the Maven manual, but both the manual and the concepts were incomprehensible -- there's so much automagic, when things break, it's difficult to even come up with a hypothesis of what might be going wrong. (And anyone who has any experience with any build system knows that the build always breaks.)

I usually just use Ant. It's a bit of a pain shuttling jar's around (symlinks help), but at least I can understand the build.

3. Part of the problem is that I don't want this alphabet soup of technologies. If I'm running in Python, and I'm developing a prototype or a one-off hack, I just write a file called whatever.py. (I can "import json" in whatever.py if I don't want to use hacks like eval()/repr() or copy-and-paste for parsing/serializing.)

I want to be able to build a quick one-file prototype to process my XML, without enabling the "Java EE 6 web profile" (whatever that is) and writing a Maven build file. I want using XML to be this simple:

  sudo apt-get install default-jdk
  javac Whatever.java && java Whatever
And Java's XML handling just isn't that simple, whereas Python's JSON handling is.
Re:Ten predictions (2004) by fusiongyro on Friday February 15, 2013 @03:31PM (#5228430)
1. The Java EE 6 Tutorial is a good place to start for these things.

2. You may not like Maven--I hate it too--but it's how things are done. In practice the only people complaining about installing libraries and managing jar dependencies are people using ant without ivy. 90% of folks just use Maven and get on with it.

3. You're turning your complaint from "Java's XML support is weak" to "Java's XML support isn't Pythonic like Python's." This is a weak argument. You're saying you want to live the Python dream in Javaland. Well, it isn't going to happen, no matter what the Play guys tell you. But if you have to use Java--and sometimes you do--adding four lines to your maven config--which you will have--so you can use EE 6 or JAXB is not a big deal, and neither is putting a few annotations on a class.

I don't love Java. In fact I dislike it. I would rather be using Haskell, Python, or Ruby. Or any number of other things. But you can't be mad at Java for being Java and not Python.

Re:Ten predictions (2004) by Anderkent on Friday February 15, 2013 @03:31PM (#5228426)
> I want to pin versions of dependencies (and dependencies-of-dependencies) so my builds are repeatable

That's by default in maven - you have to do something really stupid to get non-repeatable builds (usually involves specifying open version ranges or some weird plugin magic)

>everyone who's forked my git repo can still build the code if the Maven URL's for the deps have gone out of business

One of the main advantages of maven is just the opposite of that - you don't have to bundle your dependencies and get them to other people - they can just ask maven to fetch them. And maven is not going away.

Re:Ten predictions (2004) by EdiX on Saturday February 16, 2013 @01:34PM (#5232437)
> That's by default in maven - you have to do something really stupid to get non-repeatable builds

I think they changed it now but for years the default behaviour was to get the latest versions of every plugin, making builds non-repeatable by default.

Re:Ten predictions (2004) by Yhippa on Friday February 15, 2013 @02:44PM (#5228067)
Re:Ten predictions (2004) by androidexample on Sunday February 24, 2013 @04:40PM (#5276029)
Camera Photo Capture And Show Captured Photo On Activity

<http://androidexample.com/Camera_Photo_Capture_And_Show_Capt...

Re:Ten predictions (2004) by samspot on Friday February 15, 2013 @04:23PM (#5228767)
The appeal of JSON isn't that it is shorter, but that it is easier. Easy to read, easy to type, easy to parse. XML may be easy "enough", but I'll choose JSON anytime I don't need the extra things that xml offers. The verbosity of XML may sometimes be necessary, but it just isn't very much fun to work with.
Re:Ten predictions (2004) by gutnor on Friday February 15, 2013 @01:10PM (#5227468)
You are a bit outdated, tooling is a bit better nowadays.

Java integrates everything you need to parse and generate XML. Most API are XSD driven (either through annotation in the code, or with the mapping code generated from the XSD), so you get plenty of types like data, int, ... You also get streaming parser (pull or push) and DOM.

Obviously, that is no longer plain XML, that is XML + XSD + Namespaces.

The J2SE (not JEE) also has built-in support to expose and consume webservices, without requiring to worrying about WSDL and the rest.

At the end of the day, that does not mean that dealing with XML is a great experience. Most real life XML is awful. And well although the basic tooling is there, that is in the usual java fashion with factories of factory of creator of generator and very little "high level" utility.

Re:Ten predictions (2004) by Roboprog on Saturday February 16, 2013 @02:28AM (#5230765)
Somehow, that doesn't sound like an easy way to serialize and/or store a simple list of name-value pairs.

The S stands for simple... <<Sob>>

Re:Ten predictions (2004) by ramses0 on Friday February 15, 2013 @12:00PM (#5227081)
XML has a few issues compared to JSON:

* attributes v. tagnames

* no "anonymous list"

* infinitely large surface area

[ {name: joe, age: 12 }, {name: bob, age: 23} ]

<list><user><name>joe</name><age>12</age></user><user><name>bob</name><age>23</age></user></list>

The access pattern for json is much easier: obj[1].name

The infinitely large surface area of XML is painful.

Namespaces, entities, xsd/schema, cdata, cdata-in-cdata.

It's an alright data / interchange format and especially suited to certain multi-vendor use cases, but the disadvantages cost more than the benefits compared to "simple" anonymous json.

Re:Ten predictions (2004) by jodrellblank on Friday February 15, 2013 @05:37PM (#5229116)

  <user name='joe' age='12' />
Re:Ten predictions (2004) by huherto on Friday February 15, 2013 @06:41PM (#5229472)
What about bob?
Re:Ten predictions (2004) by jodrellblank on Friday February 15, 2013 @09:55PM (#5230140)
I'm sure you're capable of filling in the pattern with <user name='bob' age='23' /> yourself.

I wasn't trying to show XML is as compact as JSON, only that it can be more compact than the claim "it's so verbose" made it look.

Re:Ten predictions (2004) by coldtea on Saturday February 16, 2013 @03:05PM (#5232785)
Yes. And then you have to find a way to parse that.

JSON always comes with ready made parsing.

Re:Ten predictions (2004) by ncote on Saturday February 16, 2013 @01:13AM (#5230606)
Man, that was funny!
Re:Ten predictions (2004) by mattmanser on Saturday February 16, 2013 @06:35AM (#5231188)

    {'users': [{'name': 'joe', 'age': '12' }, {'name': 'bob', 'age': '23'}]}
    <users><user name='joe' age='12' /><user name='bob' age='23' /></users>
Re:Ten predictions (2004) by ramses0 on Tuesday February 19, 2013 @03:50PM (#5246960)
Yeah, that's cool and all, but I avoided using XML with attributes because attributes can't / don't nest.

{ name: 'joe', dob: { m: 1, d: 2, y: 1934 } }

<user name='joe' dob='...???...'>

<user><name>joe</name><dob><m>1</m><d>2</d><y>1934</y></dob></user>

I actually wasn't trying to make the "XML is bigger" joke because that isn't what's important to me. Structurally XML is harder to use.

Re:Ten predictions (2004) by FlyingAvatar on Sunday February 17, 2013 @09:35AM (#5235295)
Not to be pedantic, but:

    {users: [{name: 'joe', age: 12}, {name: 'bob', age: 23}]}
    <users><user name='joe' age='12' /><user name='bob' age='23' /></users>
Re:Ten predictions (2004) by seanalltogether on Friday February 15, 2013 @12:03PM (#5227095)
XML has the capacity of being as simple as you want it to be

Unfortunately in practice it never is. I've seen programmers do too many dumb things with data structures in XML, which then becomes "part of the spec" so it never goes away.

Take an xml api in a fortune 500 and run it through 10 developers over the course of 5 years, then do the same thing with a json api, I guarantee you the json one will be more standardized and easier to consume.

Re:Ten predictions (2004) by ams6110 on Friday February 15, 2013 @10:43PM (#5230283)
Guarantee? Do you actually know how "enterprise" projects work?
Re:Ten predictions (2004) by seanalltogether on Friday February 15, 2013 @11:58PM (#5230453)
bank of america, t. rowe price, wall st on demand, ebay, aflac, adobe, ge, nielson, navy federal...do you want me to open my entire client archive? You should see what java devs try to shove into xml structures.
Re:Ten predictions (2004) by ripter on Friday February 15, 2013 @11:58AM (#5227066)
I don't understand the complant that JSON doesn't support a date/time format.

It supports numbers and strings. You can use unix timestamps, you can use ISO 8601, you can use any format that makes sense for your application.

JSON doesn't support a Date/Time object because it's a data format. XML doesn't support a Date/Time object either.

Now if you want to complain that the JSON parsers don't automatically convert ISO 8601 dates into Date/Time objects, I understand.

To me 50% less bullshit means 50% less typing and maybe getting something wrong. JSON is easy to read and write by hand, which happens a lot.

XPath/XQuery and XSLT are nightmares in my opinion. I'd much rather type `Foo.bar` or `_.each(Foo.items, function(item) {...})` and be able to easily debug when something goes wrong.

Re:Ten predictions (2004) by emn13 on Friday February 15, 2013 @07:08PM (#5229612)
Right, but xml "objects" are annotated with some name, whereas json nodes aren't. This is a hassle, but it's also very convenient when you want to represent something that doesn't map 100% perfectly onto the underlying structure. So as you say, you _could_ represent a date in lots of different ways. In xml that's doable, and somewhat comprehensible. In JSON it's usually jibberish. And that's just dates - good luck with anything more complex.

I still think JSON is a more promising format in the long run. But it certainly isn't great - it's just bad in a different way, and somewhat more minimalist (which is good).

Also, I can't for the life of me understand why someone would dislike xpath. It's like the one best thing about xml - it's simple, concise, and easy to read. I'd absolutely love an xpath equivalent for json, which just doesn't exist.

Just expressing obvious things like "person[name='bla']/nickname" is so much more wordy in an explicit function style. And notice how the rest of the world - including most major js(on) libs have long gravitated towards that (monadic) style of querying - it's not just me, almost everyone prefers it. CSS; SQL; jquery selectors; even a filesystem glob - every complex datastore gravitates to some variant of the same pattern, and it's something json consuming libs do not yet do very well. I'm sure they will someday - but it's a real lack right now.

Re:Ten predictions (2004) by corresation on Saturday February 16, 2013 @09:04AM (#5231485)
JSON doesn't support a Date/Time object because it's a data format. XML doesn't support a Date/Time object either.

XML doesn't support objects, but there was enough thought put into the implementation that it has an easy way to document and define the types, with validated ways of representation. ISO 8601 for the xsd:dateTime, for instance. There is no ambiguity or uncertainty, no hand-rolled varieties of crazy, quite unlike JSON world where there are a hundred ways to represent a date or date/time, all of them broken in some way or other.

Re:Ten predictions (2004) by reginaldo on Friday February 15, 2013 @11:51AM (#5227037)
I think the 50% less bulshit figure is pretty generous. Let's not forget that, unless you opt out of it, most XML parsers, when given user-generated input, will do lots of crazy stuff. In the best case scenario, the machine that parsed the input will fall victim to DoS. In the worst, we have good old remote code execution. Tipically, an attacker will be able to read lots of files from the servers and make arbitrary network connections, many times from the viewpoint of a machine inside a corporate firewall. As a spare-time security researcher, let's say I absolutely love XML. As a developer, I despise it.
Re:Ten predictions (2004) by reginaldo on Friday February 15, 2013 @12:08PM (#5227128)
corresation: I can't answer your post directly, so I'll answer my own. It's absolutely not vague handwaving. HTML or JSON parsers can't make arbitrary network connections. XML parsers often can.

XML remains the lingua franca or most enterprise systems and interchanges (meaning the ones that people are most interested in trying to compromise

That is one of the reasons attackers are so happy. They are not trying to compromise. They are succeeding. Show me a SOAP/XMLRPC web service and I will show you a compromised machine, with very high probability.

See, for instance, last year's BlackHat presentation about SAP. Root with 1 request. Granted, there was an overflow involved, but the entry point was XML. Many more instances of this are available (I've compromised tens of systems in the last six months through the "magic" of XXEs, but unfortunately can't talk about them).

http://media.blackhat.com/bh-us-12/Briefings/Polyakov/BH_US_...

Re:Ten predictions (2004) by corresation on Friday February 15, 2013 @11:54AM (#5227053)
I'm sorry, but the vague handwaving about security issues with XML is utter nonsense. There have been issues, just as there have been issues with JSON, HTML, or any other parsed or shared content. Alluding to some vast chasm of danger is absurd, made especially obvious that XML remains the lingua franca or most enterprise systems and interchanges (meaning the ones that people are most interested in trying to compromise).
Re:Ten predictions (2004) by jgalt212 on Saturday February 16, 2013 @10:37AM (#5231742)
XML is good when the structure of the data returned is not self-evident to the data requester. In this case XML's verbosity assists in hand walking the tree to grok what the server is returning.

XLST is a friggin nightmare to code and I can't think of any reason why one would want to use it. It's much better to first parse the XML and then reshape to your needs rather than trying to do both at the same which XSLT does. In short, XSLT violates separation of conerns. Furthermore, if you think XML is hard to read, just try reading someone else's XL

Re:Ten predictions (2004) by EdiX on Saturday February 16, 2013 @01:11PM (#5232364)
> I don't get this. XML has the capacity of being as simple as you want it to be. You don't need schemas, namespaces, xpath

XML data model (trees with attributed nodes and special kinds of leaves) is not native to any language: XPath/XQuery and XSLT exist to bridge the alien world of XML to regular programming languages. Taking them out doesn't make XML simpler.

JSON doesn't have them because it can be represented with maps and lists, object types fundamental to many programming languages (it practically maps almost exactly to every scripting language created in the last 20 years). That's why it doesn't have, and doesn't need, XPath or XSLT equivalents. And that's also why it feels more natural to most programmers (ie. 50% less bullshit).

You could build a stronger case for the need of schemas and namespaces but IMHO that's actually bullshit, even in XML. But you can ignore them in XML too, as you noted, so it doesn't really matter.

Re:Ten predictions (2004) by edu222 on Friday February 15, 2013 @10:00AM (#5226436)
Have you tried Django's ORM? From what I understand its not perfect, but for the most part it really rocks.
Re:Ten predictions (2004) by hcarvalhoalves on Friday February 15, 2013 @01:17PM (#5227502)
I've been working with Django for 5 years, and I would say Django's ORM is pretty pedestrian, when not downright painful. It fails at simple things like allowing you to GROUP BY without falling back to SQL.
Re:Ten predictions (2004) by amatix on Friday February 15, 2013 @02:11PM (#5227855)
That used to be the case, it's much better now: see QuerySet.annotate() and QuerySet.aggregate()
Re:Ten predictions (2004) by hcarvalhoalves on Friday February 15, 2013 @02:34PM (#5228017)
I'm aware. These features are not replacement for GROUP BY.