Server Side JavaScript

I'm looking to replace PHP with something better (everyone seems to say that PHP is evil, right?) And given server-side JavaScript.

node.js seems very popular, but I'm afraid that I will go down with asynchronous stuff. Is it possible to write regular (synchronous) code under node?

My whishlist: web scripts and command line, good performance (in Computer language
Benchmarks Game , V8, apparently, is an order of magnitude faster than PHP), preferably developed by a company or community, so it won’t just be removed someday, a user community with a decent library of modules.

I do not consider various Rhino-based frameworks, since Rhino works in Java, and I am not in Java, I don’t know how this happens with memory, and the whole idea of ​​compiling javascript in java does not make any sense to me.

I spent some time searching and found many projects: Myna, Meteor, GromJS, APE, GLUEscript, v8cgi, silkjs, wakanda, GPSEE, sorrowjs, ejscript, Persevere, PhantomJS.

Does anyone have experience with them? Any recommendations are appreciated.

+6
source share
5 answers

Good Node.JS is the way to go if you ask me. You can write synchronous code, but only in command line scripts. When writing web servers, you need to go through an asynchronous route, otherwise it will not run because JavaScript is single-threaded and everything stops.

The reason Node.js is so great is due to asynchronous I / O.

You will get used to callbacks and events, and after a while you will not want to return.

Node.js is a platform built into the JavaScript JavaScript runtime to create fast, scalable network applications. Node.js uses an event-driven, non-blocking I / O model that makes it lightweight and efficient, ideal for applications that use real-time data intensively that run across distributed devices.

+5
source

Meteor Built on top of Node.js and growing fast.

In Meteor, the server code runs in a single thread for each request, and not in the asynchronous callback typical of Node. We consider the linear execution model more suitable for typical server code in the Meteor application.

UPDATE After a year - Why Meteor

+5
source

Have you looked at Server Side JavaScript Comparison ?

Node.js is popular. Regarding php speed, have you looked at HipHop ? Rewriting code in javascript will probably not give a big increase in php performance.

+4
source

Nodejs is a very good option on many fronts.

But you say that you are concerned about its asynchronous nature.

Two points on this.

  • you don’t need to worry about async and keep writing the application from top to bottom, like PHP. This is if you are not doing an "I / O lock".

  • If you are doing an “I / O lock”, such as reading a database or accessing the file system, then you will need to handle asynchronous requests. Fortunately, there are good ways to do this without having to change your coding methods too much.

+4
source

Thank you for providing a list of the “numerous projects” that you have found. We are currently using Microsoft ASP 3.0 ("Classic ASP" included in IIS), which has been providing server-side implementation since 1996 - it is fast, mature and thanks to COM technology, which is quite extensible. If you're not tied to open source, it's worth a look. For our open source strategy, we will take a closer look at SilkJS.

+3
source

Source: https://habr.com/ru/post/920505/


All Articles