Dart & AngularJS

2,021 views
Skip to first unread message

Michael Chean

unread,
Apr 10, 2012, 3:36:04 PM4/10/12
to mi...@dartlang.org
Any chance that you plan on generating Angularjs at some time?

Seth Ladd

unread,
Apr 10, 2012, 4:26:46 PM4/10/12
to Michael Chean, mi...@dartlang.org
Hi Michael,

AngularJS isn't on our radar right now. It would be an interesting project for someone to try, but we're not thinking about it right now.

Curious, what are the features of AngularJS that interest you?

Thanks,
Seth

Michael Chean

unread,
Apr 10, 2012, 8:58:09 PM4/10/12
to mi...@dartlang.org, Michael Chean
Hi Seth:
I'm just looking at it now, and it seems very straight forward.  However, I understood that it's origin was from Google, so I thought maybe there
was some connections.  There are a number of efforts coming from Google in the language sphere, but they seem to be independent of each other.

Mike

Seth Ladd

unread,
Apr 10, 2012, 11:23:20 PM4/10/12
to Michael Chean, mi...@dartlang.org
Hi Michael,

I know it appears that way sometimes, even to us inside Google. Dart is looking at different web app frameworks for inspiration, and I know the team is aware of Angular.

Thanks for the suggestion,
Seth

Søren Kyndi-Wiuff

unread,
May 8, 2012, 5:57:23 AM5/8/12
to General Dart Discussion


>
> Curious, what are the features of AngularJS that interest you?
>

What would be most interesting is the two-way databinding that
AngularJS and similiar frameworks offers.

Sam McCall

unread,
May 8, 2012, 10:22:40 AM5/8/12
to Søren Kyndi-Wiuff, Martin Probst, General Dart Discussion
+martinprobst
Martin has recently started using AngularJS on an internal project and
has been quite impressed. I hope something similar will emerge for
Dart.

The most important features seemed to be:
* data binding, as Søren mentioned
* templating at the DOM (rather than textual) level
* client-side URL routing
* separation of controllers, terseness through dependency injection
* testability of controllers
* rich set of builtin directives and services
* extensibility (can write your own first-class directives)
* excellent documentation :-)

Martin, anything to add?

olouv...@gmail.com

unread,
Jul 17, 2012, 7:33:52 AM7/17/12
to mi...@dartlang.org, Søren Kyndi-Wiuff, Martin Probst
I'm also very interested by this.

That would be so awesome to have interoperability between the two projects, so that a JS user can commit today on a AngularJS app knowing they will have a window in the future to easily switch to Dart (& gain improved perf, etc.), and it would also promote the Dart language (to build real web apps). To me, you guys should definitely work together. This looks so critical today, as everything still seems fuzzy on where OO-programming complex web&mobile app will go in the next few years. Angular is getting some traction, it could clearly be a nice leverage for Dart.

I clearly dream of an AngularDart project that could compile to web apps (like app.js headless webkits) & native apps (like titanium but done right)...
Damn, it seems so far away...!


On Tuesday, May 8, 2012 4:22:40 PM UTC+2, Sam McCall wrote:

Shannon Behrens

unread,
Jul 17, 2012, 12:02:30 PM7/17/12
to olouv...@gmail.com, mi...@dartlang.org, Søren Kyndi-Wiuff, Martin Probst
I personally like AngularJS as well. I spent some time hanging out with the AngularJS guys a few weeks ago. Although I know the Dart team is working on their own client-side framework, it is my personal opinion that there will be many ways to build web applications in the future even in the Dart community, just as there are many ways to build web applications in the JavaScript community today. Naturally, many approaches will be created by non-Googlers. I think we're already seeing that in the Dart community. I also think that interoperability with JavaScript is something that's critical for Dart, and it's something I know we're working on.

Happy Hacking!
-jj
--
Shannon -jj Behrens | Developer Advocate for YouTube APIs | apiblog.youtube.com | @YouTubeDev

Vincent Spallek

unread,
Aug 7, 2012, 11:34:12 AM8/7/12
to mi...@dartlang.org, Søren Kyndi-Wiuff, Martin Probst


On Tuesday, May 8, 2012 4:22:40 PM UTC+2, Sam McCall wrote:

The most important features seemed to be:
 * data binding, as Søren mentioned
 * templating at the DOM (rather than textual) level
 * client-side URL routing
 * separation of controllers, terseness through dependency injection
 * testability of controllers
 * rich set of builtin directives and services
 * extensibility (can write your own first-class directives)
 * excellent documentation :-)

I'd like to add:
* support for existing HTML/CSS tool chains, because AngularJS works on valid HTML files. (Different from Buckshot, which uses its own XML scheme)

Seth Ladd

unread,
Aug 7, 2012, 12:23:13 PM8/7/12
to mi...@dartlang.org, Søren Kyndi-Wiuff, Martin Probst
Thanks Vincent. One open question is minification, a common step in a build process tool chain. Current minifiers only get us so far with dart2js output, because dart2js (last time I checked) uses string names for method invocation (sometimes). That's harder to minify. I think the dart2js team has minification on their radar, though.

