Monday, December 24, 2012

Dec 17 Language Design Meeting Notes: Configuration-Specific Code, Optional Named Params

Dart engineer Bob Nystrom has posted the notes from the December 17th language design meeting. He writes:

Here's my notes from this week's meeting. It was a short one since we were mostly focused on M2:

Configuration-specific code

There's been some discussion among the language designers about this, but I haven't seen the details.

Gilad says that libraries are parametric definitions. An import can define paramaters. The restriction is that these parameters have to be constants.

Optional named params

Lars says people are starting to nag him about a problem: sometimes with optional named parameters, you want to forward exactly what was passed. The language doesn't currently give you a way to do that without a combinatorial explosion.

He asked Gilad if he can cook up some syntax where you can optionally pass a parameter.

Cheers!

As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

Breaking Changes in dart:html: Window, LocalWindow & WindowBase, LocalHistory, LocalLocation


There are a number of name changes coming down the road in dart:html. Pete Blois gives us the details

FYI-
We'll be renaming Window to WindowBase and LocalWindow to Window. Ditto for LocalHistory and LocalLocation.

If you're curious, but not familiar it, there is both the global 'window' object, and IFrameElement.contentWindow. The contentWindow only exposes a subset of APIs while dart:html's 'window' exposes the full API. We used LocalWindow and Window to expose these two API sets, but LocalWindow was too undiscoverable. Hence, this change.

As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

Friday, December 21, 2012

A Game of Darts, Target 7: Defining a Custom DOM Tag Using Dart's Web UI Package and Web Components

The Game of Dart tutorials provide a gentle introduction to building web applications using the Dart language, tools, and APIs.  In the latest tutorial, learn how to make custom DOM elements using the <element> tag, use data binding to connect Dart variables to content, and attach event handlers in HTML using the Web UI package. 


As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

Wednesday, December 19, 2012

New Article by Gilad Bracha: Mixins in Dart

Mixins are a much talked about and anticipated feature of Dart and in a new article Google engineer Gilad Bracha gives us details of plans to incorporate mixins into Dart in M3. Read about basic concepts behind mixins, the syntax and the semantics of mixins in Dart, issues surrounding privacy and statics, the extensibility of current proposals and what changes all of this brings to the language spec :


As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

Tuesday, December 18, 2012

New Dart Editor Update for M2


