Skip to main content

Posts

Showing posts from September, 2012

New site for Dart news and articles

For the latest Dart news, visit our new blog at  https://medium.com/dartlang .

Breaking Change: Hashable interface is removed

Lasse Nielson writes to the Dart mailing list : Now that we have implemented hashCode on Object, we no longer need the  Hashable interface for anything. We have removed all references to Hashable in the SDK classes[1], and  will be removing the Hashable interface itself later - no earlier than in two weeks, but at some later point  it will be removed without further warning. The Hashable interface is still there, so classes that implement  Hashable won't break immediately. Code that *tests* whether an object is Hashable will probably begin  failing immediately! For example String is no longer Hashable. Two Dart M1 language changes converged to make this breaking change possible. First, explicit interfaces have been removed . Dart classes expose an implicit interface, so no need for explicit interface declarations. Second, Object now implements hashCode , so all objects explicitly are hashable. As always, you can join the discussion at that Dart mailing list , or ask question

Breaking Change: Raw string syntax

Matthias Hausner wrote to the Dart mailing list about an upcoming break change. Matthias writes: Tomorrow Thursday 9/27 we will eliminate support for the old raw string syntax that uses the @ prefix. The new syntax requires an r instead of the @ in front of the raw string literal. @"..."  ->  r"..." @'...' -> r'...' @"""..."""  ->  r"""...""" @'''...'''  ->  r'''...''' The Dart Editor (build 12784) can perform this change automatically. Time to update your code!

Use JavaScript code in your Dart apps

You can now use existing JavaScript code with Dart! We've recently released a JavaScript-Dart interop library , one of our developers' most requested features. This is a big milestone for the Dart project. Using this library, you can proxy JavaScript objects inside Dart code. You can also reach Dart functions from JavaScript code. Here's an example of wrapping a Google Maps API object: var canvas = query ( '#map_canvas' ); var googlemaps = js . context . google . maps ; var googlemap = new js . Proxy ( googlemaps . Map , canvas ); This code instantiates a JavaScript google.maps.Map object onto the given canvas and returns a proxy to Dart. Note that googlemaps.Map is a proxy to the JavaScript constructor. The resulting googlemap is a proxy to the actual Google Map object in JavaScript. Here's an example of calling a Dart function from JavaScript: js . context . handler = new js . Callback . once ( display ); var script = new

Dart + HTML5 = Happy Web Developers

If you’ve been using HTML5 for a while, you’ve probably seen HTML5 Rocks . However, it’s not always clear how to translate these samples into Dart. To fix this, we’ve started a new project called dart-html5-samples , where we’ve started porting the HTML5 Rocks samples. We’ve already ported a bunch of tutorials such as: Reading Files in JavaScript Using the File APIs Native HTML5 Drag and Drop Exploring the Filesystem APIs HTML5 Video Getting Started with Web Audio API Introducing WebSockets: Bringing Sockets to the Web Using the Notifications API A Simple TODO list using HTML5 IndexedDB Leaner, Meaner, Faster Animations with requestAnimationFrame Along the way, we’ve occasionally encountered bugs in Dart. By filing these bugs on dartbug.com , we’ve not only been transparent about the process, but we've given the community a chance to vote for the features they find important. Although we’ve ported a lot of samples, many more remain. If you’d like to help out, thi

Pub support in Editor

A new Dart Editor build is  available at  www.dartlang.org/editor . Changes include: Pub support in now on in the integration build! Features include: analysis support for the packages directories a pubspec.yaml editor, with syntax highlighting and other goodies our new app wizard can optionally create your app in a pub friendly format, including a sample pubspec.yaml file the 'pub install' and 'pub update' tools are available from the Tools menu the open folder dialog will run 'pub install' automatically if there is a pubspec.yaml In addition: The Eclipse plugins distro is now compatible with Eclipse 4.2. We now support using @override and @deprecated metadata from package:meta/meta.dart. See this  CL  for an example. Our syntax and semantic highlighting has been dialed back a bit. Added a clean up to migrate raw strings from @'str' to r'str'. Added a clean up to migrate parseInt() and parseDouble() references to

3 Dart events at GOTO Conference

Next week, Dart is going to be at the  GOTO Conference  in Aarhus, Denmark!  We have three Dart events this year. Dart User Group and Code Lab After an introduction to the language, we'll guide you through all the steps to create your first Dart application. The code lab was battle tested in June during Google I/O, and is ready to go. We'll lead you through the process of building a modern web app with the Dart platform, using both client-side and server-side Dart. You will explore the language, libraries, editor, and integration with Chromium. You'll leave this session with a working Dart app that works in modern browsers. Register now! Translating Dart to efficient JavaScript To make Dart run in all modern browsers, we have implemented an optimizing Dart-to-JavaScript compiler. Performance-wise the biggest challenge is the gap between the semantics of Dart's low-level operators and JavaScript's builtin primitives. This presentation will introduce

Dart Language meeting notes from Sept 17

