Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

This is why I never liked XML. There's no concept of a type. You can specify one in a DTD or something, but half of the tools I've used just never bothered, and it's now back inflexibility when you want to do something outside the boundaries of DTDs/schemas (optional schemas was considered one of XML's greatest strengths over SGML).

Without one, how can you know if <foo>12345</foo> represents the number 12345, or the string "12345"? You have to guess.

Adbot
ADBOT LOVES YOU

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender
I think the XML-ish completely unhelpful response to that complaint is that in <foo>12345</foo>, the 12345 is obviously of type foo, and you have to know the context of the message if you want a more concrete interpretation.

pseudorandom name
May 6, 2007

<value name="foo" type="string">12345</value>
<foo type="string">12345</foo>
<foo><string>12345</string></foo>
<string><foo>12345</foo></string>
<foo>"12345"</foo>

XML is great!

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

ShoulderDaemon posted:

I think the XML-ish completely unhelpful response to that complaint is that in <foo>12345</foo>, the 12345 is obviously of type foo, and you have to know the context of the message if you want a more concrete interpretation.

Right, so the type data is out of band, which means that the logic that can be implemented by you by a generic XML parser becomes less and less, which means that "generic toolkits" invent their own hacks because people are lazy.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Suspicious Dish posted:

Right, so the type data is out of band, which means that the logic that can be implemented by you by a generic XML parser becomes less and less, which means that "generic toolkits" invent their own hacks because people are lazy.

Yeah, it's kind of shameful that so many supposedly "generic" intermediate layers are prone to simply throwing out information and relying on the most ambiguous representations they can possibly get away with.

Horror: I have actually written modern code (in the last 2 years) for a new application that used Sun RPC to communicate. I was working in Haskell.

Horror2: It was pretty much the best experience I've ever had writing IPC code, and I have little doubt that time will show it to be the most reliable IPC code I've written.

pigdog
Apr 23, 2004

by Smythe
If you're doing something with the XML, you'd almost certainly expect it to be in a particular format. You can define that format in a .xsd schema, afterall that's what they're for. It's still a good idea define a schema for the XML data format even if you use a generic parser of some sort, if only for testing and documentation purposes.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

This is probably a coding horror in and of itself, but I can't stand XML and I can't really articulate any reason that an XML-defender couldn't give an answer of some sort to.

Neslepaks
Sep 3, 2003

Structure is nothing if it is all you got. Skeletons spook people if they try to walk around on their own. I really wonder why XML does not. --Erik Naggum

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Thermopyle posted:

This is probably a coding horror in and of itself, but I can't stand XML and I can't really articulate any reason that an XML-defender couldn't give an answer of some sort to.

It's ridiculous verbosity? The fact that people misuse it and just shove everything into XML?

There are obviously some good use cases for XML, somewhere down the line someone thought to use XML for everything. See: Java

pseudorandom name
May 6, 2007

There is one good use-case for XML: domain-specific text markup languages.

Nobody uses it for that.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

pseudorandom name posted:

There is one good use-case for XML: domain-specific text markup languages.

Nobody uses it for that.

Right. Text nodes are XML's most powerful feature, and everybody ignores it.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Suspicious Dish posted:

Right. Text nodes are XML's most powerful feature, and everybody ignores it.

I think I understand what you mean, but could you expand on this a bit? Why are text nodes XML's most powerful feature?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

pokeyman posted:

I think I understand what you mean, but could you expand on this a bit? Why are text nodes XML's most powerful feature?

Maybe not most powerful, but it's a powerful construct that everyone ignores. Maybe because the DOM bindings are so awful to work with. I mean, you use it all the time when you write HTML:

code:
<blockquote>
  Let's <em>emphasize</em> some text.
  Am I being too <strong>strong</strong>?
</blockquote>

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Right, that's what I had in mind. I've never, ever seen XML written like HTML.

Contero
Mar 28, 2004

What do people think about Yaml? I haven't actually used it in a project yet, but it seemed nice enough.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
It's awesome and is a superset of JSON but isn't as widely used.

TildeATH
Oct 21, 2010

