7 ms·
0s: "next generation web framework for node.js" (oh god, not another) 5s: "designed by the team behind Express" (wait what?) 6s: "Through leveraging generator
by quarterto 13y ago
0s: "next generation web framework for node.js" (oh god, not another)
5s: "designed by the team behind Express" (wait what?)
6s: "Through leveraging generators Koa allows you to ditch callbacks" (wow, ok. oh hey, that makes "next generation" not just marketing fluff)
18s:
app.use(function *(next){
var start = new Date;
yield next;
var ms = new Date - start;
this.set('X-Response-Time', ms + 'ms');
});
(oh sweeet)
- mateuszf 13y agoSo, does node support generators out of the box?
- quarterto 13y agoIt's behind a flag (--harmony-generators) in 0.11 (current stable is 0.10, hence my "next generation" comment).
- FooBarWidget 13y agoReading this comment makes me sad. Does this mean you would have immediately closed the tab, irregardless of technology, if they didn't namedrop?
- quarterto 13y agoI was already giving it the benefit of the doubt by reading any further than "next generation web framework for node.js".
- easy_rider 13y agoCouldn't agree more. Happy that I did though.
- usethis 13y agoit's because of the hyperbole: > next generation web framework for node.js I don't think they need that, just list the stand-out features first. And yes, referring to past accomplishments does give it more credibility.
- eknkc 13y agoThis utilizes generators heavily. Generators are within the ES6 spec, which is the next generation of JavaScript. This might be one of the very few instances that "next generation" is a valid statement.
- mathrawka 13y agoToo many things claim to be a "next generation framework", that it usually is a let down because it is just a rehash of something. But this is something new that looks like it can be good. I've been wondering when it would be announced, as TJ has been working on it for a while: https://github.com/visionmedia?tab=activity https://github.com/visionmedia?tab=activity
- RivieraKid 13y agoI would.
- sergiotapia 13y agoOfftopic: *irregardless is not a word, Just use regardless.
- ehsanu1 13y agoLike it or not, irregardless is here to stay. Languages change, mispellings become the correct way to spell things, words become their own antonyms, and a lot of other very strange things. Embrace it!
- swalkergibson 13y agoI reject your implication. Just because a lot of people use it does not make it grammatically accurate. http://en.wikipedia.org/wiki/Irregardless http://en.wikipedia.org/wiki/Irregardless
- JangoSteve 13y ago> Just because a lot of people use it does not make it grammatically accurate. Actually, that's exactly what it does... over time. Where exactly do you think our language, as it exists today, came from?
- ds_ 13y agoAn interesting read on the subject: http://www.amazon.com/The-Unfolding-Language-Evolutionary-Invention/dp/0805080120 http://www.amazon.com/The-Unfolding-Language-Evolutionary-In...
- swalkergibson 13y agoOf course language evolves, but a double-negative is a double-negative, no matter how you slice it. Do you have another example of a single word that is a double-negative?
- nekopa 13y agoUnless?
- tolas 13y agoYou don't believe in social proof and a history of success?
- dlau1 13y agoIt looks almost like if they rewrote express for generator functions I can't wait to drop this in to one of my projects!
- Gigablah 13y agoSaw something similar in Martini (golang): https://github.com/codegangsta/martini#next https://github.com/codegangsta/martini#next // log before and after a request m.Use(func(c martini.Context, log *log.Logger){ log.Println("before a request") c.Next() log.Println("after a request") })
- bjconlan 13y agoI don't think this yields the current thread/routine though does it? I think what you are seeing here is closer to express': function(req, res, next) { console.log('before'); next(); // go to the next middleware handler console.log('after the middleware stack has been traversed'); }
- andreypopp 13y agoI think does yield as stated in docs. Go have coroutines so there is no need in generators.
- flym4n 13y agoThat's using a callback, like express or connect does. What's new in koa is the use of js generators
- jerf 13y agoGo doesn't need JS generators. It already handles execution flow correctly. It is not correct to assume the Node execution model holds everywhere; we've made a lot of great advances since the old event-based model was invented in the 70s. That actually wraps the full handler without any need to jump through event threading hoops, and is not "blocking", in the sense that the Node community uses the term. That's an out-of-the-box feature for a modern language.
- klibertp 13y ago> That's an out-of-the-box feature for a modern language. Or for any Scheme for the last 30 years, but don't let that change your views on how "modern" you language is :)
- joenied 13y agoI found the GIF on this page explains it pretty good: https://github.com/koajs/koa/blob/master/docs/guide.md https://github.com/koajs/koa/blob/master/docs/guide.md
- bsiddiqui 13y agopretty well
- deleted 13y ago[deleted]