For my first efforts at Dart, I would like to get a simple "hello world" application running. As a stretch goal, it would be nice to play with iterators and the DOM, but let's see how far I get with the simplest case first.
I create a very simple web page with minimal Dart (or what I think passes for Dart) in it:
<!DOCTYPE html> <html> <head> <script type="application/dart"> #import('dart:html'); main() { Console.log("hello"); } </script> </head> <body> <h1>Hello Dart <div id="target"></div> </body> </html>When I load that up in Chrome... nothing.
Thinking that maybe I have the
lt;script>
tag wrong, I change strategy. Instead of defining the dart script in the HTML, I load it from a separate file:... <script type="application/dart" src="iterator.dart"></script> ...It is at this point that I realize that it is not possible to do Dart natively in Chrome yet. Bummer.
Almost resigned to doing all of this in the "Editor" thingy, I happen to stumble across build instructions for a dart-enabled Chrome.
I learn the hard way that this will not run well from an interactive zsh prompt. So first I switch to bash and then run the installer:
➜ dart-site git:(master) ✗ cd ~/src ➜ src bash 1.9.2 ~/src $ source install-build-deps.shEventually, it runs to the point that I am asked what to do with 32 bit libraries:
... Installing 32bit libraries not already provided by the system This is only needed to build a 32-bit Chrome on your 64-bit system. While we only need to install a relatively small number of library files, we temporarily need to download a lot of large *.deb packages that contain these files. We will create new *.deb packages that include just the 32bit libraries. These files will then be found on your system in places like /lib32, /usr/lib32, /usr/lib/debug/lib32, /usr/lib/debug/usr/lib32. If you ever need to uninstall these files, look for packages named *-ia32.deb. Do you want me to download all packages needed to build new 32bit package files (y/N)Curious, I answer "No". This turns out to be a bad idea because the installer exits. Re-running the script, I am then greeted with:
... It produces the following output: Reading package lists... Done Building dependency tree Reading state information... Done 0 upgraded, 0 newly installed, 97 reinstalled, 0 to remove and 0 not upgraded. Need to get 0 B/61.9 MB of archives. After this operation, 0 B of additional disk space will be used. E: Internal Error, No file name for libstdc++6 You will have to install the above packages yourself.Bah! This seems to be a bug in the installer script. Rather than troubleshooting it myself (I just want some progress tonight), I remove one of the packages previously installed:
➜ dart-site git:(master) ✗ sudo apt-get remove language-pack-frAnd then re-try the script, this time answering "Yes" to installing the 32-bit libraries.
I am forced to call it a night there as the installer is still downloading the entire contents of the Ubuntu repository. Hopefully tomorrow, I will have my very own Dart-enabled browser.
Day #248
You really should just try the editor.
ReplyDeleteNot only does it compile your Dart code to Javascript for you, so that you can run your app in any browser, but it also has code completion and navigation, which are some of the first benefits of the type system.
Oh, and it's compiled for you. Much less painful.
@Justin Given that I only have ~10G free on my laptop, I may be forced to agree with you :D
ReplyDeleteMy concern with the editor is that it's not Emacs. I've tried eclipse and other IDEs in the past and I find them excruciating (even with emacs key bindings).
Then again, I am going to need to investigate compiling-to-javascript eventually. Maybe it's better to front load it in my exploration of all things Dart. That way, I can wait for some binaries :)
Thanks for the tip!
google 1739
ReplyDeletegoogle 1740
google 1741
google 1742
google 1743
google 1744
google 1745