3 ms·
It's going to be an even bigger hit than express, for sure.
by ulisesrmzroche 13y ago
It's going to be an even bigger hit than express, for sure.
- nailer 13y agoI've been playing with 'Co', the thunk / flow control framework TJ uses for Koa: #!/usr/bin/env node --harmony var fs = require('fs'), co = require('co'), thunkify = require('thunkify'), request = require('request'), readFile = thunkify(fs.readFile); get = thunkify(request.get); var log = console.log.bind(console); // Create a thunk, and run it immediately. co(function *(){ try { var fileContents = yield readFile('myfile', 'utf8'); log(fileContents); var yahoo = (yield get('http://yahoo.com'))[0]; log(yahoo.statusCode) } catch(error) { log('Oh no, an error!') log(error.code) } })() Async, inline, catching errors. It's nice.
- ulisesrmzroche 13y agoYeah, once you start using yield it's really hard to write JS without it. It's nice to get that keyword back. You can start throwing that on mocha too, it's pretty sweet.
- btd 13y agoIt is nightmare for v8 jit.
- andreypopp 13y agoWho needs JIT on I/O bound tasks?
- coldtea 13y agoAny links for that?
- btd 13y agov8 does not optimize blocks inside try catch (not too fresh http://www.html5rocks.com/en/tutorials/speed/v8/ http://www.html5rocks.com/en/tutorials/speed/v8/) and about generators and optimizations (http://wingolog.org/archives/2013/06/11/ecmascript-generators-from-a-performance-perspective http://wingolog.org/archives/2013/06/11/ecmascript-generator...)
- lttlrck 13y agoit's a nightmare for crankshaft.
- btd 13y agoYes, you are right. I forgot how they call own optimizer. (i wanted to point that people do not repeat blindly that peace of code)