Koa – Next-generation web framework for Node.js
koajs.com
koajs.com
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)> 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.
This might be one of the very few instances that "next generation" is a valid statement.
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
Actually, that's exactly what it does... over time. Where exactly do you think our language, as it exists today, came from?
ex:
"Ther nas no man no wher so vertuous" ("There never was no man nowhere so virtuous")
"He nevere yet no vileynye ne sayde / In all his lyf unto no maner wight" ("He never yet no vileness didn't say / In all his life to no manner of man").
The modern English language (written and spoken) has been in constant flux for the last 600+ years. What was once required is now antiquated, and what was once verboten is now required.
At this moment in time, double negatives are frowned upon. However, that may change in the future, and it's possible that irregardless is the start of a new set of changes in the language.
It's worth noting that neither of your examples has a double negative. Triple negative (the second possibly quadruple), sure, but not double.
> At this moment in time, double negatives are frowned upon.
I don't know that there's really a shift in time with the double negative, its a stylistic rule, and, much like the Pirate Code, stylistic rules in English are more what you'd call guidelines than actual rules.
Or, looked at another way, more like training wheels.
Nowher so bisy a man as he ther nas [0] (Nowhere so busy a man as he there none)
[0] http://www.bartleby.com/40/0102.html line 321
Irregardless, it's not about being grammatically correct, but being socially accepted and understood; just like slang and broken grammar that develops in subcultures, it ain't no goin anywhere!
I can't wait to drop this in to one of my projects!
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")
}) function(req, res, next) {
console.log('before');
next(); // go to the next middleware handler
console.log('after the middleware stack has been traversed');
}Or for any Scheme for the last 30 years, but don't let that change your views on how "modern" you language is :)
* stack traces of errors are useless? [1]
* missing catch filters/pattern matching i.e. catch (e) {} also captures type, reference and range errors i.e. "pokemon exception handling"?
[1]: http://spion.github.io/posts/analysis-generators-and-other-a...
It doesn't seem like they are useful yet:
1. The FAQ gives a political answer about the status of Express but I imagine that Express will not be actively maintained any more. Correct?
2. If focus is now on Koa, why the name change from Express when it is already a huge name for node frameworks?
3. If a new developer sees Express and Koa, would they immediately know which one is being focused on?
Basically I'm wondering why it couldn't be called Express 3.0 (or 4.0).
I guess I'm more concerned about the marketing of this framework as there's now two names for the same thing except one is newer than the other. As a dirty analogy - if jQuery started to support yields instead of function callbacks, do they change the name of the library?
Looking at the syntax of Koa, it's still express except it looks nicer because there's no callbacks. What was the reasoning for ditching the big name? It can't be just for that.
I also see pull requests getting merged into Express.js on almost a daily base. So I am not really worried about it dying anything soon. Most of the road map items for express are about extracting it's features into separate modules as well. Which means they are aiming at making the Express core even smaller and less opinionated.
EDIT: Answer: that's how "generator functions" are recognized. http://wiki.ecmascript.org/doku.php?id=harmony:generators
app.use(function *(next){
^
SyntaxError: Unexpected token *
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3Or use gnode, which will down-compile it to ES5 for current stable node.
It seems Express and Connect? http://stackoverflow.com/questions/3809539/choosing-a-web-ap...
And Express sits on top of Connect.
Koa is likely to replace Connect [0].
[0]: https://twitter.com/tjholowaychuk/status/369868946989535232
What other values can I yield, and why would I want to?
Alternatively, couldn't the `next` object just be a plain continuation?
in compiled languages it is a compile time error. So you don't run through 1/2 of your application before you run into it. Instead it shows up as soon as you run make/gcc/g++/etc.
E.g. if you use JSHint, you'd get:
"Expected a conditional expression and instead saw an assignment."
Nowadays, there usually isn't any benefit in using yoda conditions.
var test = [
"firstitem"
, "seconditem"
//, "thriditem_commented_out"
//, "fourthitem_should_also_be_commented_out"
]
Otherwise you have to do this: var test = [
"firstitem",
"seconditem"//,
//"thriditem",
//"fourthitem"
]
It's just a lot more cognitive overhead to not put the comma first.if (user.isAuthenticated) doSomething()
vs
doSomething() if (user.isAuthenticated)
the first is less readable perhaps but I think it's more useful for a programmer. To each their own! Maybe some day I'll be convinced otherwise, I like it better for asserts too:
assert(200 = res.statusCode) assert('application/json' == res.headers['content-type'])
assert(res.headers['content-type'] == 'application/json')
looks weird to me now but maybe I'm just used to it
http://iampaddy.com/lifebelow600/
http://uxmyths.com/post/654047943/myth-people-dont-scroll
http://www.marketingexperiments.com/blog/analytics-testing/w...
I had to work with express, and one thing that I missed was having a Response object where you build your response and then pass back to the framework at the end of the request. So I built my own proof-of-concept-framework to understand why others don't do it (maybe it was just not possible).
Many people will tell you that there are a thousand frameworks out there, go contribute to one of those instead of creating more noise. For me doing a framework was a great way of learning the internals of node, the kind of things that frameworks are designed to hide away from you. Go for it, start your own open source framework and put your ideas into practice. The ecosystem is still maturing.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guid...
but there aren't any comparisons yet.
Node developers go home and fuck the prom queen.