Fletch: the new server/client story?

138 views
Skip to first unread message

Jacob Goodson

unread,
May 16, 2015, 7:38:29 PM5/16/15
to mi...@dartlang.org
I have watched videos on Fletch, read about it, and followed various forum posts dealing with it... Is Fletch meant to replace the current Dart vm with one that is not held back by browser requirements?  It seems Fletch will allow developers to interactively code programs as well as use concurrency/parallelism more easily.  Am I misunderstanding its purpose?

Lex Berezhny

unread,
May 16, 2015, 7:42:15 PM5/16/15
to misc
I think the main thing Fletch will bring is the ability to compile Dart code so that it will run on iOS. But there are also a lot of other interesting things going on with Fletch that are unique to Fletch.

I'm not sure what you mean with the browser comment. Dart VM is not held back by browser requirements (any longer).

On Sat, May 16, 2015 at 4:38 PM, Jacob Goodson <submissio...@gmx.com> wrote:
I have watched videos on Fletch, read about it, and followed various forum posts dealing with it... Is Fletch meant to replace the current Dart vm with one that is not held back by browser requirements?  It seems Fletch will allow developers to interactively code programs as well as use concurrency/parallelism more easily.  Am I misunderstanding its purpose?

--
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

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Jacob Goodson

unread,
May 16, 2015, 7:51:06 PM5/16/15
to mi...@dartlang.org
I know that it is no longer held back by it, but I did not know if Fletch could one-up the original vm since it is being created without any intentions of satisfying browser requirements(I assume).  I do not think Fletch is being made prominently for Dart to be able to run on ios, I think ios, as a target, just a side goal to Dart on mobile(Fletch?).  However, I could be wrong, I am just trying to get a little more clarity.  A ton of languages now compile to javascript, so I am wondering what selling points are coming on the horizon. 

Lex Berezhny

unread,
May 16, 2015, 7:57:06 PM5/16/15
to misc
I meant to add that as a language Dart will probably continue to be held back by browser requirements into the foreseeable future. As long as Dart will compile to JavaScript there will be certain restrictions on what can be done (and still produce reasonably fast javascript). And since Google Ads depends on Dart you can safely bet that dart2js will be around.

Dart VM will continue to exist on server side (and client side outside browser).

Fletch will make it possible to build iOS apps with Dart.

Seems like the main client side story now for Dart is Sky (outside of dart2js).

Lex Berezhny

unread,
May 16, 2015, 8:01:51 PM5/16/15
to misc
On Sat, May 16, 2015 at 4:51 PM, Jacob Goodson <submissio...@gmx.com> wrote:
I know that it is no longer held back by it, but I did not know if Fletch could one-up the original vm since it is being created without any intentions of satisfying browser requirements(I assume).  I do not think Fletch is being made prominently for Dart to be able to run on ios, I think ios, as a target, just a side goal to Dart on mobile(Fletch?).  However, I could be wrong, I am just trying to get a little more clarity.  A ton of languages now compile to javascript, so I am wondering what selling points are coming on the horizon.

I don't think Fletch can do everything Dart VM can do and vice versa. So there is room for both.

Jim Trainor

unread,
May 16, 2015, 9:56:46 PM5/16/15
to mi...@dartlang.org
I view it mostly as a lighter weight embedding option that complies with iOS restrictions. By virtue of that it opens other embedding options as well.  That aids in expanding the Dart ecosystem and forming a base of entrenched adopters. Look at the number of places, for example, that Lua and Javascript are embedded.  The concurrency aspect appears to be a timely research topic for which fletch is the vehicle. All just speculation and reading between the lines however.

Rich Eakin

unread,
May 16, 2015, 10:41:48 PM5/16/15
to mi...@dartlang.org
On Sat, May 16, 2015 at 9:56 PM, Jim Trainor <jim.trainor.kanata@gmail.com> wrote:
I view it mostly as a lighter weight embedding option that complies with iOS restrictions. By virtue of that it opens other embedding options as well.  That aids in expanding the Dart ecosystem and forming a base of entrenched adopters. Look at the number of places, for example, that Lua and Javascript are embedded.  The concurrency aspect appears to be a timely research topic for which fletch is the vehicle. All just speculation and reading between the lines however.

 

