These are chat archives for jdubray/sam

8th
Sep 2016
Fred Daoud
@foxdonut
Sep 08 2016 10:06
@devinivy @jeffbski @jdubray do have any opinions about koa?
devin ivy
@devinivy
Sep 08 2016 12:44
comparable to express/connect, but uses the futuristic async/await. i've stayed away from it for similar reasons i don't use express– middleware just isn't ideal for writing modular web services or plugins that interoperate with each other.
but i totally wouldn't diss it. it's much lighter than other options, and i think it's quality.
i would go to koa before express, personally. the community is "healthier" (not just bigger), i think.
i also avoid using features of js that are not in latest node.js, so async/await is off the table (for now).
Fred Daoud
@foxdonut
Sep 08 2016 13:47
@devinivy nice assessment, thanks! I used koa for meiosis examples, but it's a very basic server, just to have an example with a back-end. I chose koa because it was simple. I haven't used it (or any other node library) for a real-world server.
Jeff Barczewski
@jeffbski
Sep 08 2016 20:21
The async/await feature makes the code pretty clean for doing lots of async stuff. You can do all of the same stuff with promises (which is what it uses under the covers) but with promises you have to declare variables outside of your current function scope to pass data between functions, where as with async await you don't have to do any of that nonsense. I think the transpiled implementation of async/await for generators is ok so you might be able to get away with using it in environments where generators are available. I'm told that if you don't have generators and you are using the regenerator code for transpiling to ES5 then the resulting code is hideous and contains a bunch of massive loops so I don't know that I would trust that for production. Obviously it will be much better when natively supported and you don't need any transpilation. I really like hapi, but if you wanted to use something else like koa, I'd try to see how it is holding up on any reasonably heavy uses, to see how stable or production ready it is. In my younger years I would have a go at it trying all the latest things, but now that I am older, I let other people debug these new platforms/features. I only use them once they've gotten most the bugs out of them. I do use plenty of the new ES syntax though in the cases where it transpiles nicely into simple code, but async/await and generators are not on that list.
Jeff Barczewski
@jeffbski
Sep 08 2016 20:27
Another thing that I found nice with hapi is that you can setup a bunch of pre-requisites for a route along with server methods and then you can have hapi do lots of fetching and resolving for you in parallel or serial and then only call into your function when it has the data. So once you do that you eliminate the need to have all that async/await stuff, hapi has done all that for you. It's a little bit to learn, but once you do it's really powerful.
devin ivy
@devinivy
Sep 08 2016 20:36
yes!! love pres. you can also perform ACLs in there without having to dirty your handlers or your authentication strategy.
Fred Daoud
@foxdonut
Sep 08 2016 22:58
thank you @jeffbski that is interesting and insightful. if I was in a situation of writing a "real" back-end with node, I'd certainly consider hapi. I used koa for a very simple example -- and in fact, I replaced it with a fake sinon server for running the examples online :)