Posts

Running Dart in the Cloud with Heroku

Image
[EDIT: Updated on 2014-10-11] Dart , the new programming language for modern web apps, certainly compiles to JavaScript. Did you know that Dart also runs on the server as well? Thanks to Heroku's support for third-party runtimes, you can now run your server-side Dart app on Heroku 's cloud. Read on to learn how. (Disclaimer: Even though Heroku can host arbitrary runtimes, they don't officially support the Dart runtime.) Dart for modern web apps Dart is a class based, single inheritance, object-oriented, optionally typed language that is built to help developers of many backgrounds build awesome modern web apps. Most importantly, Dart compiles to JavaScript so that your Dart apps can run all over the web. Dart is familiar to JavaScript, Java, C, C++, and C# developers. There's even bits of Smalltalk in there. While it has a syntax that is instantly recognizable, it also has cool new features like optional static types and isolates . Check out the Dart langua...

Simple Dart + WebSocket demo

[EDIT: Updated on 2013-03-05] I just posted a simple demo of Dart with WebSockets . Not only does it show how to connect to a WebSocket server and send messages, it also shows off a few neat features of the Dart language . (The code follows below, or check out the full  open source project .) Look mom, no classes! Dart is a class-based object oriented language, but that doesn't mean you are required to wrap everything in a class. No sir, this is Dart, not Java. In Dart, you can use top level functions and top level variables. Libraries for modularity Dart organizes code into libraries for modularity. For example, this code uses the dart:html library for the WebSocket code. Concerned about bloat here? Don't be! Thanks to tree-shaking, the code that you don't use is eliminated during a (optional) compile step. The Dart to JavaScript compiler uses tree shaking to help generate minimal JavaScript code (still more work to do here). An upcoming Dart to Dart script wi...

How we built the new Dart homepage

Image
I work with the Dart team, and we needed to update our dartlang.org site. It was a fun project to rebuild dartlang.org , so I wanted to give a shout-out to some of the libraries and tools that we used. The new dartlang.org Requirements for the new dartlang.org included: work on multiple screen sizes display more obvious calls to action load faster clean up CSS display more info on the home page To achieve these goals, we used the following tools: Bootstrap  CSS and widgets Jekyll  (and plugins) site generator Markdown with kramdown  text file formatting Pygments syntax highlighter Compass CSS framework Bootstrap + Compass for SCSS Font Awesome for sprite icons Make build tool optipng image shrinker App Engine hosting Bootstrap , from Twitter, is a slick set of CSS styles and simple JavaScript plugins. Bootstrap has a grid system, pre-defined styles, and most importantly a sane set of defaults for adaptive layouts. Jekyll is a st...

Slides from Dart talk at O'Reilly's FluentConf JavaScript conference

The fine folks at FluentConf included a Dart session in their first JavaScript conference. I had the pleasure of presenting "Structured web programming with Dart", an introduction to Dart's motivations, language, libraries, tools, and ecosystem. The room was packed, which was quite encouraging! I learned that Dart's optional static type annotations are very interesting to JavaScript developers. They especially appreciated the optional part. That is, in Dart you can experiment with simple functions and scripts as you start your idea, and grow over time to full complex modern web apps that use more structure like classes, interfaces, and libraries. Once your design emerges and you are comfortable with the structure, or once you enter maintenance mode, you can add the type annotations. Once those type annotations are in your code, the magic turns on. Type annotations provide inline documentation for your fellow developers. The toolchain can also read the type annot...

My interview with O'Reilly on Dart and doing better.

Image
I had the pleasure of being interviewed by Simon St. Laurent on the topics of Dart and how we can all strive to do better. Thanks Simon! The orignal post has the chapter markers and topics if you want to skip around.

Misleading strong type systems

This post is a record of a Dart Misc mailing list post  titled "Types are useless (?)". The original author was curious why Darts "allows running code with invalid arguments".  My reply follows: --- For reference, let's look at Java. Many would think that Java has a "strong type system" and that its types prevent, as you say, invalid arguments. However, it's easy to write a Java program that will compile just fine, yet fail at runtime. In your words, it will allow running code with invalid arguments. Here's an example: import java.util.*; public class hacked {   public static void test(int i) {     System.out.println(i);   }   public static void main(String[] args) {     String msg = "hacked";     Map cache = new HashMap();     cache.put("hacked", msg);     // later     int hacked = (Integer) cache.get("hacked");     test(hacked);   } } This code will comp...

When Dart types aren't optional

Dart, the structured web programming language, has a feature typically called "optional types". Dart claims that "type annotations don't affect the runtime semantics of the code". This post helps to explain when a type is and isn't optional, and what "type annotation" means as different than "type". The Dart discussion mailing list kicked off a good thread about generics , which evolved into when types can be optional. The Dart community chimed in with great answers (thanks to Ladislav, Sam, John, Dirk, Ross, Bob, and Eli!). Bob Nystrom summed it up well, with some examples that I wanted to specifically highlight: Bob writes: --- Types aren't always annotations. There are type annotations, but there are also places where types appear in code that are not annotations. For example: // type annotations:  int i; foo( int i) => ... class Foo {   int bar;   int baz() => ... }  // types that are not annotation...