Why is Dart keeping certain cruft from other languages?
groups.google.com
groups.google.com
How is coffeescript 'daring' in any way ? It is a thin veneer on top of javascript, syntactic sugar for your coffee.
Dart is a hundred times more daring. It is trying to push optional typing. No mainstream language has such a feature, and not even so much non-mainstream ones.
It doesn't say anything about my opinion of any of those two languages (i actually use and like CoffeeScript), but it just sounds to me like you're looking at syntax only, where the important part of a language is its semantics.
I long for the day when statically typed/dynamic language debates are considered quaint and old-timey.
There was an article posted to HN, where someone instrumented web apps and determined that after some short "warm-up" period, even variables in web apps written in dynamic languages had static types. If a tracing JIT eventually knows what type is in all the variables, why can't we have a development process that uses this information? Isolate all of the "dynamic" code in separate modules marked as such (the JIT could tell us what those sections are) and inject the type information back into the source code. Production servers could keep track of such information over many months, and the developers could know with a high degree of certainty what all the types in all of the variables are.
CoffeeScript does compile into JS, but so does Dart. Both are in that sense just syntactic sugar.
CoffeeScript does make quite big changes to syntax though (often inspired by Ruby, Python, etc.) in many cases more than Dart which seems inspired by Java - and I don't think anyone considers Java 'inspiring' (useful and familiar, sure).
> Dart is a hundred times more daring. It is trying to push optional typing. No mainstream language has such a feature, and not even so much non-mainstream ones.
ActionScript.
And Groovy =D
With regards to Dart, that's like saying C++ is just syntactic sugar for assembly. When there's semantic differences between the mapping from one programming domain to another, I would argue that constitutes "compilation". I would agree with the statement for CoffeeScript though.
Dart's types do not affect runtime behavior (at least in the compiled-JS route), so basic types are quite close to JavaScript's, much like CoffeeScript.
There are also no features in Dart that cannot be compiled into JS, like say threading with shared state.
So overall I think it is reasonable to say that both Dart and CoffeeScript are close to JavaScript and built specifically to compile into it.
From my understanding, ActionScript is a gradually typed language. Contrast with Dart, which is optionally typed. In Dart, static type annotations do not affect the runtime semantics of the code. In ActionScript, the types do affect the runtime semantics.
It wasn't made to be exciting. For exiting go look elsewhere.
It was made for some very pragmatic goals:
1) to be used in the same context as Javascript (web clients mostly but some server too) 2) Look familiar to JS programmers 3) be more like Java and remove the bizarro JS behavior 4) be able to be made faster than V8 5) add some handy stuff to the mix.
Exciting does not come into play at all, and with this goals it should not.
With "exciting" you get Haskell or Clojure, languages with such small following that they celebrate it with blog posts when they are used by some company (personally, I like both, and they are both better than Dart for tons of things but not for Dart's specific goals).
Not that Dart is used by anyone as of now, but one of their goals is to have it be used. And conventional beats "exciting" every time in this goal (All the major used languages: C, C++, Java, JS, Python, Ruby, Perl, C#, all fairly similar and conventional).
Having said that, I think they could find some success in, say, making Chrome run Dart natively (as well as Javascript for the time being) and then getting other more hyped languages to compile to Dart.
True, they need "hype", but exciting in the way asked above just throws most developers off of it. No exciting language ever gained a stronghold in the market. Even Lisp in the AI/Lisp Machines era and Smalltalk in its heyday were marginal.
<b>Having said that, I think they could find some success in, say, making Chrome run Dart natively (as well as Javascript for the time being) and then getting other more hyped languages to compile to Dart.</b>
They do have Dart run natively in Dartium, a special Chrome version IIRC. But obviously I can't see Apple/Mozilla/MS playing along and adding Dart to their browsers.
One way they could gain ground would be to use the server side advantage (since they want Dart to work on the server too):
Make a better Node.js like environment with Dart, with no callback-spaghetti and single-thread issues, and add a top-notch web framework for it, suitable for both Rails and client-rendering style web development. Add MySQL/PostgreSQL and Mongo drivers.
I think something like that will catch on like wildfire.
That would fragment the web, just like if Microsoft made IE run .NET natively (or, like Microsoft made IE run ActiveX).
So hopefully that won't happen.
That being said, if you poke around and try the language, you'll see quite a few significant improvements and exciting features. I wouldn't say it's "slightly better", I would say there are some significant enhancements.
Some significant improvements include:
* Isolates for shared-nothing concurrency. Shared-state threads are error prone.
* Optional types. You don't always need to prove the entire world is validated by some ceremonial type checker. Web programming especially is a workflow where you want to "write some code, hit reload" and iterate as fast as possible. Also, sometimes you just can't express what you want with your type system. Optional types is a way to say "I was going to cast to Object anyway, so let's dispence with the pleasantries and just use var."
* Everything is an object. No more "some things are primitives, some things aren't."
* Arbitrarily sized integers. 'nuff said.
* Not everything has to be in a class. Dart has top-level functions. This makes utility libraries significantly easier to use.
* A package manager as a native part of the ecosystem. This encourages 3rd party developers to share code early.
* Significantly faster start up. Go ahead and print out all the classes that are loaded when you run a simple Hello World program with the JVM. We'll wait. :)
* (related to the above) All Dart programs actually start running with main(). Turns out, this is not the case in JVM, due to how statics are initialized.
* Snapshots. Load code and libraries from a serialized binary heap. Significant startup performance improvements.
* Compile-time constants. These are canonicalized, and make for easy way to share data across isolates (they are immutable, for instance).
* Named optional parameters, with default values.
* All exceptions are uncaught.
* Throw any object. So you can throw "This is a crazy one-off error"
* Dartdoc comments can have markdown. This is awesome. :)
* A file can have a mix of classes and top-level functions.
* Lexical closures! (no more need for anonymous inner classes)
* Operator overloading.
* Method cascades. See http://www.dartlang.org/articles/m1-language-changes/#cascad...
All that really matters is "Are real developers more productive and having more fun? Are real developers launching more exciting apps?" That is the true test for Dart or any web language. Our experience is that evolutions, not revolutions, are a successful way to adoption.
Disclaimer: I'm a long time Java user and I have respect for the platform. I've written books on it, and launched many apps with it.
http://news.dartlang.org/2012/08/dart-editor-improves-on-cod...
var v = document.query("input#id");
v. //brings up intelli-sense for InputElement
You can also debug natively in Chrome or inside the Dart IDE. JetBrains are also developing their own plugin for Dart: http://plugins.intellij.net/plugin/?idea&id=6351
It also transpiles to JS (like CoffeeScript) but also includes a Dart VM which contains innovative features like Snapshotting for instant start-up times.
I really don't like X vs Y stuff (too many subtle and contextual issues), so I'm just trying to help the original commenter dig a little deeper.
The claim is not that we shouldn't have explicit statement terminating characters. It's that we already have one - new lines - and that mandating semicolons is both redundant and bug prone.
Personally, and while it doesn't really affect my choice of languages, I think you should be able to use one or the other, but not two consecutively.
In any case, excuse me for posting this, and I promise I won't discuss it here any more.
foo.bar(arg, objectToComputeArg2.computeArg(innerArg1, innerArg2,
innerArg3), arg3)
You can do the same in Python or in Lua. Lua will yell at you when it's actually ambiguous, as in function_returning_a_function(arg)(arg_to_returned_function)
(it_is_not_clear_whether_this_is_a_call_to_the_value_returned_by_the_previous_line())
You can disambiguate this with parentheses or using a semicolon, though. There's never actually a need to use a semicolon.Groovy's semicolon-less mode has lots of syntax restrictions. E.g.this doesn't compile...
println true
? "yes" : "no"I would't say 'lots'. It pretty much boils down to one thing: 'leave the operator on the previous line'
println true ?
"yes" :
"no"
For example is just fine. class Hello{
public static void main(String[] args){
System.out.println( true
? "yes" : "no" );
}
}
In order to work without semicolons, Groovy's grammar must restrict some things that work in Java. Semicolon-less mode in Groovy has a price.It was said (at the time) that C-like syntax meant a program was a series of expression, not statements. So something like
(void)1;
is valid syntax. Even compound expressions are valid: a=5, b=6;
Where I feel abandoned (betrayed?) is this: why then aren't compound statements also expressions? E.g. {
int x=Foo(50);
Bar(x);
}
The value returned could just be the value of the final executed expression (Bar yields a value). No need for 'return' at all.And no need for '?'.
int x = { if (i > j) 5; else 6; } (-> (Foo 50) (Bar))
(def x (if (> i j) 5 6))
I do miss the static typing and more readable syntax, though, and have appreciated Haskell in this regard. Too bad things like powerful macros and convenient syntax don't seem to gel together well in the same language. reportData = orders.collectMany {it.items}
.groupBy {it.product}
.collect { key,value -> [product: key,
vendor: key.vendor,
cases: value.sum() {it.actualQty},
productCharge: value.sum() {it.totalProductCharge},
platformCharge: value.sum() {it.portalCharge},
shippingCharge: value.sum() {it.shippingCharge},
dueProducer: value.sum() {it.totalDueProducer()}]}
Is perfectly valid groovy, spread on multiple lines with no semicolons.You seem to be making this out like its some huge inconvenience. It is very rarely an issue and its not like there are 5000 things you can't do. Its really just line breaks in statements that aren't delimited any other way that are effected and all you have to do it put the operator on the line prior to the break...
If we didn't have multi-line statements, new lines would work great as statement terminators.
why do you need semicolons?
I know syntax isn't everything in a language but it's pretty important. There are much better (IMO) ways to express yourself than the approach Dart takes.
So it appeals to the widest (and thus) more average programmer.
Languages have an implicit audience and purpose. For example I consider Java a language designed to be consumed by code-monkeys. The mentality that you have a large enterprise project and you look to India to hire 200 programmers to finish it for you. The language has to have static typing, it has to be familiar to those learning previous languages (C++, C), IDEs are the preferred work environments, everything is very explicit and verbose.
Take Haskell, it is a language that would appeal to an academically minded developer. Someone who knows about catamorphisms, uses words like endofunctor, or say wouldn't mind struggling for weeks to comprehend what a Monad is.
Those are 2 different audiences. Neither language is better or worse, they are just tools and in some cases one is a better fit, in other case another one is.
Dart is closer to the Java.. It wants to be used in large code bases, by many (including average and junior) programmers. So adding things like fancy list comprehensions, de-structuring assignment, pattern matching and stuff like that, might not fit with its goals.
Does anyone use Dart?