Bob Nystrom posted the latest Dart language meeting notes to the mailing list . Bob writes: Here's my notes from this weeks meeting: 0.11 language spec I asked when we'd be publishing the next version of the language spec. Gilad says "real soon now". We keep making changes so we don't want to publish just to immediately invalidate something a few days later. scope of type parameters Gilad brought up what happens if you try to access a type parameter within a static method: class Foo<T> {   static bar() => T; // <- What does this mean? } Currently they are just not in scope, which means it could refer to some other outer name. Instead, maybe we should say they are in scope, but you can't use them, which is consistent with other names inside a class. Kasper says there one's scope. It doesn't matter whether you are on the instance or static side. You'll just get an error if you try to refer to some

Dart helps you build Web Components today

Watch this episode of Dartisans and learn more about using Dart with Web Components . Even though Web Components aren't yet baked into the platform, you can use Dart to build Web Components today and compile them down into code that works in modern browsers. You can follow along with the open-source dart-web-components work on Github . With Dart, you can build structured web apps. With Web Components, you can build encapsulated, declarative components. Two great ideas that go together!

Dart Team Updates, Sep 5 - 18, 2012

Summary Dart is getting closer to reaching Milestone 1. We have been doing a lot of M1 bug-fixing across sub components. There is now a Dart web components sample available. We have a new pub package layout and the editor now comes with the possibility to auto-update. Details Dart Editor: Lots of SDK changes: dart:dom was removed and several libraries moved from dart-sdk/lib to dart-sdk/pkg. Run the Dartdoc tool from the Editor - see Tools > Generate Dartdoc. Code completion now supports the method cascades syntax (foo..and()..another()..thing()). New clean up to convert old optional parameters to the new optional named ones where possible. New refactoring to convert optional positional parameters to named. New "Convert Method to Getter" refactoring. Rename refactoring improvements - if there are potential references to a field or method, we will warn the user and display a preview dialog. New Quick Fix to create a library import for unresolved functions and fi

Breaking Change: parseInt to become int.parse

Yesterday, Lasse Nielsen, an engineer on the Dart team, wrote to the Dart mailing list about a new breaking change coming to the Dart core libraries. The parseInt and parseDouble from dart:math will be replaced by int.parse and double.parse, respectively. Lasse writes: Greetings all. We are removing parseInt and parseDouble from the dart:math library, and making them static methods called "parse" on the int and double classes. The original reason, from long ago, for putting them in Math was that int and double were interfaces, and couldn't contain static methods. Now that we are converting all interfaces to abstract classes, we will move those functions where they belong. The dart:math parseInt/parseDouble functions will still work, but they will be removed in about a week. The functions now have documentation too! Please do report if it is confusing or misleading in any way. Cheers /L A good discussion then followed with suggestions for creating

Dart Editor gets auto-update!

A new Dart Editor build is  available at  www.dartlang.org/editor . Changes include: The last Editor you'll ever download! We now support auto-updating the editor. This was one of our most starred  issues . To try it out, open the Preferences dialog and enable auto-updating. Additional release notes: You can now run the Dartdoc tool from the Editor - see Tools > Generate Dartdoc. There's a new clean up to convert old optional parameters to the new optional named ones where possible. There's a new refactoring to convert optional positional parameters to named. The Files view now displays whether a dart: library is client only (like dart:html) or server only (like dart:io). Added a preference to enable code folding. Several performance improvements for large projects. Fix for missing keystrokes in the searchbox (on GTK Linux). Fix for a crash related to the break-on-exceptions feature, and for a crash that could occurred when launching Dartium wi

Simplify your constructors and top-level variables

The Dart mailing list was treated to some very good news today. Kasper Lund informed us that lazy init of statics and top-level variables is ready for use! Kasper writes: We now have one of the major new language features of M1 implemented across the board. That's right -- you can now use lazy initialization for top-level and static variables (both final and non-final). This means that the restriction that used to force the initialization expression for such a variable to be a compile-time constant is no more. You can now write: // Top-level. final worklist = new Queue(); var compiler = new Compiler(worklist); main() {   compiler.compile(); } and both worklist and compiler will be initialized on first access. We've also lifted the restriction for instance fields so the following code now runs just fine: class Cache {   final Map table = new Map();   Logger log = new Logger();   ... } as long as the initialization expressions do not refer

Breaking change: Remove '.dynamic' from Object

Today, Dart engineer Lasse Nielsen informed the mailing list that Dynamic will be renamed to dynamic . He writes: We will be renaming the "Dynamic" type to "dynamic", and as the first step we will remove 'dynamic' as a getter on Object in a few days.  Code that uses "x.dynamic" can be rewritten to use the equivalent "(x as Dynamic)".  As you might know, dynamic (as it is now called) is the stand-in type when a static type annotation is not provided. I asked Lasse for some background on this change. He continued: "One positive thing is that all built-in identifiers and keywords are now all lower-case. It's a special type, like 'void', and not a class, so consistency might also be a point." As always, we invite you to join the discussion on the Dart mailing list , and ask questions at Stack Overflow .

