Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    rows = db.select('users')
instead of callback spaghetti monster (CSM)

    db.select('users',function(data){/*callabck*/},function(error){/*error*/})
I guarantee you 90% of (CSM) could be avoided if node wasn't so anal about everything being async.

90% of the time I need the template when I read it

    view = template('index.html')
90% of the time I need the file I am reading right away

    text = getFile('setup.yaml')
90% of the time I need the content of a url right there

    html = webget('google.com')
So why design a language for the 10% of the use cases?

Fork it, drop the (CSM) stuff and conquer that 90% who would like to use JS on the server.



Most of the fs calls have sync equivalents, but you only want to use them at application startup.

IO is slow, Node is evented IO, the requests come in and the requests (to the database) go out, the data comes in and the result is rendered to the client. Node deals with requests.

But let's say it was made to work like you request, and the docs were changed to reflect that. People learn they could throw some code in a file and call it node.js. (I've done that, using a fastcgi server implementation and adding a hander for it on a bluehost account.)

So now you have PHP but with Javascript as it's syntax, your developers build applications the way they do in PHP, you call Node slow and a thread like this launches on HN saying how bad the language is and how somebody should fix that.


I've never heard of people complaining of PHP being slow. They don't care, they just want to glue some HTML, CSS and JS together and run it on the browser easily.

So yes, simplify JS on the server to act like PHP and use node for servers and other stuff. Name it differently if you want so they don't call node slow. V8CGI is the closest to a deliciously simple JS implementation on the server I've seen. Take a look at it for some ideas.


Maybe you would be interested in trying gevent (Python library)?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: