6

Alright so I've been thinking of taking my skills to the next level and would like to know a few things from PRO C++ DEV out there

1. Is it possible to set up a production level web server with c++, if so why don't i see many and why are there so many with nodejs etc..

2. Client side web pages without Javascript, possible?

3. Well I forgot the other questions I wanted to ask, if I do remember you'd be able to find them in the comments

I believe in a single universal language for coding, hence I place forth such questions

Comments
  • 2
    There's plenty of C++ webserver frameworks like wt, cppcms, treefrog, etc etc. I recently used Crow which is based on Python Flask.
  • 2
    1. Yes it is possible but unless you have very specific requirements it is probably a better idea to use a higher level language (productivity matters a lot)

    2. Javascript is the only language which is supported by all major browsers, if you want to use something else you need to either write plugins for the browsers you wish to support (Although modern browsers have started to phase out plugins support since it is a bit of a security problem) or transpile the code to javascript (Which means you would still technically be using javascript, just not directly)
  • 0
    @g-m-f looks inefficient to me.. Id rather use Javascript
  • 0
    @ItsNotMyFault

    Will it offer me any benefits to build my server in c++, like speed, etc.. Over the other languages
  • 0
    @g-m-f well I hadn't given use cases a thought, nevertheless it is 'literally' inefficient
  • 1
    @g-m-f when you put it that way...
  • 3
    1: NodeJs is actually written in C++ and you can write your own c++ modules wich you require from Js
  • 0
    @TheAnimatrix If you're good at C++ and use a modern compiler you might get a tiny bit of extra speed compared to for example Java or C# but it is unlikely to be relevant, The most common web bottleneck is at the database layer (executing your code 2 nanoseconds faster isn't all that relevant when the database needs 200ms to return the result of your query).

    I would only consider C++ if you are building microservices and then only for services that do a significant amount of work with in memory data.

    and even then i would first look if there are any modules/extensions for a high level langauge to handle it. (languages like Python, PHP, Lua, C#, etc can all use modules/extensions written in C (or C++) and tend to have such modules for cpu intensive tasks (i.e, image processing).

    In many cases it might also be a far better idea to use something like CUDA for such tasks (which means you can use a high level language like python with numbapro and do the heavy processing on the GPU)
  • 0
    1. Generally is not worth it. Web technologies are very bloated (open and close TCP request, HTTP is a text based protocol, Websockets design) so the performace gain in most cases is differential. Also portability of networks stuff is not standard, but it is not a big deal because who wants yo build a server other than linux?. The last reason is due you like the language itself. C++ is a good languages with a lot of good features for abstractions. When I program in other langs I miss some of these features a lot.

    2. Wasm will open a lot of possibilities to use other languages without dealing with javascript. Currently I'm transpiled C++ to javascript using emscripten.

    i am also fan of the idea of the one jniersal language but in practicr the best approach is having two languages. One scripting for fast development abd one strong typed compiled language for serious stuff. my chooses are PHP and C++
Add Comment