Dart Editor keeps getting improved. A new M2 build is out and Eric Clayberg fills us in on the details:
A new Dart Editor build is available at www.dartlang.org/editor. Changes include:

    • General context menu cleanup
    • UI tweaks to the Class Hierarchy view
    • Improved logging for failed update checks
    • More analysis errors and warnings
    • Various analysis, editor and refactoring fixes
            Breaking Change List:
            And as always, view the changelog for the full list of changes, and to get started with the Editor see our tutorial. 

            We invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Publish Your Own Packages to Pub

            Pub, a package manager for Dart, is now accepting uploads of new and updated packages. Developers can self-publish their Dart libraries to pub.dartlang.org for other developers to use and enjoy.



            Bob Nystrom sends the good news:


            As Anders' announcement email said, with M2 out the door, you can now publish packages yourself to pub.dartlang.org. 
            You'll need a Google account that you can use to authenticate. In theory, it's as simple as going into your package directory and running: 
            $ pub publish 

            It will walk you through the one-time authentication process, validate your package, and then you're good to go! 
            We've tested this as thoroughly as we could, but our experience has been that users in the wild have a much greater variety of machine, operating system, software, and account configurations than we can hope to test for. 
            Please be patient if you run into issues. File bugs and we'll do our best to sort them out as quickly as we can. 
            Also, if you've filed a package upload request that we haven't gotten yet (likely because we are waiting on more information from you), please consider yourself empowered to handle that on your own now. You hold the keys to the castle!
             Get started with pub by downloading the Dart SDK or Dart Editor. We look forward to your feedback!

            New Article Detailing Dart Milestone 2 Changes


            The Dart team announced its Milestone 2 (M2) release today. Seth Ladd has a new article detailing the many changes and improvements that M2 brings. Find out about smaller dart2js output, improved libraries, SSL in the Dart VM, the Web UI library, direct publishing to pub, new http, oauth2 and serialization packages, and more:


            As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Dart Milestone 2 Brings Smaller JavaScript Output and Package Uploads to Pub

            Anders Sandholm gives us some of the details of the Milestone 2 (M2) release:

            We’re happy to announce the next milestone of the Dart project - M2. The bits for the editor and SDK are available at dartlang.org.

            A few features you may like in this release:

            • Significantly smaller generated JavaScript from dart2js due to tree-shaking of the html libraries and general minification.  Tree-shaking is on by default. Minification requires the command line flag --minify.  As a result, the generated code for swarm is now only half the size compared to M1.
            • Support for uploading of user packages to pub.

            The M3 release will focus on core library cleanup and the new streaming API for asynchronous communication.

            We’re looking forward to your feedback and thanks for your support.

            As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Monday, December 17, 2012

            Dec 10 Language Design Meeting Notes

            Dart engineer Bob Nystrom has posted the notes from the December 10th language design meeting. He writes:

            Mixins

            We're down to arguing about syntax. Lars says, OK, here it is:

                class C extends S with M1, M2 { ... }

            Mixins are linearized from right to left. This makes sense since the class body appears last but takes precedence, so we work backwards from that. Gilad has an updated proposal that he'll send out.

            There is one corner case. If you want to mixin, you have to have an explicit superclass:

                class C extends Object with M1 { ... }

            [Bob: This means that I believe we have the semantics and syntax for mixins nailed down now. Woo!]

            throw as expression

            They're looking to implement this in dart2js now. Even with the restriction on rethrows, it still feels tricky. Since throw takes an arbitrary expression on the right, including a conditional one, there are some corner cases related to how it binds.

            Lars: Is rethrow an expression?
            Gilad: It is in the spec, but the implementations don't support it.
            Kasper: It is hard to parse. We have to lookahead to tell if we're at the beginning of an expression.
            Lars: Let's make both kinds of throws an expression and rename rethrow to use a "rethrow" contextual keyword. It's a rarely used feature. Better?
            Gilad: I'll talk to the implementors and work through something.

            Metadata in corelib

            Brian: There is a faction that says certain metadata constructs need to be in the language spec before they can be put into the core library. Are all tools required to have certain behavior because certain metadata is in the core library? For example, does dart2js have to emit some kind of notification if you use @deprecated?

            Gilad: If we want metadata that does something magical then it should be in the spec. If it's just in tools, we shouldn't.

            [Bob: I think an example of an annotation with magic behavior is one that says "don't tree-shake this".]

            Kasper: If we use them in our libraries, we have to tell people what they mean. So it has to be specified somewhere, even if informally.

            Gilad: Sure, but that applies to the library API itself too. You have to document it.

            Lars: I would like to minimize the use of annotations in core library. We don't want using them to be part of normal style. Java uses them everywhere.

            Configuration-specific code

            Lars suggests we could have annotation to put on constants that lets you override its value from the outside from something like a command line argument.

            We'll discuss this more after M2.

            Cheers!

            As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Tuesday, December 11, 2012

            New Dart Web UI Codelab

            If you've been waiting for the right time to learn how to use Web Components in Dart, now's your chance! Continuing where we left off with the Google IO 2012 Dart Codelab, I've created a Dart Web UI Codelab which focuses on Web Components and the new Web UI library.

            In this codelab, I cover:

            • How to set up pub
            • How to use Web Components
            • How to use dynamic templates and two-way data binding (inspired by Model-driven Views)
            • How to build an application with multiple Web Components
            • Where to get more information about Web Components and the Dart Web UI package
            • What to do if you get stuck while trying to build an app using the Dart Web UI package

            We've already created videos, blog posts, and articles about how to use Web Components in Dart, but this codelab is pretty exciting in that it walks you through building a complete, albeit small, application using Web Components and the Dart Web UI library. So give it a try and tell us what you think!

            We invite you to join the Dart Web UI mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Dart Editors adds GUI for pubspec files



            Eric Clayberg
             fills us in on the details on the details on the new Dart Editor build:
            A new Dart Editor build is available at www.dartlang.org/editor. Changes include:
            • New forms based pubspec.yaml file editor! To see it, right click on a pubspec file and choose "Open with Pubspec Editor".
            • New Class Hierarchy view.
            • New Clean-up to add and remove local variables type annotations.
            • Launches in non-Dartium browsers are now faster (we only invoke dart2js if the source has changed).
            • If a build.dart script indicates to the Editor that it has remapped a file (foo.html ==> out/foo.html), and the user launches that file, we'll launch the generated file instead. For things like web_ui applications, this means fewer clicks for users and a simpler workflow.
            • Added a preference to control automatically running Pub.
            Breaking Change List:
            • dart:html changes
              • All dart:html class names have been updated to follow the Dart naming guidelines. For example CSSStyleDeclaration is now CssStyleDeclaration.
              • All indexed DB types (IDB*) have been moved to dart:indexed_db and had their prefix removed. For example, IDBTransaction is now Transaction (with the exception of IDBFactory which is IdbFactory).
              • DOMApplicationCache and DOMFileSystem are now ApplicationCache and FileSystem
            And as always, view the changelog for the full list of changes, and to get started with the Editor see our tutorial.
            As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Monday, December 10, 2012

            An Approach to Illiterate Programming: doc-code-merge

            It's very common to embed code examples in technical documentation. However, doing so is kind of painful. First of all, the environment you use to edit the documentation may not be the same as the environment you use to write code. For instance, I generally use Dart Editor to write Dart code, but I use Sublime Text 2 to edit documentation written in HTML or Markdown. Secondly, it's difficult to run unit tests or use dart_analyzer if the code is trapped in documentation. This is a big problem for us on the Dart project because we move pretty quickly, and we want to make sure our documentation is always 100% correct. I've created a tool called doc-code-merge to solve this problem.

            doc-code-merge is the opposite of what Donald Knuth labelled Literate Programming. doc-code-merge lets you write your documentation and your code examples completely separately. When you run doc_code_merge.dart, it makes a copy of your documentation with all the examples merged in. The Pragmatic Programmers mentioned using a similar tool when writing The Pragmatic Programmer: From Journeyman to Master, so the idea has probably been around for a while.
            Using doc-code-merge is easy. Start by writing some documentation such as:
            Then, write some code such as:
            Now, run doc_code_merge.dart:
            This results in:
            Easy peasy! doc-code-merge automatically handles things like indenting code blocks when generating Markdown and HTML escaping code when generating HTML.

            Although doc-code-merge is written in Dart, it'll work with almost any programming language and with almost any type of documentation as long as the documentation is written in text such as HTML or Markdown. We're hoping to make use of it for the Dart web site, dartlang.org, and for our book on Dart, Dart: Up and Running.

            If you're interested in using doc-code-merge, check out the README. As always, we invite you to join the Dart mailing list and ask questions on Stack Overflow.

            Dart VM improves performance by 50%

            The Dart VM is now 50% faster than Chrome’s JavaScript engine, V8, on the two Octane benchmarks, Richards and DeltaBlue.



            This info is available and being tracked on dartlang.org/performance/, which we’ve launched today. It is the new place for up-to-date information on Dart performance. We’re tracking and comparing performance of V8, the Dart VM, and the Dart to JavaScript compiler for every new revision, so you can now follow performance improvements as they are landing and help us keep an eye out for regressions.



            The benchmarks are run on a Linux ia32 architecture and follow the standard Dart benchmark harness. Over time, we'll add to the set of benchmarks being tracked. Of course, benchmarking is a subtle science, which is why we've published a short guide on benchmarking Dart.

            It's still early for Dart VM, but we're encouraged by the initial performance boost for web developers. If you are too, download the Dart SDK and get started today.
            We encourage you to send feedback using our mailing list.

            Written by Anders Johnsen, Speed Obsessed Software Engineer


            BREAKING CHANGE: Renaming web_components Package to web_ui


            The web_components package has a new name. John Messerly gives us the details

            We're renaming the web_components package to web_ui. Aside from saving everyone's wrists a bunch of keystrokes :), this new name was chosen to reflect the growing mission for the project. When we first started, we envisioned the project as a polyfill for the new HTML5 web components standard. But since then the effort has expanded to encompass a bunch of model-driven views (MDV) and template features, data watching, CSS polyfill work (just starting), and more. Web components is one of the shiniest new features, but there are other shiny features already there and more coming.

            We also have a new mailing list for the project! Please do sign up if you're interested in discussing how to build web apps on top of the exciting new standards.

            Send your web-ui thoughts to: web...@dartlang.org


            Here are the changes:

            pub package:
            rename this in your pubspec.yaml

            library name:
            -import 'web_components/web_components.dart';
            +import 'web_ui/web_ui.dart';

            github project:

            compiler (unchanged):
            bin/dwc.dart


            I’ve uploaded a final version of web_components, with @deprecated, that depends on and exports the new web_ui package. I hope the upgrade process is relatively painless -- but don't hesitate to reach out to us if you hit any problems.

            We’re still in the process of updating the documentation on dartlang.org. You can follow the progress at https://github.com/dart-lang/web-ui/issues/247.

            Cheers!

            As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Wednesday, December 5, 2012

            Dec 3 language design meeting notes (Mixins)



            Dart engineer Bob Nystrom has posted the notes from the December 3rd language design meeting. He writes:

            If you're as excited about mixins as I am, you'll be happy. This week's language meeting was all about them. I tried to keep up as best as I could this week, but I'm not much of a secretary. Any omissions or mistakes are all my fault.

            Lots of people were in this meeting. Except Lars, who is apparently in Austria with Katy Perry. I'm guessing that's a joke, but you can never tell...

            Kasper likes the proposal but discussed some syntax changes with Peter.

            They are discussing VM implementation since Ivan [VM lead] is in Aarhus [Kasper and Lars' office]. Does the mixin have to go in the superclass chain?

            Gilad: There is well-defined semantic model and it has been implemented before.

            Kasper: Where is it being in superclass chain visible? Reflection?

            Gilad: In is checks too. You could also see it in super calls, but the current proposal says you can't have those.

            Kasper: But the class mixing it in can have super calls.

            Gilad: Yes, and there you should see mixin methods.

            Kasper: Would a super in a class that extends a mixin application hit the superclass or the mixed in methods?

            Gilad: Would hit superclass, which is mixed in methods.

            Kasper: If you want to override a mixed in method...

            Gilad: Yes, need to have same rules for how an override works.

            Ivan: I thought a super call skips mixins and goes straight to class in extends clause.

            Gilad: That's not the original intent. "Goes to superclass" means "go to the superclass which *is* the compound mixin application class".

            Ivan: I thought it was more complicated then because you have to skip these other artificially created superclasses.

            [More discussion here, the end result of which, I think is that this is easier to implement than Ivan originally thought.]

            Kasper: Is it OK to canonicalize mixin applications?
            Ivan: Is it legal to canonicalize but not forced?

            Ivan is worried about class explosion. Gilad says he hasn't seen that in other languages.

            I pointed out that we're doing more code generation like in web components, so there may be more artifically generated classes and mixins.

            Kasper: I'm not too worried about canonicalization. It probably wouldn't be a breaking change if we changed it.

            Ivan: I'd be more comfortable if it allowed but did not mandate it.

            Kasper: The next step from my POV is agreeing on syntax.

            Cheers!

            As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.

            Photo credit: http://arlingtonhousewife.files.wordpress.com/2010/08/batter-without-mixins.jpg