I have a similar view of the fletch project and hope that it succeeds in this aim. To be able to use a language dart as 'glue' for arbitrary platforms would be extremely powerful, and the language is so much nicer than Lua or javascript. That it is lightweight and aims to support 'live reload' are also huge features for why I'm keeping my eye on the project.

To me, Dart VM is a a bit of a different beast, which is in direct competition concerning performance and robustness with VMs such as v8 or spidermonkey, and I suppose java VMs as well. 

Joao Pedrosa

unread,
May 17, 2015, 6:55:48 AM5/17/15
to mi...@dartlang.org
Hi,

For the past few days I have started playing with Fletch more seriously. Fletch has a FFI feature that allows for invoking some arbitrary system functions to extend it with. It seems that FFI has been an important way for languages to get extensions. I first heard of FFI in Ruby, but it seems that the LuaJIT has gone one up on almost everyone else by dynamically compiling C function signatures and such, so that the LuaJIT may have one of the most advanced FFI supports out there. It does cause people to be locked to it I guess. I've been browsing some of the LuaJIT mailing list posts, and in one of them they were even suggesting that LuaJIT allows for using C structs for a faster than the "metatable" way to code, it seems. LuaJIT is just phenomenal, except that the language is not like Dart.

Fletch's FFI seems to be custom-made. It doesn't seem to use any external FFI library. The API set seems to be smaller than others, but it works so I have used it to create extensions that I have posted to my experimental Fletch project here: 

For my Arpoador project I have added some more ways to work with Files and Directories. Added a FileBrowser class to search directories. I'm also experimenting with the important Fletch socket support. Next I want to support running command-line tools from Fletch and capture the output. If you want to start a HTTP server with Arpoador you can use just code like this:

import '../../lib/arpoador.dart';
import '../../lib/io/io.dart';
import '../../lib/lang.dart';


handleSocket(socket) {
  Momentum.handle(socket, (req, res) {
    res.writeHead(200, {"Content-Type": "text/html"});
    res.writeBuffer(IO.readWholeBuffer("sample_file.html"));
    });
}

main() {
  Momentum.listen(handler: handleSocket);
}

I tried to keep an API similar to what people are used to in Node.js and similar systems. By writing directly from buffers rather than first loading the file content into strings I got a performance boost for serving static files, so I kept it. Here's the kind of performance that it gets me:

[snip]
Concurrency Level:      100
Time taken for tests:   0.800 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      3590000 bytes
HTML transferred:       2980000 bytes
Requests per second:    12497.84 [#/sec] (mean)
Time per request:       8.001 [ms] (mean)
Time per request:       0.080 [ms] (mean, across all concurrent requests)
Transfer rate:          4381.57 [Kbytes/sec] received
[snip]

Fletch's concurrency allows it to use all the CPUs, which is absolutely great compared to what we normally get with scripting languages. I did notice that performance starts to fall whenever I've added some more features. I added a Request parser (only header is being parsed, no Post body yet.)

Fletch is pretty quick though. But it has safety nets like bounds checking in FFI that can hurt performance a little bit when we are extending it. My feeling is that Fletch is at least about as fast as normal Lua since I ran a couple of benchmarks to compare them. But on pure number crunching it's no surprise that Fletch would lose to JIT VMs.

Also Fletch has a lot of support for Dart but is still missing things like loading functions with named parameters... But this week after I upgraded the Fletch version, I noticed a small performance improved in one of the "ab" tests I did. That is, Fletch is being actively worked on and I hope that they can succeed. Having a second great VM for Dart code would be awesome. And now that even Microsoft seems to be thinking about restricting JIT in their mobile systems, Fletch could be useful on Windows phones some day. :-)

For now Fletch does not support Windows yet, though. You need Linux or MacOSX to give it a try.

Cheers,
Joao



Reply all
Reply to author
Forward
0 new messages