News for hackers. Stuff that matters.
Re:Dart language by nzonbi on Monday October 10, 2011 @05:55AM (#3093065)
Agree with parent comment. My opinion, so far:

Overall: uninspired. Below what I was expecting. Probably good for Google goals (tooling, migrating developers, etc)

The language is somewhat interesting, but unfortunately saddened by an incredibly boring syntax. At this point, I am thinking that they would have been better off just going with the Go language for this. Looks like something good to migrate fleets of java engineers to, but not something that would inspire "hackers".

Now I feel like it is not worth to create any "brigthly" IDE whatsoever. Just go with eclipse.

I was planning to immediately rush to the language. But changed to wait and see now.

Misses:

  - Incredibly uninspired, boring Java-like syntax.
  - Not everything is an expression.
  - Java-like classes, instead of anything more interesting.
  - Lacks simplicity, symmetry and beauty.
  - Semicolons.
Some notes:

  In Dart, you can often create objects directly from an interface, 
  instead of having to find a class that implements that interface
What?? Why to blur the concepts of classes with interfaces and introduce a quirk? Beauty comes from simplicity and symmetry.

  named constructors:
  var greeter = new Greeter.withPrefix('Howdy,');
Mildly interesting.

  Every type in Dart is public unless its name starts 
  with an underscore ("_")
I laughed at this. I always have hated the practice to start with "_" for supposed private variables, in languages without true private. I like it this way in Dart. My little favorite syntax feature until now.
Re:Dart language by phillmv on Monday October 10, 2011 @11:10AM (#3094078)
Can someone explain to me what's the point of having syntax like:

`var foo = new Bar()`?

Why can't a constructor just be a regular method that happens to return a new instance? What's with this new nonsense?

Re:Dart language by tomp on Monday October 10, 2011 @01:08PM (#3094702)
I agree, this syntax makes little sense in dynamic languages where classes/types are first-class values that share the namespace with functions and ordinary values... Even in JavaScript, where it sort-of-kind-of makes sense, it introduces more problems than it solves.
Re:Dart language by Someone on Monday October 10, 2011 @04:26PM (#3095654)
Nitpick: you can make a constructor look like a regular method that happens to return a new instance, but you cannot make it one. How would that constructor make the instance that it returns?

I think the overhead of adding that 'new' is worth it. Without it: in var foo = Bar(), is Bar a type or a function? If you decide it should be colored like a type, your syntax colorer needs deeper information about the code, making it harder to write, slower, etc.

Re:Dart language by SeoxyS on Monday October 10, 2011 @08:00PM (#3096434)
Not true, look at Objective-C for an example of how it's done. Broken up into two methods, the first of which is a static method which creates an uninitialized instance, and the second which is a plain method which initializes the instance and returns self (or rarely, nil):

    + alloc // reserves memory and creates an instance
    - init // initializes the instance
    - initWithSomething: // can have multiple inits
Re:Dart language by ajanuary on Tuesday October 11, 2011 @07:51AM (#3098186)
I go back and forth on whether I like this. On the one hand, the clean split makes it conceptually simple what's going on. On the other hand, you can have allocated, uninitialized code, which makes me uneasy.
Re:Dart language by SeoxyS on Tuesday October 11, 2011 @02:21PM (#3099708)
You always chain together `alloc` / `init` calls, and so you're hardwired never to have a situation where you don't initialize something you've allocated. I think the compiler even knows to warn you about it, now.
Re:Dart language by phillmv on Monday October 10, 2011 @04:51PM (#3095786)
>but you cannot make it one

Why not? It makes no difference whatsoever. Make it so that the only constructor in the system is Object.new(), and so everything else that inherits behaves just like a method.

>Without it: in var foo = Bar(), is Bar a type or a function?

That's easy. Make it so that only classes and consts can be capitalized.

Blammo!

Re:Dart language by arctangent on Monday October 10, 2011 @06:36AM (#3093164)
I agree with you about the syntax - I was hoping for something more like Python.

Perhaps this is by design, though? Presumably the syntax doesn't look too bad to people who spend all day writing JavaScript (i.e. the target demographic for this language).

Presumably some bright spark will eventually write a Python-to-Dart compiler and then we'll all be happy :-)

Re:Dart language by nextparadigms on Monday October 10, 2011 @09:18AM (#3093624)
When you're trying to change things, it's best to appeal to the early adopters and to do give them a real reason to switch. Making it look the same and appealing to the same "user base" won't work, because then they might find little reason to switch in the first place.
Re:Dart language by cppsnob on Monday October 10, 2011 @03:43PM (#3095446)
Staying with the norm worked out quite well for both Java and C#.
Re:Dart language by artsrc on Monday October 10, 2011 @08:21PM (#3096505)
When I learned Java in 1996 I did not already know Haskel, Lisp and Python. Now I do.
Re:Dart language by cppsnob on Tuesday October 11, 2011 @02:04AM (#3097346)
I learned LISP and Python before Java and C#. The latter two are just as useful nevertheless.

The world's experience outside of HN makes me think Dart will not be at all inhibited by its Java like syntax. If it doesn't catch on, it will be for other reasons.

Re:Dart language by rdtsc on Monday October 10, 2011 @07:48AM (#3093352)
> I was hoping for something more like Python.

Me too! We already have a very readable, simple and elegant language, let's use that. Anyone know why that wouldn't have worked? (Not using the current CPython implementation but maybe the same syntax but with a different (web-only) set of libraries, that is...)

Re:Dart language by nailer on Monday October 10, 2011 @08:04AM (#3093389)
That's almost exactly what coffeescript is.

With Source Mapping in browsers, it also means you'll be able to get a .coffee line in your tracebacks too.

Re:Dart language by rdtsc on Monday October 10, 2011 @08:39AM (#3093500)
I agree. Yes, I would have liked to just have coffeescript as their new language. Maybe they could have just supported direct native execution on Chrome. Maybe Firefox would have followed.
Re:Dart language by LeafStorm on Monday October 10, 2011 @10:59AM (#3094029)
CoffeeScript solves most of the problems with JavaScript's syntax, but the problem they're trying to solve here isn't the syntax, it's the structure and semantics.
Re:Dart language by rayiner on Monday October 10, 2011 @10:18PM (#3096791)
Because Python's semantics are fucktarded.
Re:Dart language by mikeleeorg on Monday October 10, 2011 @01:18PM (#3094767)
I interpreted (no pun intended) this all to mean is that Dart is aimed at people who spend all day writing Java.
Re:Dart language by haasted on Monday October 10, 2011 @07:49AM (#3093355)

  In Dart, you can often create objects directly from an interface, 
  instead of having to find a class that implements that interface
What?? Why to blur the concepts of classes with interfaces and introduce a quirk? Beauty comes from simplicity and symmetry

Sounds like Java's anonymous classes. Quite a useful feature, actually.

Re:Dart language by calebmpeterson on Monday October 10, 2011 @09:26AM (#3093649)
Sounds like Java's anonymous classes. Quite a useful feature, actually.

It's only useful because Java lacks first class functions and syntax for lambdas. This is the single most irritating thing about Java to me. When this is fixed with the release of 8, the only thing Java will be missing is a really good implementation of persistent data structures a la Clojure.

Re:Dart language by nathanwdavis on Monday October 10, 2011 @11:19AM (#3094128)
I agree that the syntax and semantics are uninspiring (you could say the same about Scala).

Where it shines IMHO is in the core library (http://www.dartlang.org/docs/api/index.html). Look there and you will find some interesting classes that deal with concurrency and asynchronous operations (Isolate, ReceivePort, Promise<T>). Also, unlike standard Javascript, there are collection classes for specific use cases (like Queue, Set, LinkedHashMap). This is where it is superior to both Javascript and mainstream static typed languages like Java.

Re:Dart language by mrb on Tuesday October 11, 2011 @04:47PM (#3100235)

  - Incredibly uninspired, boring Java-like syntax.
Syntax should be boring. It should not deviate from one's expectations. One should not spend any mental resource thinking about it.
Re:Dart language by iaskwhy on Monday October 10, 2011 @07:57AM (#3093373)
What does "boring Java-like syntax" mean? Can anyone show some quick examples of a boring and a not boring syntax?
Re:Dart language by cubicle67 on Monday October 10, 2011 @08:48AM (#3093519)

    someString.append(System.getProperty("line.separator"));
vs

    some_string += "\n"

Edit: Someone's in disagreement with me, so I'll try and clarify. I'd classify boring code as code where the intent gets lost in the syntax/language or other constructs the maintainer of the code doesn't care about but are required anyway.

Trying to open and read a file in Java is probably a better example as the intent (open this file and read the contents) is buried in about 6 lines of boilerplate code

I use Java as an example because in a previous life I used to write it and see this as perfectly acceptable

Re:Dart language by dextorious on Monday October 10, 2011 @10:17AM (#3093832)
Well, for one you can probably make your own "+=" for strings, if not available, since Dart has operator overloading.

Also, System.getProperty("line.separator") does not translate to n"\n".

The first makes your program more portable. Of course it could be made accesible easier, eg as a constant System.NEWLINE or something.

[UPDATE] Downvote? Really? Because someone thinks "\n" is the same as "line.separator"?

Re:Dart language by jeltz on Monday October 10, 2011 @11:41AM (#3094233)
Indeed they do not translate into the same thing. But neither makes your program more or less portable in itself. It all depends on what you want to use it for. Some files and protocols should always have \n some always \r\n while in some cases it should be the system line separator. I think Python, Perl, C, and Ruby have fixed that quite well by making the IO library do the conversions. I do not remember if it is the same in Java.
Re:Dart language by d0mine on Monday October 10, 2011 @08:53PM (#3096579)
I didn't downvote, but see universal newline support in Python http://www.python.org/dev/peps/pep-0278/
Re:Dart language by nmcfarl on Monday October 10, 2011 @10:50AM (#3093992)
Of course they could have taken perl's tact and defined "\n" to mean System.NEWLINE not 0x0A.

That would have been an improvement right there.

Re:Dart language by highwind81 on Monday October 10, 2011 @09:57AM (#3093766)

    Circle my_circle = new Circle();
I have to type the word circle 3 times to define a circle. It gets boring. This gets worse if you are trying to do any kind of user input.

    BufferedReader my_reader = new BufferedReader(new InputStreamReader(System.in));
Had to type reader 4 times. :(
Re:Dart language by seasoup on Monday October 10, 2011 @11:23AM (#3094145)
People can argue with "boring", call it redundant instead and you'll get less harsh feedback.
Re:Dart language by cromwellian on Monday October 10, 2011 @12:45PM (#3094566)
Dart doesn't require the type.

var c = new Circle();

Re:Dart language by chc on Tuesday October 11, 2011 @11:59AM (#3099092)
But then it appears to just turn off type checking. This would be the cakiest cake ever for even a shoddy type inference engine.
Re:Dart language by iaskwhy on Monday October 10, 2011 @11:54AM (#3094304)
But is it something people actually type? I haven't played with Java for almost ten years now but I do C# for a living which is pretty similar and I can't remember the last time I had to type something that long, Visual Studio does it for me. I can see the point if you say it's longer to read but it's also much clearer, isn't it?
Re:Dart language by Peaker on Monday October 10, 2011 @06:53PM (#3096230)
Redundancy is noise.. How is it any clearer to read?
Re:Dart language by iaskwhy on Tuesday October 11, 2011 @04:32AM (#3097742)
How's that redundant? In C# you would just "var something = new object()", so there wouldn't be any redundancy at all.
Re:Dart language by Peaker on Tuesday October 11, 2011 @08:24AM (#3098249)
I was replying to:

"Visual Studio does it for me. I can see the point if you say it's longer to read but it's also much clearer,"

So he's saying that: Circle circle = new Circle() is typed by Visual Studio for you, and clearer to read. I don't think it's clearer to read.

Re:Dart language by justncase80 on Thursday October 13, 2011 @12:12PM (#3107672)
It's kind of a misnomer too, because only the second circle is typed for you so you had to type Circle at least once... which is the same as if you were typing var. So it's not only not saving you much effort it's uglier. And with more complex types it's downright evil (to not use var).
Re:Dart language by nailer on Monday October 10, 2011 @08:02AM (#3093385)
Requiring a function for a simple print statement, perhaps? The demo breaks when you remove the surrounding main() loop.
Re:Dart language by cromwellian on Monday October 10, 2011 @06:15AM (#3093119)
Default interface implementations are nothing new. In Scala for example, if you create a Map, you can get it to automatically construct a MapImpl, without having to know it. A really common case in many code bases is 1 implementing class, and 1 mock/testing class, and this fits the common case really well.

I think "beauty" is really a subjective consideration when it comes to programming languages.

Re:Dart language by jmtame on Monday October 10, 2011 @07:08AM (#3093231)
Also, string interpolation using only double quotes has bothered me in Rails. That was the one feature I saw that they supported, although now that I think about it, Rails probably adopted it as a convention to prevent excessive escaping.
Re:Dart language by manveru on Monday October 10, 2011 @07:20AM (#3093269)
That's Ruby, not Rails. It allows you to influence how your content should be escaped, so you write '\n' instead of "\\n" and '"' instead of "\"", it's actually pretty handy in practice.
Re:Dart language by jeltz on Monday October 10, 2011 @09:00AM (#3093573)
I believe this interpolation difference in Ruby originates from Perl which in turn got it from bash and other UNIX shells. I actually like the fact that Ruby and Perl have so many way to quote a string a lot since I have always hated excessive escaping.