Posts

Showing posts from November, 2011

Variables and Optional Types in Dart

Update: Reworked some of the optional types section based on comments.

Intro

Dart is a structured web programming language, complete with libraries, a virtual machine, and an editor. Dart is designed to help developers create more complex and feature rich apps for the modern web.

In this post, we look at variables and their types in Dart.

Variables

The most simple example declares a variable without an explicit type:

main() { var msg = 'hello'; print(msg); } > hello
The most common way to declare a variable is to use the var keyword. This is truly a variable, as shown here:

main() { var msg = 'hello'; msg = 'world'; print(msg); } > world
final

So far, this is a lot like JavaScript. Let's see what Dart can do differently. Dart allows you to mark variables as final.

main() { final msg = 'hello'; msg = 'world'; // ERROR: cannot assign value to final variable print(msg); }
This all looks simple, but let's reflect on what we&…

Why Dart Excites Me

Intro

Dart, the new open source structured web programming language currently in technology preview, is making me excited about web programming again. I'm watching it closely, fully understanding it's extremely early in the game to make any predictions. However, at least I can say I'm hopeful that there's a team out there attacking the very real problem of "not enough complex and full featured web apps" by working on an a language/libraries/VM option for modern web apps.

My background

I am a Java developer in a past life, where I grew to love the rich libraries, composable and modular applications, helpful tools, and refactoring techniques. I am a web developer at heart, with a true love for browser based client side web apps. This dichotomy was a bit of an uneasy fit, as part of me wanted a language with more structure (enabling tooling and modularity), and the other part of me wanted the insanely quick iterations of web development and the native-to-the-brows…

Transcription of A Quick Tour of Dart by Gilad Bracha

Image
On November 2nd, 2011, Gilad Bracha gave a talk at Stanford University titled "A Walk on the Dart Side: A Quick Tour of Dart". I transcribed nearly all of the video so you can more easily skim and study the material.  Thanks to Dart News for pushing to YouTube. Learn more about the Dart language.



(disclaimer, I did my best to capture what was said, any errors are my own)


We’re talking about dart. It’s a new language we’re working on at Google. It’s really not my work. I joined the team the 3 months ago, but this project has been running for about a year. I’ve just started to contribute to this in any way I can. Overall, it’s the work of the Dart team, which is a fairly significant team.At 50,000 ft, the overall summary is that it’s a language for programming the web.  What is special about the web? In principle there’s nothing special about the web, but in practice there’s a lot that’s special about the web. And we’ve had an arguably had a regression in terms of tooling and t…