The Dart team is embracing web components, which are the future of composable web apps. With web components, you'll use normal CSS and HTML to create new tags like <x-widget>. I wouldn't be surprised if Buckshot evolved to use web components to power its components.

Thanks for the feedback!
Seth


--
Consider asking HOWTO questions at Stack Overflow: http://stackoverflow.com/tags/dart
 
 

John Evans

unread,
Aug 7, 2012, 1:12:14 PM8/7/12
to mi...@dartlang.org, Søren Kyndi-Wiuff, Martin Probst
You are so right Seth.  Web components are definitely on my radar for Buckshot's rendering routines.


On Tuesday, August 7, 2012 11:23:13 AM UTC-5, Seth Ladd wrote:
Thanks Vincent. One open question is minification, a common step in a build process tool chain. Current minifiers only get us so far with dart2js output, because dart2js (last time I checked) uses string names for method invocation (sometimes). That's harder to minify. I think the dart2js team has minification on their radar, though.

The Dart team is embracing web components, which are the future of composable web apps. With web components, you'll use normal CSS and HTML to create new tags like <x-widget>. I wouldn't be surprised if Buckshot evolved to use web components to power its components.

Thanks for the feedback!
Seth

Steve Gentile

unread,
May 15, 2013, 7:17:18 AM5/15/13
to mi...@dartlang.org, Michael Chean
When I see code like this:
TextAreaElement chatElem = query('#chat-display');
InputElement usernameElem = query('#chat-username');
  • InputElement messageElem = query('#chat-message');
Basically the 'jQuery' way of writing apps, versus using MVVM AngularJS approach

$scope.chatmessage

ng-bind="text: chatmessage"

I think Dart is going 'backwards'.  What surprises me though of these answers is that Dart is a language isn't it ?  AngularJS is a framework.

So the question I have is - 'how can the Dart language, which compiles down to javascript be used with the AngularJS framework'.  If Dart can't run javascript frameworks then it's just yet another proprietary language, reminiscent of using something like GWT.

I'd be very disapointed to learn Dart developers wouldn't be actively working with AngularJS devs to promote building AngularJS applications  written in Dart.

Zdeslav Vojkovic

unread,
May 15, 2013, 7:50:10 AM5/15/13
to mi...@dartlang.org
"If Dart can't run javascript frameworks then it's just yet another proprietary language,"
well, JS can't run Python libs, can it, does it make it more or less of a proprietary?

Dart is not CoffeeScript or TypeScript - it has different goals and is not meant to be just a preprocessor for javascript.
Actually, you can use JS interop to work with JS libraries, but that is not the way it is meant to be used, it is simply a workaround for current lack of libraries, as Dart is rather new.

Your sample compares apples to oranges - the Dart part is not idiomatic way to bind data to GUI.
Dart also supports model driven views and web components which use data binding, and that is similar to AngularJS approach.
This means that you have both jQuery-like approach available (as a part of core lib) and model driven approach, based on emerging HTML standards (MDVs, templates, etc)

sure, Dart has its drawbacks, but IMO it is often misunderstood


--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new
 
 

Mike Watson

unread,
May 15, 2013, 9:09:41 AM5/15/13
to mi...@dartlang.org
> Actually, you can use JS interop to work with JS libraries, but that is not the way it is meant to be used, it is simply a workaround for current lack of libraries, as Dart is rather new.

I disagree with this statement. If JavaScript is the assembly language of the web, then JS interop is the linker. The number of useful JavaScript libs will continue to grow at a pace far faster than Dart versions can be created.

Steve Gentile

unread,
May 15, 2013, 9:16:51 AM5/15/13
to mi...@dartlang.org
Ok that is fair - I am guilty here of a contempt prior to investigation - as I see the MDV and templates, @observable (aka KnockoutJS).

It feels very GWT to me with just a new language syntax but very 'java' like - I guess that is the 'misunderstanding' of it.

I'd like to see more on view composition, routing, controls, etc... for building large single page applications.

There are a bazillion javascript libraries, solving many of our day to day problems - and so if I'm going to build a SPA in Dart, I'm going to need access to this - not sure if creating 'wrappers' around it in an interop fashion - it just feels messy to me.  I'm not sure I get the Dart story behind this - as if Dart is expecting the entire community of javascript users to rewrite everything into web components ?

I'll keep researching, this is my first impression - I was seeing Dart as you say as a 'preprocessor for javascript'

Matthew Butler

unread,
May 15, 2013, 9:37:57 AM5/15/13
to mi...@dartlang.org


On Wednesday, May 15, 2013 10:16:51 AM UTC-3, Steve Gentile wrote:

There are a bazillion javascript libraries, solving many of our day to day problems - and so if I'm going to build a SPA in Dart, I'm going to need access to this...


Truthfully, you need to stop looking at javascript for solutions to your dart problems. Otherwise you're going to bind yourself up tighter and make life more difficult for yourself. Yes, Javascript has many many years head start on Dart in terms of libraries and frameworks. However many in the dart community (and even by the dart team themselves) have started addressing the issues you speak of. See: web_ui, route, rikulo, bee, widget, dart web toolkit, haml, hart, etc etc etc... on pub.dartlang.org 