BREAKING CHANGES: Duration, RegExp, Uri.fromComponents

Kasper Lund has been making good use of the new named optional parameters syntax , a new Dart M1 language feature. He writes to the mailing list : Over the last few days, I've changed the constructors for Duration, RegExp, and Uri.fromComponents to insist on getting their optional parameters passed by name. This is possible using the new named optional parameter syntax where the formal parameters are enclosed in { }:   class RegExp ... {     const RegExp(String pattern, {bool multiLine, bool ignoreCase});   } It isn't possible to pass these optional parameters positionally anymore; you have to pass them by name or leave them out:   const RegExp("foo")   const RegExp("foo", multiLine: true)   const RegExp("foo", ignoreCase: false)   const RegExp("foo", multiLine: true, ignoreCase: false) The following constructor invocation that used to be legal are now illegal:   const RegExp("foo", true)   const RegExp("foo", true,

New pub package layout

Today, Bob Nystrom, one of the pub engineers, posted details about the new pub package layout . Time to use the new layout for your packages! Bob writes: If you live on bleeding_edge, pub now supports the new package layout conventions that avoid the nasty circular symlinks. Pub also still supports the old style too, simultaneously. It works like this: When pub is generating a symlink to a package it determines if it's an old style or new style package. The presence of a .dart file at the top level (aside from build.dart) indicates that it's an old style package. If it's an old style package, pub symlinks to the package's root directory. If it's a new style package, it looks for a "lib" directory inside that package and symlinks to that. It will also generate a self link, but  only  for new style packages. So, if you have: myapp/   pubspec.yaml -> depends on old_style and new_style   lib/     app.dart old_style/   ol

Change final to const for top-level and static variables now

Kasper Lund , engineer on the Dart project, sent a notice of a new breaking change to the Dart mailing list today. Kasper writes: TL;DR: Change final to const for top-level and static variables now. Over the next days, we will stop treating references to top-level or static final variables as compile time constant expressions. This means that the following code will be illegal:    final X = 42;    final Y = const [ X ]; because you can only build constant lists out of compile time constants. The fix is easy. Just replace final with const and you'll be good to go (this works today):    const X = 42;    const Y = const [ X ]; The nice thing is that this paves the way for lazy static initialization which allow you to initialize top-level and static (final) variables with non-constant expressions like this:    final Z = new Set<int>(); Note that this isn't supported across all our platforms just yet. As always, you can join the discussion at the

Learn About Compiling Dart to JavaScript

Dart runs across the modern web, thanks to our Dart to JavaScript compiler. We recently sat down with some engineers from the dart2js project. Enjoy the video! Don't forget to watch our past episodes of Dartisans !

Negate() changes to -() soon

Today, Kasper Lund gave dartisans a head's up about an upcoming breaking change.  Kasper writes: We're getting rid of operator negate in favor of the unary operator -.  If you have code like this:     operator negate() => ...  now would be a great time to change that to:     operator -() => ...  I expect that we will turn off the support for negate within a few days. Why make this change? We didn't want developers to see negate() and think they can actually call object.negate(). We hope -() makes it more obvious. As always, you can join the discussion at the Dart mailing list or ask questions on Stack Overflow . Thanks for trying Dart!

Editor can now convert methods to getters

A new Dart Editor build is available at  www.dartlang.org/editor . Changes include: Lots of SDK changes: dart:dom was removed and several libraries moved from dart-sdk/lib to dart-sdk/pkg. During a rename refactoring, if there are potential references to a field or method, we will warn the user and display a preview dialog. Using the old catch syntax is now an error. We have a new "Convert Method to Getter" refactoring. We no longer report 'no such method' warnings if class defines 'noSuchMethod()'. We added a Quick Fix to create a library import for unresolved functions and fields. The warnings we create for inferred types are now displayed differently from other errors. You can view them by hitting the 'show informational messages' button in the Problems view. Fixed an issue where our search box would not consistently show SDK types. Several miscellaneous debugger UX improvements, and 11 analysis issues fixed. As always, view

Dart Language Nears M1 State

Posted by Seth Ladd Dart Team Updates - August 18-Sept 4th Learn more at  http://dartlang.org Summary The language spec is nearing its M1 state, the core libraries have been unified, the VM and dart2js implement more M1 features, and the editor improves on static analysis, refactorings, and quick fixes. Details Dart language specification: 0.11 spec nearing completion: all M1 features covered. Dart libraries [core, unittest, i18n, etc]: The core and coreimpl libraries have been unified across dart2js and the VM. There are still implementation-dependent sources, but there is only one corelib and the SDK only contains implementation-independent files. Dart VM: New compiler: Deoptimization support, class hierarchy analysis, unboxing of doubles in select instructions, smi and class check elimination, stackmaps for live registers and simple inlining. Language features: Argument definition test (aka '?' prefix operator), abstract class handling, disabled legacy try-