- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The real WTF is XML. There, I said it.
Admin
"The error, for those that care, was that our code expected values in the range 0 to 255, rather than -127 to 128. "
Or if you use one of those newfangled computers that uses two's complement, it would be -128 to +127.
Admin
Another method, would be to gzip the data, and store it inline (just like pdf does)...
Admin
Hey, it's svg!
Admin
Are you kidding? What could possibly be gained by encoding an image like that?
Admin
Admin
And for some generations of javac, most of the silly string+string - operations people do have been silently optimized to use StringBuilder. It's still not smart to depend on it happening, but that's probably what Phil meant.
Admin
But wait! I thought garbage collection made it so that I never had to worry about memory allocation and deallocation! It all just goes away, right? Right?
Admin
Welcome to 2003(ish)!
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
Or how about: http://java.sun.com/j2se/1.3/docs/api/java/lang/String.html
To save some clicking:
Right then. Carry on.
Admin
The real wtf is that people are proposing XML schemas by posting sample documents when there are multiple unambiguous languages for defining a schema.
Admin
Why not use -42 to 213, that would be much more beautiful!
Admin
The Real WTF is that they're using XML when there already is a perfectly valid text format for storing images:
And, yes, XPM is a real format. It outputs images as valid C files for use in X11 programs via #include.
Admin
cthulhu, you're assuming the image is rasterized. What if it is vector art? The file is being transported in its binary form, which would be agnostic to the file format.
I don't ger why they didn't just base64 encode the image. Talk about bloat.
Admin
Except now it's allocating a bunch of unreachable StringBuffer instances on top of the unreachable String instances, since
is really converted to
Yes, huge savings...especially with all that excess wasted space in the private char[] in StringBuffer.
Admin
Actually, including whitespace it expands byte sizes by about a factor of 20 (ranging from 19x (for 0) to 22x (for 0127/0xFF)), plus the header/footer overhead.
Admin
This is why I hate XML.
For every good example of XML use, there are 10000 bad examples.
Admin
Hmmmm.
Look at it this way. If you're using descriptive language to name each and every single permutation of RGB then there are going to be RGB combinations for which there are no standardized names.
So you can immortalize ex-girlfriends and other annoying people all you like.
Example: this color's name is now "Lisa's Pimply Ass".
Admin
Oh yeah! Especially if you convert a 4mb image to XML by string concatenation.
LOL. I'd wait to run this specific piece of software until a coworker is trying to compile something really big.
"WTF!? Where did all the resources go ..."
Admin
Makes it even more attractive!
Why it's not an integral part of the HTML 4.0 spec, I have no idea.
Admin
Admin
That is almost as bad as ASN.1/BER
Admin
Brillant! I'm going to use this in every project I do from now on. Look at all the features!
Admin
Don't worry, they're adding it to the HTML 5.0 spec.
Well, not quite as bad, but they ARE requiring that browsers allow you to embed images via "data:" URLs. (Worse, browsers must be capable of generating such URLs via JavaScript.) By default, it requires bytes to be escaped in URL format, like:
data:application/octet-stream,%01%02%03%04
However, you can also use Base64-encoding, by adding something like:
data:application/octet-stream;base-64,ABCD==
Such things are already supported by Firefox, Opera, and Safari. Really.
Admin
TRWTF here is the obvious lack of experience that almost anyone in this forum apparently has when it comes to XML serialization and web services. Not to mention, transfer of binary data.
Admin
I don't know where I'm going with this.
Admin
They did say it was enterprisey.
Admin
string string3 = string.Concat("string1", "string2");
Might not be as bas a string string3 = string.Format("{0}{2}", "string1", "string2"); which I bet someone, somewhere has done exactly that. (Note: this would use a StringBuilder, and three string objects!!)
If you used a StringBuilder you'd only have two object (though one more complex than the other) instead of three string objects which is "slightly" better. Since the less objects you have the better off your are as the GC eats your waste of space faster :D
Admin
I think this is actually even more sinister than anyone here has guessed. I don't think this is meant to be a bitmap format translated to XML. As others have pointed out, it doesn't contain the information necessary to render an image (dimensions, color channels). I think each <bytes> element is actually a byte from the image file. The serialization code simply opens the file as a character stream and reads from beginning to end, writing each byte out to XML.
Pure, unmitigated evil.
Admin
Admin
You could easily define the actual values of each color earlier in the image, also:
Admin
schemas aren't funny
Admin
Well thank heavens for the XML then. If those bytes had been in binary, he never would have noticed that they were signed!
Admin
Don't meant to ruin the fun... but, just base-64 encode the image thusly: <data type="bmp"> xsfgsdjnsdasdfvsavhbasdovuinsadv sdfgdsfsdfsdjndsifndsfisdufnsfs asdfiojndfdisufnsdufdsuifnsdfsdufn </data>
(btw: don't try and decode that. I'm far too lazy to encode something clever into this post.)
Admin
FTW!!!
The sad thing is I've seen this example back in my Uni days :) The lecturer for 'Internet Programming' was truly clueless
Admin
FTW!!!
The sad thing is I've seen this example back in my Uni days :) The lecturer for 'Internet Programming' was truly clueless
Admin
No it wasn't. But it did come with terribly useful HTTP headers, such as Content-Length and Content-Type. You'd think those would be useful for something.
Admin
Hey - I was the one expecting it in the range 0-255 and preferably not in XML. Don't give me a hard time for what was being returned from the server.
Admin
That looks just like first draft of Microsoft OOXML!
Admin
Yep. It was a PNG, but it was a whole PNG, not image data. Yep. The actual file.
Admin
Admin
Admin
With tabs as 4 spaces, Windows newlines, and Unicode, such a disk image would be 6,000 times bigger than the actual disk. 1 GB Disk => 6 TB disk image.
I am not making fun of DriveImage XML, which uses XML to match filenames to chunks within the binary disk image.
The XML should appear indented
Admin
Admin
I think you mean
<pixel><color name="Sunset Orange"/></pixel> <pixel><color name="Light Green"/></pixel> <pixel><color name="Reddish"/></pixel> <pixel><color name="Lime Green"/></pixel> <pixel><color name="Sea Breeze Blue"/></pixel> <pixel><color name="Woodchip Brown"/></pixel>
Admin
since each element is a byte, that means it's binary right? like binary data?
better to base64 encode it first then, no? of course then you need an extra attribute on each element. It's a little wordier, but best to be clear:
<bytes encoding="base64">MQ==</bytes> <bytes encoding="base64">MQ==</bytes> <bytes encoding="base64">MQ==</bytes> <bytes encoding="base64">MQ==</bytes>
Admin
Admin
Hi, not being sarcastic, got a question:
Why is this worse? Is it because the MIME headers are also unnecessarily encoded, instead of just the actual 'data'?
Admin
HOLY CRAP WHAT ARE SAYING????
Your going to use XML to describe each bit??? Dude, for one byte you'd eat up loads of XML. That is unreadable, will be problematic to parse and basically increases the size of the file 8 fold (worst case - not to mension you already added attributes).
Admin
Admin
The real WTF here is the use of the plural "bytes" to represent a single byte. It should obviously be: <bytes> <byte>12</byte> <byte>193</byte> : </bytes>
There. much better.