Why Dart is not the language of the future.
blogs.perl.org
blogs.perl.org
> Dart programs may be statically checked. The static checker will report some violations of the type rules, but such violations do not abort compilation or preclude execution.
> In other words the "static checker" is a lint-type development aid, not a language feature.
My reading is that the language is optionally typed (similar to SBCL). The type checker will warn you when you have a type declaration that appears to be incorrect, and will optimized based on these declarations, but will not keep you from running code that violates a type-check. This is a remarkably good solution for dynamic languages.
> Here's a strange thing: the one and only true value is the boolean literal boolean true. Everything else is false. That means that code in if (1) { ... } will never execute, because 1 is a number, not a boolean, and there is no implicit conversion to boolean. You'll need to write if (1==1) instead.
This makes as much sense as 'everything' being true. You would write if (true) {...}, but I can't imagine why you would do that.
> There is no implicit type conversion between numeric, string or boolean types.
Ok. This is a good thing. Auto conversion is bad.
> The distinction between string and numbers allows to re-use the addition operator + both for addition and concatenation. However, without strong typing, this will almost certainly prove to be a bad idea. From the specs, it looks like "2" + 2 will be a concatenation, and 2 + "2" a run-time exception (in the absence of implicit conversion from string to number), but experience infirms this: string concatenation happens in both cases (although with a warning in the second one).
This seems to directly contradict the first point. Which is it? It should do a dynamic type check and generate a run time exception in both cases. I don't see anything to convince me that "2" + 2 will be a concatenation... in the spec.
>Thus, isolates are a heavyweight thread control model very much like Perl 5's ithreads. That means that they are good for data isolation, but heavy to use and hungry in memory, because spawning a new isolate will imply cloning all the objects and data structures of the running libraries.
There is absolutely nothing that implies this. There is a tiny section in the spec about isolates. They could easily be lightweight like Erlang processes.
> You would write if (true) {...}, but I can't imagine why you would do that.
In haste to make your point, you overlook that Boolean expression are used in loops too. Combined with a "break;" I'm sure many here have used a "while (true)".I think his real point is that there's no 'truthy', no evaluation to true. Later in the article he says that
if (a) a.foo();
isn't possible because of that. A better example would've been (a != null) instead of (1 == 1), imho.> This seems to directly contradict the first point. Which is it? It should do a dynamic type check and generate a run time exception in both cases. I don't see anything to convince me that "2" + 2 will be a concatenation... in the spec.
Not in the spec itself, right. But the current documentation seems to imply exactly what he states. See the definition of '+' here: http://www.dartlang.org/docs/api/String.html#String::String
"String +(Object other) Converts other to a string and creates a new string by concatenating this string with the converted other. "
This is a good practice, even better would be checking the type or class.
> "String +(Object other) Converts other to a string and creates a new string by concatenating this string with the converted other. "
This is a bad idea, now I have a gripe with dart.
http://qconlondon.com/london-2009/presentation/Null+Referenc...
Like I said, I'm not particularly a fan of Dart.
ie. data Maybe a = Nothing | Just a data Either a b = Left a | Right b instead of (err,result) like in go
I don't think this is right, and seems to be bad wording on part of the documentation. I don't have any access to an interpreter right now, besides the Google AppSpot in-browser console, but adding a String Object and a Date Object to a new variable does not alter either object or do a forced alter on the existing objects, but rather creates a new string object.
Though, I can't tell if either the date object, or the first string object in this example are altered, it appears that they aren't changed during concatenation: http://try-dart-lang.appspot.com/s/KSAX
The gripe comes from overloading the + operator, for all I can tell. That's at least the point of the author of the blog post, having + for addition and concatination, with poor type support.
The blog claims that "1" + 1 = "11" (exactly what the docs state here) and claims the same for 1 + "1".
>Ok. This is a good thing. Auto conversion is bad.
One of the things I really dislike about developing in Ruby is that I can't do
value = 5 "The value is " + 5
I get bitten by this at least 10 times a day while developing, usually either when dumping to the log, or writing into html. I can fix the problem really quickly now, but every time I get an error:
"r" + 5 "TypeError: can't convert Fixnum into String"
I think, yes, yes you can easily convert a Fixnum into a String.
"r" + 5.to_s
It just means I have to sprinkle .to_s everywhere in my code. Ridiculous!
If one really wanted that kind of behavior (and not getting errors when trying to add strings and number) you could make it so:
class String
def +(o)
warn "You are adding a #{o.class} to a string." unless o.is_a? String
"#{self}#{o}"
end
end
for example.Whether this leads to other issues is left as an exercise for the reader and whomever ends up maintaining the reader's code.
value = 5 "The value is " + 5
is supposed to do? at the moment i can't work out why it would be frustrating to be unable to type something that looks like a syntax error... (i'm assuming it has some meaning in a language i don't know, which i guess would mean php).edit: what does "say" mean in the reply below? print? evaluate? and does "later" mean in another statement? or replacing what was before?
value = 5
"The value is " + 5
If you really want that value in your string, why not use "The value is #{value}"
"r#{5}"
or in actual use something like "I have #{me.num_of_children}\n"
much better then Auto conversion
In python "I have " + str(me.num_of_sons) + "and " + str(me.num_of_daughters) +"\n"
does get annoyingAs I understand it, it's not that you might write if(1){} literally. It's that you might write a method to return <something> on success or null on failure, and ordinarily that would be reusable in a conditional. In Dart, it's not - unless you're careful. This is not the sort of thing we have grown up thinking that we need to be careful about.
Combined with the author's example of a==a potentially evaluating to either false or true depending on the class in a really unexpected way, I'm just seeing potential for confusion and I can't see any immediate reason why they would have thought that this would be a good idea. Yes, the spec mentions JS's problem with an autoboxed false, but they've just moved that problem around, they haven't solved it.
Doing this is like writing a pun into your code. Check the type of it, or check if it is equal to null (or if it is not equal to null).
> If the results should be saved, that should generally be done outside the if condition anyway.
That's as may be. This is one of those areas where the language is guiding you towards a specific code pattern rather than explicitly preventing something, and I just don't think in this case the guidance is helpful or warranted. I think it's a side-effect of a workaround for a bug in the compilation target, and that's not a good thing to expose at the language spec level.
We all started with some bad practices, and as we matured our code did too. But the loose, forgiving standards are precisely what enabled broad use in the first place.
When a language imposes more constraints on the programmer (it may be for their own good!), it limits adoption and growth.
1: From the summary of Javascript: The Good Parts, "... Douglas Crockford identifies the abundance of good ideas that make JavaScript an outstanding object-oriented programming language-ideas such as functions, loose typing, dynamic objects, and an expressive object literal notation. Unfortunately, these good ideas are mixed in with bad and downright awful ideas, like a programming model based on global variables."
I'm an advocate of the python model (although I should maybe call it the Modula-3 model): only allow module-level globals. You get globals if you need them, but no worries about code mangling your variables.
The difference is that JavaScript has a design flaw in that if you forget to declare a variable before you use it, it becomes globally scoped. This causes local variables inside functions, for example, to become accidentally global leading to bugs.
This was my impression exactly when I first read about Dart. This is the language that Google wants to replace Javascript? Please. Javascript may have some strange design quirks (or outright flaws, depending on who you talk to), but at least it has the sense to have a meaningful boolean context. I understand that you can't try to revolutionize everything if you're targeting a wide audience, but this just looks like decaffeinated Java.
"Meaningful boolean context"s have given us things like the abundant "if (!!foo)" in JavaScript. And then he goes on to criticize absence of auto-conversions, which are the other plague of dynamic programming languages (see "===" & friends).
I don't see how anyone could actually want that kind of litter in his programming language.
...then he goes on to complain that there's no automatic type coercion! This is probably one of the worst misfeatures of JavaScript (and Perl and PHP), but after a short tirade about "weak typing", he's longing for automatic type coercion? Sorry dude, "3 dog night" + 2 should not equal 5
Self, actually. Dart is closer to Smalltalk in Java's clothing.
Oh and it's posted on a Perl blog. Completely objective I'm sure.
1) I have a hobby horse 2) Dart gets released 3) Flog hobby horse
Go had a bunch of similar criticisms, mostly for not being "innovative" enough and favoring a small, solid feature set.
I don't really have an informed opinion on dart yet, I'm just noting that 90% of the complaints I'm seeing consist of people with a hobby horse that predated the Dart announcement.
It's a good thing then that the author of this article falls in your 10% group: someone who actually knows a thing or two about language implemetations, and not a hobby horse rider.
But you see, Go got all this attention just because it is a language released by Google. And in the meantime version 2.0 of a real systems programming language that is innovative and kick-ass is largely going unnoticed.
Which one?
Edit: I'll take a stab in the dark and say D?
Of course that wont't stop people who have not written any Go code from claiming Go is worthless without them.
http://www.reddit.com/r/programming/comments/kikut/think_in_...
Not to mention somebody quite biased given that Go has been way more successful in being used to build actual systems than Alexandrescu's D2.
Everyone I know who has actually used Go strongly disagrees with this claim, they are very happy with Go's interface system and most of them don't notice the lack of generics at all.
Go is not like other languages, and 'features' are not interchangeable across languages.
> But you see, Go got all this attention just because it is a language released by Google.
Yea, that it was created by Ken Thompson and Rob Pike had absolutely nothing to do with it. /a
Say Google unveiled a Scala, Haskell or even Go like language.
Sure, the hip crowd would be pleased. But would it ever gain traction with the web dev masses?
Hell, those languages have not that much traction even outside web development.
Now, if Google had unveiled something like Ruby or Python, that would have also pleased the HN crowd (maybe a little less that some extravagant functional language with crazy type tricks). And it could possible gain traction too. But that too would hardly be revolutionary.
(Not a huge jump for Android programmers, either. In light of the Oracle lawsuit avalanche, this might be interesting…)
Now I am using ActionScript to make a point, since I have not yet programmed in it to be able to address how much Dart does or does not mimic the AS syntax.
Is ActionScript "type-optional" as with Dart?
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
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.)
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!");
}Then dart does not have a nice concept of true/false witch most lisps have.
Take-up is all that matters in the future; the quality of a programming language has rarely had any influence on take-up.
* The backing of the largest web company in the world.
or * Inclusion in the second-most popular browser in the world.
Yep. That aught to do it.Most languages (including Perl) have at least one case where a==a is not true. (0.0/=0.0) == (0.0/0.0), or any NaN == NaN expression.
> if (1) { ... } will never execute, because 1 is a
> number, not a boolean,
This hasn't stopped Ruby from being popular. x = meep
if x
# do stuff
end
will run as most might mean. > I guess you mean the opposite hasn't
> prevented Ruby from being popular.
I was stating something more like "the fact that there is a hard split between numbers and booleans, and everything -- barring null -- by default evaluates to true." Since everything is a object instance in Ruby, asserting a variable is basically only evaluating whether or not it is null. type(x) == Boolean ? x == True : x != nil
Disclaimer: That may not be valid Ruby, as I only have a passing knowledge of some bits of Ruby.I can understand forbidding non-Boolean values in Boolean contexts - it's not something I'd want myself but I think I get why a reasonable person might. Dart's semantics, though, are really strange: they follow no precedent I'm aware of, and don't seem to offer anything useful in themselves. Does anyone else have some insight here?
[UPDATE: yes, please, down vote freely, because humor is dangerous].
Why is it surprising that a language designed to occupy a niche between shell and C in 1987 had a spec faster and looser than a language designed from (let's say) 2009 through 2011, based on an existing, popular, and well-understood language with well-publicized flaws?
Sure, but is it? Does it have any chance at all of being "the language of the future"? Or, is it a very old, mature language that has reached a plateau or is in slow decline?
If anybody but Google released Dart HN wouldn't give two shits.
Perl has been out fucking forever and still isn't in the browser, so stop whining. Javascript whipped your ass in this arena, Perl.
I was there in 1995 and I have no recollection of anyone saying that. People were generally excited by its possibilities. The worry was about a) embedding a VM into a browser back when memory was limited and b) java was controlled by one company and wasn't an open standard.
Javascript won the 'browser war' because a) it was already there so it didn't need a plugin b) it was 'good enough' for its time c) it had Java in the title d) it had the sense to become an ECMA standard.
Perl never had any plans to be in the browser it was always a Unix command-line tool.
What is interesting is that Java started as a language for making UIs on iPad-like devices, The first web-server was written in Objective C, Perl gained traction as the way CGI programs were written. Now, Objective-C is used for programming iPads, Java moved from UI to Server and displaced Perl for corporate web apps. Meanwhile Javascript has quietly solidified its role in the browser and may finally make the leap to being a major server tech.
"Perl never had any plans to be in the browser it was always a Unix command-line tool."
Perl is not (just) a "Unix command-line tool". It is an interpreted language. It was a preferred language for old school webapps in the mid-to-late 90s, and continued in use a lot through the 2000s. Now for the majority, it has been replaced, except for code that is still running on old servers.
So why are Perl programmers ranting against Dart? Javascript is somewhat of a sore spot, even though the average Perl programmer would not admit to it and may not even realize it. A client-heavy web application that doesn't try to do things quickly saving keystrokes is about as far from Perl as one can get. Dart is "Javascript part 2" to the Perl programmer, and subconsciousnessly eats away at the Perl programmers ego. Even though they can't explain why, they feel as they must destroy it.