6 ms·
For a ssjs implementation to win my heart this is how I would like to code my apps: require session,models,template function main(request,response){ s
by Kilimanjaro 16y ago
For a ssjs implementation to win my heart this is how I would like to code my apps:
require session,models,template
function main(request,response){
session.start()
data = models.getEntries()
html = template.render('blog',data)
response.write(html)
}
Can not be simpler, hide all complexities from the coder so he can concentrate on building apps, not fighting with code.
- aaronblohowiak 16y agoYou can get close with expressjs
- Kilimanjaro 16y agoI like it, it can be humanized a bit more like: var app = express.Application(); // let me create apps, not servers app.get('/', app.do('index',req,res)); app.run(); // set port in config.js I'll keep an eye on express.
- foenix 16y agoI can give express a thumbs up. I came from a python-flask environment, and express provided a way for me to quickly get the gist of javascript object-models and message passing. (I'm not a CS guy, I just wanted to finish a digital art project involving buses and geolocation).
- yesbabyyes 16y agoCombining express with http://jashkenas.github.com/coffee-script/ http://jashkenas.github.com/coffee-script/ makes it really terse.
- mishmash 16y agoLet's see, braces and parens but no semi-colons, almost. ;)
- armandososa 16y agodata = models.getEntries() html = template.render('blog',data) I may be wrong, but these two lines has to be blocking
- Kilimanjaro 16y agoThat's the whole point, I don't care, hide that complexity from me. I can't render the page unless I have the data and I don't want to deal with callbacks, coroutines, monads, or what not, so I'll wait patiently for the data to come back.
- deleted 16y ago[deleted]
- armandososa 16y agoWell, yeah, I'd like to see that too. Just like ruby or PHP, only with JavaScript syntax. Sorry for pointing the obvious;
- isntitvacant 16y agosomething like this: var session = require('session'), models = require('models'), template = require('template'); function main(request,response){ session.start( models.getEntries.bind(models, template.render.bind(template, 'blog', response.write.bind(response)))); } would be easy to put together with node.js; it's functionally equivalent to the above (though it assumes that data comes into the template.render call as the last argument(s)), and neatly avoids too much nesting.
- Detrus 16y agoBig discussion on that here http://news.ycombinator.com/item?id=2101210 http://news.ycombinator.com/item?id=2101210 Ryan was developing Node for certain use cases. He chose the name "Node" because it was supposed to be a small piece of a larger web app. A few nested callbacks, programs that have a few hundred lines of code and don't have complex control flows work well. Hype created a large community which is pushing beyond such narrow goals. But it will take time to come up with good DSLs or add continuations to V8. For now the best solution is to learn how to organize async code, for which I've only seen one trivial example.