by Lowtax
I used to hate JSON soooo much (And Javascript, I hated js, but that's another story...) but now it's really grown on me, and instead XML looks overly verbose.

etcetera08
Sep 11, 2008

pokeyman posted:

It's awesome and is a superset of JSON but isn't as widely used.

I'm seeing it more and more sprouting up in Github projects.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof
XML is great for applying semantics and structure to documents. JSON is great for serializing shared data. Both turn to poo poo when you abuse them.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

TildeATH posted:

(And Javascript, I hated js, but that's another story...)

JavaScript is an awesome language that's widely abused. I wish I knew it better.

Opinion Haver
Apr 9, 2007

code:
function Foo() {
    this.elems = [];
    this.push = this.elems.push;
}

foo = new Foo();
foo.push(1);
foo.elems.length == 0; // true

foo.elems.push(1);
foo.elems.length == 1; //true
:allears:

Bonus points to anybody who knows where the hell the first 1 gets pushed.

Opinion Haver fucked around with this message at 01:46 on Apr 28, 2012

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

yaoi prophet posted:

code:
function Foo() {
    this.elems = [];
    this.push = this.elems.push;
}

foo = new Foo();
foo.push(1);
foo.elems.length == 0; // true

foo.elems.push(1);
foo.elems.length == 1; //true
:allears:

Bonus points to anybody who knows where the hell the first 1 gets pushed.

It gets pushed to foo, so foo.length is 1. But if you REALLY want to burn your noodle, tell me why that doesn't work but this does:

code:
function Foo() {
    this.elems = [];
    this.push = function() {
        for (var a in arguments) {
            this.elems.push(arguments[a]);
        }
    }
}
foo = new Foo();
foo.push(1);
foo.elems.length == 1; // true
:crossarms:

DaTroof fucked around with this message at 02:40 on Apr 28, 2012

shrughes
Oct 11, 2008

(call/cc call/cc)

DaTroof posted:

It gets pushed to foo, so foo.length is 1. But if you REALLY want to burn your noodle, tell me why that doesn't work but this does:

Because that's the way Javascript works?? Nothing there is a mystery.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

shrughes posted:

Because that's the way Javascript works?? Nothing there is a mystery.

If functions are first-class objects, those two snippets should have the same behavior. It's not a killer bug or anything, but it's still weird.

pseudorandom name
May 6, 2007

push() operates on this, not this.elems, I'm not sure why this is surprising.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

pseudorandom name posted:

push operates on this, not this.elems, I'm not sure why this is surprising.

Because push operates on this in the first example, but it operates on this.elems in the second.

pseudorandom name
May 6, 2007

Well, yeah, you're calling this.elems.push() instead of this.push(). None of this is weird or surprising.

ToxicFrog
Apr 26, 2008


DaTroof posted:

If functions are first-class objects, those two snippets should have the same behavior. It's not a killer bug or anything, but it's still weird.

Functions are first class objects but they aren't closures over their enclosing object; this is passed to the function at call time.

So:

code:
function Foo() {
    this.elems = [];
    this.push = this.elems.push;
}

foo = new Foo();
foo.push(1);       // this == foo
foo.elems.push(1); // this == foo.elems
Same function is called both times, but on different objects.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

DaTroof posted:

Because push operates on this in the first example, but it operates on this.elems in the second.

The this argument is whatever is on the left-hand side of the call. Unlike other languages where a.b.c(); can be decomposed into var f = a.b.c; f();, JS needs the qualification.

And:

code:
Array.prototype.push = function(val) {
    var length = this.length || 0;
    this[length] = val;
    this.length = length + 1;
};
So in the first instance, the 1 is pushed to foo[0] (or foo["0"], arrays are just objects, and the property names are all integers)

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

pseudorandom name posted:

Well, yeah, you're calling this.elems.push() instead of this.push(). None of this is weird or surprising.

They both use foo.push(), but only one of them pushes to foo.elems. Point being, I don't know why assigning an anonymous function to this.push works, but this doesn't:

code:
this.push = this.elems.push;

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

ToxicFrog posted:

Functions are first class objects but they aren't closures over their enclosing object; this is passed to the function at call time.

So:

code:
function Foo() {
    this.elems = [];
    this.push = this.elems.push;
}

foo = new Foo();
foo.push(1);       // this == foo
foo.elems.push(1); // this == foo.elems
Same function is called both times, but on different objects.

Ahh, that actually makes sense. Still seems weird to me, but I get the logic now. Thanks.

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Suspicious Dish posted:

The this argument is whatever is on the left-hand side of the call. Unlike other languages where a.b.c(); can be decomposed into var f = a.b.c; f();, JS needs the qualification.

And after that, it doesn't even seem weird anymore. Sheesh. Maybe I need some sleep.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

DaTroof posted:

And after that, it doesn't even seem weird anymore. Sheesh. Maybe I need some sleep.

Right, it's a bit unnatural when you're used to a language that automatically creates a bound closure for you, like Python. Note that in ES Harmony, they're planning on making automatic soft bound closures the default.

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





Contero posted:

What do people think about Yaml? I haven't actually used it in a project yet, but it seemed nice enough.

yaml is awesome until you look at the spec and realize how hosed up and horrible it can get. all so you can omit `{}`, `[]` and `"`

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through

Thermopyle posted:

This is probably a coding horror in and of itself, but I can't stand XML and I can't really articulate any reason that an XML-defender couldn't give an answer of some sort to.

I'm coding an app that reads data from user generated, but otherwise static, XML files like this one:

http://pastebin.com/As98K9S0

It is awfully verbose, but I don't know of anything else that would make sense to use. I don't really have an extensive coding background, though.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

pokeyman posted:

I think I understand what you mean, but could you expand on this a bit? Why are text nodes XML's most powerful feature?
Because you can encode non-XML formats in them of course! :downs: (and more!)

Contero
Mar 28, 2004

code:
<string xmlns="urn:Initech.Global.Services">
  &lt;CompanyGetConnector&gt;
    &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;xs:element name="InitechGetConnector"&gt;
        &lt;xs:complexType&gt;
          &lt;xs:choice maxOccurs="unbounded"&gt;
            &lt;xs:element name="employees"&gt;
              &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                  &lt;xs:element name="EmployerName" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Employee" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Firstname" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Prefix" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Lastname" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Org._unit" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Function" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="E-mail_work" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Telephone_work" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Mobile_work" type="xs:string" minOccurs="0"/&gt;
                  &lt;xs:element name="Birthdate" type="xs:date" minOccurs="0"/&gt;
                  &lt;xs:element name="Hired_since__irt._yearsemployed_" type="xs:date" minOccurs="0"/&gt;
                  &lt;xs:element name="Image" type="xs:base64Binary" minOccurs="0"/&gt;
                &lt;/xs:sequence&gt;
              &lt;/xs:complexType&gt;
            &lt;/xs:element&gt;
          &lt;/xs:choice&gt;
        &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
    &lt;/xs:schema&gt;

    &lt;employees&gt;
      &lt;EmployerName&gt;
        My Client
      &lt;/EmployerName&gt;
      &lt;Employee&gt;
        100001
      &lt;/Employee&gt;

      [cut rest of employee info]

      &lt;Image&gt;
        Nx4U8fSs+0lLRRNjORrUg/495x23NWHYf6j8T/OqW7QnsndLp74jJ5p64q6XycDrWZYk4PPc

        [cut rather large blob]

      &lt;/Image&gt;
    &lt;/employees&gt;
  &lt;/CompanyGetConnector&gt;
</string>

quote:

it's actually better this way for future compatibility and, regardless, several customers already use it tihs way.

:stare:

Impotence
Nov 8, 2010
Lipstick Apathy

Contero posted:



:stare:

code:
<string encryption="64-bit">
	PHN0cmluZyB4bWxucz0idXJuOkluaXRlY2guR2xvYmFsLlNlcnZpY2VzIj4NCiAgJmx0O0NvbXBhbnlHZXRDb25uZWN0b3
	ImZ3Q7DQogICAgJmx0O3hzOnNjaGVtYSB4bWxuczp4cz0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiJmd0
	Ow0KICAgICAgJmx0O3hzOmVsZW1lbnQgbmFtZT0iSW5pdGVjaEdldENvbm5lY3RvciImZ3Q7DQogICAgICAgICZsdDt4cz
	pjb21wbGV4VHlwZSZndDsNCiAgICAgICAgICAmbHQ7eHM6Y2hvaWNlIG1heE9jY3Vycz0idW5ib3VuZGVkIiZndDsNCiAg
	ICAgICAgICAgICZsdDt4czplbGVtZW50IG5hbWU9ImVtcGxveWVlcyImZ3Q7DQogICAgICAgICAgICAgICZsdDt4czpjb2
	1wbGV4VHlwZSZndDsNCiAgICAgICAgICAgICAgICAmbHQ7eHM6c2VxdWVuY2UmZ3Q7DQogICAgICAgICAgICAgICAgICAm
	bHQ7eHM6ZWxlbWVudCBuYW1lPSJFbXBsb3llck5hbWUiIHR5cGU9InhzOnN0cmluZyIgbWluT2NjdXJzPSIwIi8mZ3Q7DQ
	ogICAgICAgICAgICAgICAgICAmbHQ7eHM6ZWxlbWVudCBuYW1lPSJFbXBsb3llZSIgdHlwZT0ieHM6c3RyaW5nIiBtaW5P
	Y2N1cnM9IjAiLyZndDsNCiAgICAgICAgICAgICAgICAgICZsdDt4czplbGVtZW50IG5hbWU9IkZpcnN0bmFtZSIgdHlwZT	
	
	[cut rest of blob]
</string>

Opinion Haver
Apr 9, 2007

I like the repeating ICAgICAgICAg. I bet they're using EBC because the person who implemented their encryption doesn't know the first thing about block ciphers.

Adbot
ADBOT LOVES YOU

Impotence
Nov 8, 2010
Lipstick Apathy

yaoi prophet posted:

I like the repeating ICAgICAgICAg. I bet they're using EBC because the person who implemented their encryption doesn't know the first thing about block ciphers.

Nah, that was base64 of the quoted post. I've actually seen it encapsulated in XML like three levels deep. And some people actually consider it encryption :psyboom:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply