RSSAmplifier

Blog

Seth Ladd's Blog

Product Manager @ Google, web engineer, author, conference organizer.

blog.sethladd.comRSS feed ↗25 posts

Latest posts

Add SSL to your personal website

Give yourself a gift this holiday season, and add SSL to your personal site. The web is going secure, and it's time to be part of the solution. This article details how I turned on SSL + custom domains, plus automated deploys, for my personal site for the cost of a domain (which I already had) and $5/year. Read on! Turns out, it's easier (and more affordable!) than you think to add SSL to your…

Dynamically load package contents with Dart's new Resource class

tldr: In Dart 1.12, you can now dynamically load the contents of files/assets from package dependencies. The new Resource class is currently implemented in the VM, with dart2js support coming in a future release. Motivation Dart applications are rarely just a collection of .dart files from a single developer. Real-world Dart apps often include numerous package dependencies, which contain…

New Dart SDK helps eliminates symlinks

In which we retell the story of Dart and symlinks, investigate the new .packages file, and create a simpler world for Dart developers everywhere. tldr: The Dart team is working towards a world where symlinks are no longer required because of the new .packages file. Why a new solution for locating packages? In the long long ago, during the before times (aka 2011), Dart could only run monolithic…

Null-aware operators in Dart

Three new language features just landed in the latest dev channel build of the Dart ! Collectively known as null-aware operators , these new features will help you reduce the code required to work with potentially null objects. I'm excited for these new abilities, because typing less is always a good thing. Read on to learn more, and be sure to try these new features on Dart Pad . ?? Use ?? when…

Formatting Dart code before every git commit

Dart 's dartfmt tool is a really neat utility to automatically format your code. Use the dartfmt tool in your workflow to ensure your code complies with the Dart style guide . Of course, you don't want to manually run dartfmt. Instead, you want to automate it. Use git's pre-commit hook to ensure your code is formatted, before it is committed. Add the following code to your . git/hooks/pre-commit…

I ported a JavaScript app to Dart. Here's what I learned.

In which I port a snazzy little JavaScript audio web app to Dart , discover a bug, and high-five type annotations. Here's what I learned. [As it says in the header of this blog, I'm a seasoned Dart developer. However, I certainly don't write Dart every day (I wish!). Don't interpret this post as "Hi, I'm new to Dart". Instead, interpret this post as "I'm applying what I've been documenting."] This…

Speed Up Your Dart App's Initial Load With This Transformer

I just saved potentially hundreds of blocking milliseconds from my Dart app's initial loads. By moving script tags, and using my new pub transformer, you can help your users, too. Where does the time go? First, some background: Typical Dart applications are designed to work in Dart VM and modern JavaScript. A small file, named dart.js , is loaded by the HTML file and checks to see what runtime is…

Angular and Polymer Data Binding, Together!

Angular and Polymer, sitting in a DOM tree, B-i-n-d-i-n-g. First comes components, Then comes elements, Then comes the interop with the node dot bind. Angular , a super heroic MVC framework, and Polymer , polyfills and enhancements for custom elements built on top of Web Components, can live harmoniously in the same app. This post shows you how to connect Angular-controlled components to…

How to shrink the size of your Dart app when compiled to JavaScript

So you caught the Dart bug and you're enjoying using the structured language, comprehensive libraries, and productive tools. Great! Except, when you compiled your Dart app to JavaScript, the output was bigger than expected. Read this post to learn how to reduce the size of your JavaScript output. Small apps are fast apps! Make sure you are minifying The dart2js compiler can minify your JavaScript.…

Compile-time dead code elimination with dart2js

Right before the release of Dart 1.0, the Dart team snuck in a cool new feature that helps you optimize the generated JavaScript from your Dart apps. Configuration values from the environment can be evaluated at compile time and potentially result in dead code elimination. Smaller code is faster code! As an example, let's consider the common case of logging. Debug logging is a useful tool during…

Forms, HTTP servers, and Polymer with Dart

(Update of this old Web UI post . Updated as of Jan 17, 2014 and Dart 1.1.) Dart can be used on the client and the server. This post shows how to: build a form as a custom element bind input fields to a Dart object build a Dart HTTP server handle and parse a form submit For lots more Polymer.dart examples, be sure to check out the Dart Polymer Samples . You can find the code for this post at my…

JavaZone Report. Spoiler: Awesome.

I had the pleasure of presenting Dart and Web Components at JavaZone 2013 in Oslo, Norway, and I'm so very happy I had the chance. The audience was clearly interested in Dart, the organizers are truly professional and welcoming, the crowd was friendly, the A/V setup was top-notch, and the logistics were easy. JavaZone is produced by JavaBin , a large network of Java user groups across Norway. I…

You complete me, unless you already have a Dart future

