Javascript Interface Design & # 8596; C ++ backend

In the near future I will need to create a system with a C ++ backend and a web interface (requirements). At the moment, I do not know more about this. I think that Frontend will trigger data delivery, not a backend, so there is no need for comets.

Due to my little experience in this area, I would really appreciate your comments on the design decisions I made.

First of all, I don't like the ability to generate HTML from C ++. Thus, the C ++ backend should interact with the Javascript interface. The simplest option that I see here is Ajax. I think that so far everything is in order.

Ajax communication with C ++ - the backend means that the backend must be able to handle HTTP. It would be nice to split the backend that provides the actual data from the HTTP processing functions.

Here I see a place for Node.js. I got a review, and this is the place where all my doubts lie.

To have an HTTP processing server on Node.js that will have a "database" as the Node.js module? I think this should be fine, but I'm not sure that I really need all this asynchronization, so there may be some simpler options that I don't know about? How would you create such a system?

Thanks in advance.

+4
source share
2 answers

β€œAll this async” is not something that Node.js is very difficult to provide as an extra. This is a different look at a web service that breathes easily when you understand how Node.js works.

For example, my colleagues need a way to wrap a C ++ program as a web service, but the program had a significant initial cost, so they wanted to run only one instance of the program that runs in a loop, serving all web requests. Everything in Node.js took up less than two screens.

A wrapper for one program invoked for each request can be executed in less than ten lines of Node.js. Don't think of asynchrony as work - if you hug it, Node.js is awesome.

However, you can go the CGI route and do it in a more standard way, and the end result will be almost the same. This may or may not come in handy.

+3
source

Have you considered the option of a CGI / FCGI module with nginx, Apache, etc.?

If not, then I think it makes sense to start with it. Your module will handle the / json data request, and the rest will be processed by the HTTP server.

0
source

All Articles