News for hackers. Stuff that matters.
Re:Why Dart is not the language of the future. by cubicle67 on Tuesday October 11, 2011 @10:19AM (#3098640)
no, it means that dart includes almost as much wtfery as js does. Things like not being able to say if (a) because unless a is a boolean true, then it's considered false. So we need to say if (a==a), except that there's no guarantee == will return a boolean, so it's possible (a==a) may evaluate as false!

If dart wants to replace javascript it has to be better, and by a long shot. at the moment I'm just not seeing that it is

Re:Why Dart is not the language of the future. by unwind on Tuesday October 11, 2011 @10:37AM (#3098706)
Having a == a be able to generate false is quite common, it's for instance the case in C, C++, Python and Ruby (off the top of my head), when a is the floating-point entity NaN. Surely not all of these languages are ill-defined?
Re:Why Dart is not the language of the future. by elisee on Tuesday October 11, 2011 @10:49AM (#3098772)
The issue isn't about the == operator returning false. It's about the == operator's return value not being typed.

Evaluating "a == a" could return the string "potatoe" which would evaluate to false (and make no sense).

I don't see the big deal with this. If your == operator is buggy, it's buggy, no matter whether you can only return a boolean or some random other type.

(I personally found most of the criticism in the article to be in the same vein: inflammatory, superficial comments after a quick reading of the spec.)

Re:Why Dart is not the language of the future. by arcdrag on Tuesday October 11, 2011 @11:52AM (#3099072)
Generally any blog written a day after the spec released is going to be pretty superficial. It isn't like they have time to be able to construct any real criticisms. Personally, if not being able to say if(a) is the worst criticism of the v.1 spec you can find, then it must be a pretty decent spec.
Re:Why Dart is not the language of the future. by rbonvall on Tuesday October 11, 2011 @10:53AM (#3098788)
Actually NaN != NaN is not a language design, it is required for complying with the IEEE 754 standard.
Re:Why Dart is not the language of the future. by tomp on Tuesday October 11, 2011 @11:54AM (#3099078)
That's still language design... Personally, I would make NaN == NaN in a language I would design, and provide a Float.equals function that would follow the IEEE standard.
Re:Why Dart is not the language of the future. by Ogre on Tuesday October 11, 2011 @11:05AM (#3098834)
You wouldn't have to write if(a==a) in the first place in those languages, however. if(a) would suffice in C and C++ for an integer type or a pointer, and possibly for an object in C++. An integer value would also work in Python. I can't say anything about Ruby.

The fact that a==a can return false isn't really the main criticism here. You could override the == operator in C++ to do that too. The article is claiming that having a literal boolean true be the only "true" value is an issue. I think I agree with this just because this code evaluating to false is out of line with every other language out there, and I haven't seen a case (yet?) that it's an improvement for any other practical purposes:

  a = 1;
  if(a) {
    print("A is true!");
  }