(Dart’s release: Google says Dart 1.0 is ready for wide Web use)
Why Google created Dart
Dart was designed to make it easy to write modern app-development tools capable of high-performance implementations. Formerly known as Dash, Dart is a class-based, object-oriented language with C-style syntax that also comes with a programming environment, a set of libraries and a virtual machine.
According to Google software engineer and Dart co-creator Lars Bak, the Dart project started two and a half years ago with two distinct goals: increased programmer productivity, and faster execution. And he believes Dart has achieved them.
“There’s a very fast turnaround cycle from when you change the source code until when you run the code,” Bak said. “In our case, if you use the VM, we changed the source code to program right away. If you’re used to Java or another programming language where you have to go through tools before you can run the program, in Dart you can run them right away.”
Lowering that source code runtime threshold leaves Dart free of what Bak called defensive programming. He explained that when dealing with a long tool chain, developers often fall into the habit of playing it safe. They spend an inordinate amount of time examining the code before compiling and running the program, instead of having the freedom to experiment with code.
“When you start experimenting with a program, you can write code without types, and if you get closer to finalizing a module, you can put in types in the interface,” Bak explained. “So if our team members are using your interface, you can actually validate your code against that interface. So you can be experimental in the language but also harden it up and use types as a way of ensuring that people are only using the code in a certain way.”
Inside the Dart SDK and IDEs
Dart 1.0 carries a host of SDK tools, IDEs and VMs, each bringing its own Web development features and capabilities to the table. Bak delved into a few of the most important ones for programmers:
• dartanalyzer: A static analyzer that verifies whether static type information in the program is correct. “This is something that’s a bit different from most other systems; even though you get warnings in the static analyzer, you can still run the program,” Bak said. “When we run Dart, we don’t use the static type information for anything other than helping the programmer see where there are problems in their code.”
• Dart standalone VM: A virtual machine with a built-in dynamic compiler that generates code for both 32- and 64-bit CPU architectures to better support server-side execution of Dart. “We would like to expand the VM so that people doing Web applications can also have [front-end] and server code written in Dart,” Bak said. “Then you can have the same modules being used on the client-side but also on the server-side.”
• Spark IDE: A Chrome-based online IDE and toolkit, still in its very early stages. “Imagine you’re sitting with your Chrome OS machine and want to start development right in the browser,” Bak said. “Having a Web-based IDE is certainly very exciting, but again we’re just taking the first baby steps in that area.”
The history of ECMAScript
“Google is an active participant in TC39,” Wirfs-Brock said. “Within TC39, our job is the evolution of ECMAScript. However we got there—and sometimes what causes a technology to become a dominant or core technology is a set of coincidences—but ECMAScript is the language based into every browser. We see ourselves as stewards of that technology doing the job that needs to be done.”
TC39 is now in the latter stages of the next edition, ECMAScript 6, which is the first major enhancement to the language since 1999. The feature set is complete, and throughout the majority of 2014 the specification will be reviewed, validated, tested and implemented, with a target date of December 2014.
The chief goal of ECMAScript 6 is bringing that speed and performance to the creation of the larger applications becoming more and more prevalent on the Web. Wirfs-Brock said this comes down to making the programmer’s life easier, and ECMAScript 6 uses a number of syntactic enhancements to make the language more concise to express it in fewer lines of code.
“Modularizing a large program into independent pieces where you explicitly identify how the pieces interact creates a building block-style approach,” Wirfs-Brock said. “Rather than deal with a single program of 100,000 lines, you would deal with 20 modules of 5,000 lines.”
In place of changing the program while it runs, Dart uses tree shaking, a pre-deployment step that eliminates unused classes and methods to reduce download times and improve startup times.
“We can do static analysis of the program, and throughout the code we can prove that’s not being used, and then only emit that to the deployed version of the program,” Bak said. “When you write your program, you can include all your libraries in the program you want, and you’re not penalized for a big library if you don’t use all of it.”
Rewriting the rules of Web development
In the next year, Dart’s formal specification will likely be ratified by Ecma, and in the short term the Dart team is working to fix bugs and keep the library stable to ensure backward compatibility. Other goals for the year include improvements to the VM, changes to the dart2js translator to make it faster and smaller, and improving the tool chain for better debugging and deployment support from within the IDE.
“If you look over the last four years on the Web, you’ll see that Web applications have been using more and more libraries,” Bak said. “In fact, applications are just getting bigger and bigger. I think a language like Dart that has more structured access to help take that to the next level in terms of complexity. There’s no way around it, you’ll see more and more logic, code running in the browser.”
Despite that uphill battle for wider use and mainstream browser adoption, Dart’s development is guided by an open-source philosophy, which has driven community engagement with the platform from the inception of the language.
Goals such as extracting and wide-releasing services from within the Eclipse IDE give developers license to use Dart any way they want, resulting in plug-ins like the JetBrains IDE, as well as early deployments in places like Mixbook, a scrapbooking software company. Bak believes if you simply give programmers the freedom of access, they’ll take the innovation from there.
“Back when I was working on V8, we came out with the beta version of Chrome,” Bak said. “That kind of performance boost in the platform gets programmers doing really creative and crazy things. They’ll start experimenting with more code in the client, and I think we can get that same boost with Dart, taking it to the next level. So I really hope we rewrite the way you can create programs for the Web.”