I think your argument is clear - but I think you're also missing a point about another approach to evolving JS, and how development stacks such as Dart can fit into this.
Bignums - ok - you claim that bignums could have made it into ES6 if google had provided more support. I'll take your word for it, but you can probably understand my scepticism.
I'm not religious about language either. I don't care much about syntax. What I really care about is being productive.
IMHO the main things that help my productivity are:
* optional types
* completion
* doc popups
* development-time runtime type checking
* good debugger
* Few implicit conversions
* Consistent core library
Now you argue that google would have been better off building these language features and tooling on top of ECMAScript instead of creating the Dart stack. What would this alternative scenario actually look like - especially from the point of view of a developer?
* It could be a mode in V8, or a fork of V8 (I'll call it "V8FutureMode"). V8FutureMode would be incompatible with other vendors JS VMs. Just as Dart is.
* Each time ES standardises a new feature already in implemented in V8FutureMode, then all your existing code would need to be updated to match the ES spec. This regular churn is painful for developers.
Now let's consider another scenario where google develops Dart, and ES20 arrives in 2020 with optional typing.
* 2013-2020. Stable language no breaking changes.
* In 2020 I can port my code over to ES20 (trivial as near 1:1 semantics, 99% automated).
This scenario is better for me as a developer. It also insulates me from the risk that optional types don't make it into ES until 2030. I also think it gives a lot of real world usage data helpful for getting optional types into ES. (You seem to disagree here.)
From the Dart team's perspective the Dart scenario is better too:
* Can build a core library and tools on a stable language, rather than having to regularly deal with breaking changes.
* Able to experiment with VM optimisations which are difficult to do in JS due to legacy compat.
* Personal motivation - this is what the developers really want to work on. (Being told by your boss to drop your experimental project, and continue doing the same old thing isn't always a good management approach)
I'm optimistic that over time experiments such as "use strong" will mean that the same optimisations implemented in the Dart VM will be able to be used in other JS VM's. Perhaps if a developer guarantees that all JS code is "use strong ES20", then it would be possible for a browser to even use a different VM behind the scenes (in Chrome perhaps even using the original Dart VM codebase, but with the language front-end changed to compatible with ES20).
The future is uncertain and difficult to predict. There are multiple ways to evolve JS - you seem quite certain that incrementally fixing JS is the only approach. I think building a new programming stack, and simultaneously evolving JS in that direction with insights learnt from the new stack, is also a valid approach. I don't understand why you have been so hostile towards this.
tl;dr -- you took too many words spelling out what I already said: that Dart diverged too much and can only hope to rendezvous with ES2030.
First, it can't without careful separation of its incompatible breaks with JS, from whatever optional type system is standardizable in future JS. The two are intertwined in Dart right now. JS is not going to break compat or add opt-in version selection to runtime-incompatible modes. That died with ES4, buried by 1JS.
Second, 2030 or even 2020 is way too far out, given the interest in TC39 right now from Google, Facebook, Microsoft, and other members. And because it took the long-odds bet, Dart is now clearly less likely than TypeScript => StrongScript to have any say on future JS optional types (AKA the revenge of ES4). You write
"I also think it gives a lot of real world usage data helpful for getting optional types into ES. (You seem to disagree here.)"
I'm not disagreeing just as a speculative opinion about 2020. I'm telling you that Dart has missed the optional types boat now, in TC39 -- the next meeting in less than two weeks. Dart and any real-world usage data from it are nowhere, while StrongScript is "on" and should generate V8-based data this year.
On the laundry list of "optional types / completion / doc popups...": most of this has been done without Dart in full or even Dart's optional types, including in the Closure compiler. (See DoctorJS for early higher-order control flow analysis that could do completion without making programmers declare types all over.)
Even the claim that a new VM is needed to do the complete laundry list is suspect at this point. Yeah, it's nice to have a clean slate, or one starting from StrongTalk's slate, as Dart did. But if only Google can afford it, it diverges incompatibly up front, and it can only partially re-converge far in the future, then it is very likely a "miss".
Life is not just a series of random Homer Simpson events, with everything about possible futures a matter of opinion. People bet on futures profitably, beating fair coin tosses. Alan Kay was right, the best way to predict is to invent.
So the smart money is not on Dart designing future optional types for JS. This could change but I doubt it, since Dart broke too much compatibility, unnecessarily for the purposes of making types optional. No one is disentangling and minimizing a proposal for ES7 or ES8 (2016 or 2017), while StrongScript is in pole position. This is much more like how standards evolution should work than the silly Dash memo's model.
If you're right, and can land optional types and bignums soon, then Dart's semantics can become a subset of ECMAScript. At this point it's pretty easy to replace the Dart language in the VM to support the ECMAScript syntax subset, and source code translate the core libraries over to ECMAScript. Then you have a fast VM which supports an easily optimisable subset of ECMAscript, and a large class library. This still seems like a good outcome to me.
"any real-world usage data from it are nowhere"
Ignoring available data from existing optionally typed VMs during the standardisation process doesn't seem like a smart idea.
Anyway, I hope there is good discussion at TC39 about Nominal typing with implicit interfaces, vs Structural typing. I'm not really a fan of structural typing - I think the Dart team made the right call here.
> Alan Kay was right, the best way to predict is to invent.
You mean to invent something compatible with legacy technology and easily adopted ;)
> If you're right, and can land optional types and bignums soon,
First, "soon" is incremental and staged, so it's not as though full optional types won't take till 2020 to be "landed" as in standardized and widely implemented.
Second, the only way to get to that 2020 is by working in TC39 now, 2015, as SoundScript is. Not pulling a Dart in 2010, doing a different language and VM, making a disjoint Ecma standard, and then hoping to pull off a last minute rendezvous.
> then Dart's semantics can become a subset of ECMAScript.
They cannot, without incompatible changes. This doesn't fit your "big investment now for great tooling, easy migration later" thinking for Dart, and it's right out for JS.
Problems go beyond bignums, but just bignums are enough. Dart can start a counter at 0 and ++ it past 2^53 without loss of precision. JS can't (you'd have to use bignum(0) or 0n). Something's got to give, and it looks likely to be infeasible to statically analyze and auto-fix all the code.
> At this point it's pretty easy to replace the Dart language in the VM to support the ECMAScript syntax subset, and source code translate the core libraries over to ECMAScript. Then you have a fast VM which supports an easily optimisable subset of ECMAscript, and a large class library. This still seems like a good outcome to me.
Except that this won't happen in 2020 thanks to Dart, because it forked hard early. Instead we will get to 2020 (maybe 2018) with SoundScript standardized, still incompatible with Dart, and no good outcome for Dart users who can't get dart2js to perform as well as DartVM. But in this scenario there's likely little market pressure on browsers to do the crazy amount of work to support multiple VMs. Good outcome?
Worse, this is a narrow, self-interested point of view from Dart side. What about the JS side? Why should we have waited five years at least to get to SoundScript? How much sooner from 2010 or even 2015 could we get to the promised land if Dart weren't flying off toward Pluto?
> "any real-world usage data from it are nowhere"
> Ignoring available data from existing optionally typed VMs during the standardisation process doesn't seem like a smart idea.
Cut the bad-faith arguing, please. It's not up to me to find Dart's "data" (where is it available, pray tell?) and try to separate all the confounding variables arising from Dart being a different VM and language.
Sound/StrongScript in V8, OTOH, will give unconfounded data this year, in the context of JS and TC39.
Who are you gonna bet on? Anyway, leave me out of it, try begging some Dart staffer for "data".
> Anyway, I hope there is good discussion at TC39 about Nominal typing with implicit interfaces, vs Structural typing. I'm not really a fan of structural typing - I think the Dart team made the right call here.
Ah. Interfaces are structural. Didn't notice that first time through. Thanks for the pointer.
JS cannot be replaced in the short term. However you can implement a VM (or mode) which supports only a subset of JS with some of the legacy cruft removed. Strongscript is a step in this direction. (Side note - deprecate a few more features and you can start reusing some of the optimisations in the Dart VM.)
It is also possible to treat JS source as an AST serialization format an to display code differently when viewed by the developer. When language semantics are close to 1:1 this can work seamlessly (unlike of the big unintelligible balls of source required to work around ES5 semantic gaps).
And who knows, give it 10 years, and perhaps TC39 members will agree on a new language syntax that fits the existing "use strong" semantics. Note there is no need for expensive new VMs in this scenario, it is just a new parser generating AST nodes in the existing VM. This seems pretty obvious, I mean it's a bit of cruel joke to make developers use === for the next few decades. Surely this can be fixed some day.
Forgive my naivety about TC39 and standards, but I would have thought when standardising a new language feature that it makes sense to review similar features in other languages, and to perhaps reach out to implementers, for a presentation, or at least some email discussion. Seems prudent to learn from other's mistakes.
Btw. It is trivial to statically analyse Dart code, and even ignoring type annotations, decide whether a number literal is an integer or a double. And yes such automatic translation wouldn't be possible until changes like strongscript and bignums have landed in ES. But perhaps I misunderstand your point.
Nope, your "Ignoring available data" weasel words, implying negligence by me or TC39 for not carrying Dart's water, were below-the-belt.
No one is "ignoring available data". Dart's type system, in particular its covariant subtyping unsoundness, outraged Andreas Rossberg of the new V8 team. He expressed himself plainly about this on LtU the other year:
Andreas and many others among us TC39ers are well acquainted with Dart. I think this intra-Google, anti-Dart outrage motivated SoundScript, in part.
That doesn't mean the "data" is out there on some Dart public wiki to inform SoundScript's design in ways that programming language research and development do not already sufficiently inform it -- that we should just go get it, or we're slackers. I think you know this.
Yes, all dynamic language VMs will look more alike in 10+ years. StrongScript or a closely related descendent of it in 5 still beats Dart, and I'm still right that this took too long by 5 years at least, precisely because of the bad politics and JS-can't-be-fixed-but-it-can-be-replaced fallacies of the Dash memo that pre-forked and diverged Dart too much, without JS uplift apart from SIMD.
Are you done defending this sideshow as a productive experiment that helps the Web? Because so far, apart from John McCutchan's work, it has not helped. Maybe it will emerge a dark horse winner, but odds are against.
I apologise for the "weasel words". But to be fair they were in response to this relatively dismissive comment:
"Dart and any real-world usage data from it are nowhere, while StrongScript is "on" and should generate V8-based data this year."
I'm watching with interest to see how Soundscript turns out. In the meantime, Dart and its tooling has helped me be productive. And I hope you and your colleagues at TC39 are able to bring the same feeling of productivity to ES.
I'm not hugely excited about the casts required in Typescript (and I assume Soundscript) when interacting with the DOM. For example as a developer I don't find it helpful that the following is a static warning:
var input : HtmlInputElement = document.querySelector('input');
A cast fixes the warning, but is pretty verbose and ugly:
var input : HtmlInputElement = <HtmlInputElement> document.querySelector('input');
I believe this was one of the motivations behind the implicit downcasts in Dart. But I will give Soundscript a shot, and see if a sound type system helps me catch more bugs and be productive.
I also wonder how much complexity variance will bring to generics in Soundscript. I believe they are invariant in the initial doc that I saw.
Thanks for taking the time to share your views - I do honestly appreciate it. And I am very grateful that you got first class functions into JS1 - so that we've all had an ok language since the start. Definitely not accusing you of being a slacker.
> I'm still right that this took too long by 5 years at least
I think you overstate your case. But I've used enough of your valuable time already.
It also sounds like you're now happy with the outcome, the Aarhus leadership sidelined, and new people on V8 with views more similar to your own. Go for it - get optional types shipped!
We're overindented -- thanks for this comment, anyway.
I'm not happy with anyone "sidelined", including Aarhus people, even if self-sidelined by too much funding, loathing of JS, and desire to work from a cleaner slate. This was far from optimal or necessary, even if you dig the tooling. Many Googlers agree with me.
A Google friend with Polish-American accent pronounces "the DOM" as "the Dumb", and I agree. Don't fret about usability of future DOM APIs in an evolution of SoundScript. I'm 100% sure they can be as sweet as Dart's Dumb, er, DOM. :-)
Isn't this problem inherent in the Soundscript type system, rather than a problem of the DOM? For example:
class Node { ... }
class FancyNode extends Node { ... }
function createNode() : Node => new FancyNode();
function doStuff(Node n) { ... }
doStuff(createNode()); // Static error - developer scratches his head - how do I fix this
doStuff(<FancyNode>createNode()); // There I fixed it. But at what cost to productivity.
Or perhaps (Not sure how Any<T> works - just guessing):
function doStuff2(Any<Node> n) { ... } // Developer - hey what's this Any<T> thing? More head scratching.
Is the extra complexity worth it, what benefits does it bring, and what are the productivity costs? Will soundness actually help runtime performance (Not proven). Will it make security harder? i.e. performance optimisations that rely on the sound type system mean that type spoofing can lead to vulnerabilities.
I keep on rambling - sorry - I find this stuff fascinating. Fun job you've got ;)
There's no type error in what you wrote, with or without the cast. But we're way over-indented now. Suggest trying ed-discuss for direct convo with Andreas R.
1) Large interdependent libraries that try to "fix" the DOM (and provide widgets, MVW, etc.
2) The common practice of loading scripts over external domains. This compromises privacy & security and is possible because of the same-origin policy.
The DOM is not idiot-proof. But the way that they are using it causes undue problems.
Bignums - ok - you claim that bignums could have made it into ES6 if google had provided more support. I'll take your word for it, but you can probably understand my scepticism.
I'm not religious about language either. I don't care much about syntax. What I really care about is being productive.
IMHO the main things that help my productivity are:
* optional types
* completion
* doc popups
* development-time runtime type checking
* good debugger
* Few implicit conversions
* Consistent core library
Now you argue that google would have been better off building these language features and tooling on top of ECMAScript instead of creating the Dart stack. What would this alternative scenario actually look like - especially from the point of view of a developer?
* It could be a mode in V8, or a fork of V8 (I'll call it "V8FutureMode"). V8FutureMode would be incompatible with other vendors JS VMs. Just as Dart is.
* Each time ES standardises a new feature already in implemented in V8FutureMode, then all your existing code would need to be updated to match the ES spec. This regular churn is painful for developers.
Now let's consider another scenario where google develops Dart, and ES20 arrives in 2020 with optional typing.
* 2013-2020. Stable language no breaking changes.
* In 2020 I can port my code over to ES20 (trivial as near 1:1 semantics, 99% automated).
This scenario is better for me as a developer. It also insulates me from the risk that optional types don't make it into ES until 2030. I also think it gives a lot of real world usage data helpful for getting optional types into ES. (You seem to disagree here.)
From the Dart team's perspective the Dart scenario is better too:
* Can build a core library and tools on a stable language, rather than having to regularly deal with breaking changes.
* Able to experiment with VM optimisations which are difficult to do in JS due to legacy compat.
* Personal motivation - this is what the developers really want to work on. (Being told by your boss to drop your experimental project, and continue doing the same old thing isn't always a good management approach)
I'm optimistic that over time experiments such as "use strong" will mean that the same optimisations implemented in the Dart VM will be able to be used in other JS VM's. Perhaps if a developer guarantees that all JS code is "use strong ES20", then it would be possible for a browser to even use a different VM behind the scenes (in Chrome perhaps even using the original Dart VM codebase, but with the language front-end changed to compatible with ES20).
The future is uncertain and difficult to predict. There are multiple ways to evolve JS - you seem quite certain that incrementally fixing JS is the only approach. I think building a new programming stack, and simultaneously evolving JS in that direction with insights learnt from the new stack, is also a valid approach. I don't understand why you have been so hostile towards this.