Chrome programmer Lars Bak speaking at Google I/O 2013
Minecraft is one of the most widely used games around these days. So it was notable when the programmer who wrote it, Markus "Notch" Persson, embraced Google's Dart programming language for Web apps.
"I love it," Persson tweeted in November, shortly after Google released Dart 1.0.
That's music to the ears of Google developers who created Dart to rewrite the rules of Web programming and, as they see it, to overcome shortcomings of the JavaScript language at the foundation of Web apps today. To fully succeed, though, Google will have to persuade a lot of skeptics to see things the way Notch does.
Google believes Dart speeds up both developers and the programs they write, but skeptics worry that it fragments Web programming and undermines the industry's focus on better JavaScript. So far, it's been a largely academic debate, but that will change in coming months.
That's because Google right now is building Dart technology directly into Chrome.
"The next step for us is to get the Dart virtual machine into Chrome," said Lars Bak, the leader of Google's project, adding that he hopes it'll be done within a year. "If everything pans out the way it's predicted, with a factor of two performance boost and a factor of ten in startup-time boost, I'm pretty sure the other browsers will be enticed with what we're doing."
Bak is "pretty sure," but Mozilla, Apple, and Microsoft -- which make the other three of the top four browsers in use today -- don't care for Dart. When Google ships a Dart-enabled Chrome, the debate over the language will transform from dueling blog posts to live code on the Web that affects the public.
Dart on the Web
There are two ways Dart can make its way to the Web. Today, it can get there only with Google software called dart2js that converts a programmer's Dart software into JavaScript that any browser can run. That's not controversial, and indeed many languages including CoffeeScript, Red Hat's Ceylon, and Microsoft's TypeScript take that approach.
There are two ways Dart can make its way to the Web. Today, it can get there only with Google software called dart2js that converts a programmer's Dart software into JavaScript that any browser can run. That's not controversial, and indeed many languages including CoffeeScript, Red Hat's Ceylon, and Microsoft's TypeScript take that approach.
Second -- and this is the project the Dart team is working on now -- is building the Dart virtual machine (VM) into a browser. A virtual machine is a software layer that acts like self-contained computer on its own, running instructions in its own particular language.
So far Dart programs only work directly in an experimental Chrome build called Dartium, but building the Dart VM into Chrome would mean native Dart programs would have a place on the Web. That's the phase that Dart fans such as Mixbook are eager to see.
That same step worries some other developers who've seen past problems when the Web was fragmented with software platforms that worked in one browser but not another.
"What I find worrying is [Google's] tendency to push for in-house, works-only-on-Chrome solutions instead of trying to work with the wider web standards community," said Henri Bergius, founder of the NoFlo project and co-creator of FlowHub. In this they strongly resemble Microsoft of the bad old IE market dominance and ActiveX era."
Dart has some big differences compared to ActiveX, though. For one thing, it's open-source software, which means anyone can adopt it for free and that Google is, at least in principle, open to outside contributions. And last week, Google convinced the Ecma standards group to tackle Dart, an effort that could more formally ensure that others get a say in Dart.
Dart's Dash debut
One advantage of JavaScript is an informality that encourages a seat-of-the-pants programming style -- you can write and go without too much advance planning. But that informality can become a drawback for big programming projects -- and sophisticated Web apps have hundreds of thousands of lines of code. Dart is geared for larger-scale projects where informality can cause problems.
One advantage of JavaScript is an informality that encourages a seat-of-the-pants programming style -- you can write and go without too much advance planning. But that informality can become a drawback for big programming projects -- and sophisticated Web apps have hundreds of thousands of lines of code. Dart is geared for larger-scale projects where informality can cause problems.
For example, it's got optional "typing," which essentially means that when one part of a program calls upon another, the programmer must lay out what kind of data it sends out and what kinds it expects back. That's the kind of thing that lets programming tools do a better job finding bugs early, and it's something that could make Web-app programming easier for developers coming in from native-app languages like C++ and Java.
Google released Dart in testing form two years ago. Before it was publicly announced and was still called Dash, though, Dart got off to an inauspicious start by antagonizing JavaScript fans with us-vs.-them wording: "The goal of the Dash effort is ultimately to replace JavaScript as the lingua franca of Web development on the open Web platform," an early memo about it said.
Brendan Eich, Mozilla's chief technology officer and the founder of JavaScript, said the B2G browser-based mobile OS has less software overhead than iOS and Android and therefore can use lower-cost hardware. He spoke at Mobile World Congress.
That raised hackles.
"Things that start out revolutionary and with a 'replace' agenda have failed repeatedly on the Web," said JavaScript founder and Mozilla Chief Technology Officer Brendan Eich.
Google doesn't really intend to replace JavaScript -- indeed, such a feat would be impossible given how many sites rely on it -- but more to compete alongside JavaScript. A victory for Dart would mean a gradual shift toward Dart, though, so that new Web sites employ it and programmers use dart2js to handle browsers that only can handle JavaScript.
JavaScript performance improvements have been impressive, but Bak thinks "it's harder and harder to get gains. I think if you really want to go to next level, like a factor of two, you have to go to a different technology," he said. Unlocking that performance will free programmers to tackle new classes of Web apps, he argued.
Dart resistance
Eich is skeptical of Google's performance claims and of the wisdom of adding a Dart virtual machine.
Eich is skeptical of Google's performance claims and of the wisdom of adding a Dart virtual machine.
"Most browsers have no reason to include Dart because doing so would not only be extremely difficult for engineers to accomplish in each major browser, it would also result in a quality hit," Eich said.
Specifically, he pointed to problems with having two separate virtual machines, both trying to clean up computer memory through a process called garbage collection and both trying to control Web page elements through the browser's Document Object Model (DOM) interface. "Two runtimes sharing the DOM adds both bug habitat and a performance tax," Eich said. That's an objection Apple has raised, too.
Luke Hoban, Microsoft's TypeScript product manager, believes that speeding up JavaScript will deliver limited returns.
"In practice, JavaScript performance is not the bottleneck in real-world performance," Hoban said. More often, it's things like pre-written libraries of JavaScript code and the interaction between JavaScript and the browser pages via the DOM, he said.
Dion Almaer, vice president of engineering for WalmartLabs Mobile, agrees. "I think the JavaScript engines are awesome," he said, adding that he'd like to see DOM improvements and better use of graphics-chip acceleration.
The practical difficulties of Dart, including the resistance of other browser makers, means that moving to Dart "feels like a big pill to swallow," Almaer said.
Microsoft's TypeScript approach
Microsoft, which in recent years has re-engaged with the Web standards world and rebuilt Internet Explorer into a much more competitive browser, agrees with Google that JavaScript programming has problems. "The difference is in the approaches to how we solve that. Our belief is that we can build on JavaScript and get it to where it can scale up to large-scale application development," Hoban said.
Microsoft, which in recent years has re-engaged with the Web standards world and rebuilt Internet Explorer into a much more competitive browser, agrees with Google that JavaScript programming has problems. "The difference is in the approaches to how we solve that. Our belief is that we can build on JavaScript and get it to where it can scale up to large-scale application development," Hoban said.
TypeScript is a superset of JavaScript: it'll run JavaScript software unchanged but adds techniques that ordinary JavaScript engines can't handle today. That means TypeScript can take advantage of "one of the most successful programming ecosystems over the last 10 years," Hoban said.
"The JavaScript ecosystem is one of the strongest ecosystems around. There's an enormous set of frameworks and libraries and tools. There are millions of programmers who know JavaScript and are comfortable working with it, and it's built into the browser itself," Hoban said. "If you can build on it, you get to leverage all that goodness."
Today, TypeScript also relies on a compiler that transforms the code into ordinary JavaScript. It doesn't guarantee a performance boost when that JavaScript runs, but when programmers use TypeScript's more industrial-strength approach, "that tends to be the same code that the JavaScript VMs are very good at optimizing," Hoban said.
TypeScript is nice, Bak said, but ultimately too limited. "We are trying to solve a bigger problem," fast program execution and fast program startup, he said. There's only so much that computing industry companies -- Google among them -- can do to improve JavaScript through the Ecma standards group.
"Whatever you do in a standards committee, it has to be backwards compatible always," Bak said. "There are things in JavaScript that are just real hard to make really fast."
Microsoft is committed, though. About a dozen people are on the TypeScript team, including Anders Hejlsberg, the chief designer of Microsoft's C# programming language, and Steve Lucco, the architect and lead engineer of the Chakra virtual machine at that Internet Explorer uses to execute JavaScript.
Microsoft is eating its own dogfood, as the expression goes: it's using TypeScript to power the Bing.com Web site; the Visual Studio Online programming tools, and the Xbox Music app on Windows 8.1, the Web, and the Xbox One game console.
Multilingual future
Bak is no JavaScript foe. He played a lead role developing V8, the engine in Chrome that executes JavaScript code and that helped push JavaScript performance industrywide to new heights.
Bak is no JavaScript foe. He played a lead role developing V8, the engine in Chrome that executes JavaScript code and that helped push JavaScript performance industrywide to new heights.
Now, though, he wants to see many languages flourish on the Web -- not just Dart and JavaScript, but something more like the panoply that you'll find elsewhere in the computing industry.
"I hope we get the Web platform to a point where there are different types of technology that can be used, so there is innovation going on," Bak said. "The more the merrier."