Dart Protip: if you already have an instance of Future, you probably don't need a Completer. Simply return the last Future. If you find yourself using Completers inside of Futures, like this: // NOT recommended. Future doStuff() { Future future = someAsyncProcess(); Completer completer = new Completer(); future.then((msg) { bool result = msg.result as bool; completer.complete(result); }); return…

Polymer and Dart: A First Look

In which I try the new polymer.dart, a build.dart file is deleted, and a template springs to life. (This post heavily inspired by Nik Graf's great " Getting started with Polymer.dart " post.) The web is evolving Developers take notice! Coming soon: actual encapsulation, real live data binding, even re-usable components! The Web Components family of specifications is on their way to a browser near…

Two-way data binding with Web UI custom elements and models

Preface This could very well be my last Web UI post! The Dart team announced they started on polymer.dart , a port of the Polymer project to Dart. Polymer.dart is the next evolution of Web UI. Luckily, the concepts are mostly the same and the syntax is mostly the same, because Web UI is also an implementation of the Web Components. So why am I still writing about Web UI? Lots of people have asked…

Dart and Sencha Touch for Mobile Web Apps

You can use Dart's JS-Interop to integrate Dart code into your existing Sencha Touch application. This allows you to take advantage of Sencha Touch's mobile-first framework and Dart's productivity, language, and libraries. Preface Sencha Touch is a full-featured JavaScript framework for mobile web apps . It supports layouts for multiple devices, touch, lots of widgets, models, a resource…

Create unified interfaces across dart:io and dart:html

Dart runs on the client, thanks to dart:html, and on the command line, thanks to dart:io. However, like oil and water, those two libraries just don't mix. Your web apps can't use dart:io, and your server apps can't use dart:html. Normally, this isn't a problem, because the two different targets are oh so very different. However, some concepts are common, such as Web sockets or HTTP requests.…

Call JavaScript from Dart - First Look

UPDATE : This article is deprecated. Dart has an improved Dart-JavaScript interop library, now included in the Dart SDK. Please read about dart:js and how to use it. If possible, do not use the js package that this blog post talks about. The js package will bloat your code. --- You can use Dart to access existing JavaScript code, thanks to the Dart-JS Interop package. Call JavaScript functions…

Forms, HTTP servers, and Web Components with Dart

( UPDATED VERSION HERE . This post is out of date, you probably want the new version .) Dart can be used on the client and the server. This post shows how to: build a form as a custom element bind input fields to a Dart object build a Dart HTTP server handle and parse a form submit For lots more examples, and more context and details, be sure to check out the Dart Tutorials . You can find the code…

Watch the video from What's New in Dart from Google I/O 2013

Google I/O was a blast, and Dart had a great time . For posterity, check out the video of my talk with co-presenter Justin Fagnani. We covered what's new across the Dartosphere, including language features, libraries, tools, and ecosystem. Like what you see? Head on over to dartlang.org to download the SDK and check out our docs and tutorials. You can always find us in our Dartisans G+ community .…

Lazy Load Libraries in Dart

UPDATE: This article is now DEPRECATED, but the feature lives on! Dart now formally supports lazy loading (deferred) libraries. Learn more in the Deferred Loading in Dart article . Dart is a statically analyzable language, and its tree-shaking compiler does a good job of eliminating dead code and producing a single, optimized application file. However, sometimes developers need to control when…

Dynamically Load Code with Dart

Rejoice! Dartium, a build of Chromium with the Dart VM, can now spawn a new isolate from a URI. This means your Dart apps have a new option for more modular code. Isolates In Dart, an isolate is an abstraction for an "isolated memory heap". Isolates do not share memory (variables, statics, etc), they are essentially self-contained applications. Isolates communicate by sending and receiving…

6 Dart FAQs - Answered!

Calvin Prewitt wrote some good questions about Dart via G+. It might be hard to find his questions and my answers, so I hoisted them here. Enjoy! Q) Could you also detail compatibility and which JavaScript APIs are fully or partially supported for Dart2JS production code? A) All JavaScript APIs supported by Chrome should be available to Dart. See http://www.dartlang.org/articles/improving-the-dom/…

First Look at Dart Mixins

You can use mixins to help inject behavior into your classes without using inheritance. Use a mixin when you have shared functionality that doesn't fit well in a is-a relationship. Dart supports a basic form of mixins as of the M3 release in early 2013. The language designers expect to expand on mixins' abilities in future versions of the language. Surprisingly, you've been using the concept of a…

Dart on FLOSS Weekly from TWiT Network

Today I had the pleasure of chatting about Dart with Randal Schwartz and Aaron Newcomb on FLOSS Weekly (part of the TWiT network ). We talked about the Dart language, its developer ecosystem, and the future of the project. You can watch the entire video of the interview, embedded below for easy viewing: Thanks to Randal and Aaron for a lively discussion. They are awesome hosts and I highly…