as if Dart is expecting the entire community of javascript users to rewrite everything into web components ? 

Google started this process with web_ui, route, and of course the core libraries for Dart. Netscape didn't release javascript and 'expect the entire community to write everything'. It just happened as developers either found a need, or wanted to correct a need in their own way. So to are developers choosing to use dart to write a library rather than using or creating one in Javascript because they feel dart is the language they would prefer to use. For an example as to why... well see the popular blog post by the Thomas Schranz http://www.ramen.io/post/46936028144/we-are-switching-to-dart-why and follow up interview: http://www.infoq.com/news/2013/04/blossom-dart-switch

Their reasons may not fit your reasons, and that's okay. Dart may not even be the solution you want. But for a growing number of developers it is.  =) 

Mike Watson

unread,
May 15, 2013, 11:06:02 AM5/15/13
to mi...@dartlang.org
> Truthfully, you need to stop looking at javascript for solutions to your dart problems.

It depends on where your focus is. I agree with your statement if you are targeting the Dart VM.

Since we don't know where the Dart VM will end up, chances are you will use Dart2js for cross browser operation.  Converting useful JavaScript libs to Dart and then back to JavaScript with Dart2js is counter-productive. I don't think anyone is saying to do this, but that leaves the question open as to how efficient JS interop is for this use case. This has been noted before and will continue to be looked into. I'm really not trying to be argumentative but rather trying to keep this as my focus. I can't  jump on the Dart bandwagon and leave JavaScript behind until the Dart VM runs in more places.

Thomas Schranz

unread,
May 16, 2013, 12:48:14 AM5/16/13
to mi...@dartlang.org
Hey Mike,

I'm glad you're interested in Dart. If you take some time to play around with it you'll see how much sense
the language, standard lib & working with packages is. It's unsurprising and you can get going in minutes.

I understand that initially it might sound counter-productive to port js libraries to Dart if all that happens is
you compile it to js again to use it in the browser. That said it actually makes a lot of sense. Usually you'll spend
a significant amount of time working in your code-base, enhancing it, changing stuff, refactoring things, …

In that day to day work having your code base in Dart yields a ton of benefits that are relevant for the day-to-day of development.

* Dart is easier to work with as a language
* The tooling (Dart analyzer) will warn you about issues that no JavaScript IDE will warn you
* Compared to js it is way easier to work with packages (Dart supports it out of the box)
* You will get exceptions if something in your code went wrong at a time when you expect it (sooner rather than later).
* No more confusion about what 'this' is and support for classes out of the box
* …

I'm obviously biased but from my POV using Dart right now (compiled to JS) already yields almost all the benefits for your day-to-day development.
Of course it would be beautiful and more pure and even faster to be able to use the Dart VM and I'm confident we'll get there eventually
but Dart as a platform is very viable today already :)

Sorry the post got so long, I didn't have the time to make it shorter. I'm sure you'll like what you see when you play
around with Dart. Here are the getting started tutorials, great weekend project: http://www.dartlang.org/docs/tutorials/

Mike Watson

unread,
May 16, 2013, 11:35:47 AM5/16/13
to mi...@dartlang.org
Hi Thomas, thank you for being a passionate advocate for Dart. I really like Dart as well for all the reasons you've outlined. I wrote my app in Dart because I wanted to do rapid prototyping, easy refactoring and type assistance. I deliberately kept things as simple as possible, sort of a jQuery with classes pattern, just in case I had to convert it to JavaScript by hand for an earlier IE browser (so far I haven't had to do that). I'm sold on Dart.

It is my belief that js-interop is a key feature. I agree that there are advantages to converting JavaScript to Dart to work with even if you are going to convert it back to JavaScript with Dart2js, but there are many cases where this doesn't make sense.

For example, if I were to use the jStat library: http://www.jstat.org/ I might want to use the core functionality and do the plotting in Dart instead of using the flot jQuery plugin. I don't have time, there is no need and it would be error prone to convert the core functionality of jStat to Dart. Maybe someday the author will. I can just use it as is with js-interop, that is a key feature.

However, js-interop in it's current state is not optimal. For example, with a simple 'Hello from Dart' and 'Hello from JavaScript' program.  (following is unminified)

'Hello from Dart' by itself is 31k
'Hello from Dar't with 'Hello from JavaScript' through js-interop is 446k

minification cuts those figures in half

That's a lot of proxy code!

Since I want Dart to succeed and think js-interop is a key feature, I would like to see js-interop brought into the SDK and more people working on it. I would volunteer myself if I had time. 

Mike

import 'dart:html';
import 'package:js/js.dart' as js;

void main() {
  js.context.sayHello();
  window.alert('hello from Dart');
}

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Jsinteroptest</title>
    <link rel="stylesheet" href="jsinteroptest.css">
    <script type="text/javascript">
    function sayHello()
    {
      alert('hello from JavaScript');
    }
    </script>
  </head>
  <body>
    <script type="application/dart" src="jsinteroptest.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>
Reply all
Reply to author
Forward
0 new messages