I run https://byuu.org using C++. Not just for page generation, but also for the server itself. It's all a single package, so no CGI is involved. Although I do use nginx as an HTTP->HTTPS proxy because TLS is scary. It's handled being linked on the front page of a few major sites with no issues. In my case, I just prefer coding in that language over PHP et al. It's on a $2.50/mo VPS and I can spawn a new instance in…
Building a Website with C++
81–90 of 122 posts
Re: Building a Website with C++
#82Earlier quoted context omitted.
Classic CGI is not the best performing interface, yes. But there's a big difference in launching a complete interpreter for every request, and running a small purpose-built native program. And remember that people did manage the former 20 years ago, sites like Slashdot were running CGI Perl scripts back then. I'm not sure about the "chock full of potential security issues". You have to be careful with trusting enviro…
Forking a process per request is expensive, interpreter or not. Slashdot used apache mod_perl back then. It never forked a process per request.
Re: Building a Website with C++
#83I run https://byuu.org using C++. Not just for page generation, but also for the server itself. It's all a single package, so no CGI is involved. Although I do use nginx as an HTTP->HTTPS proxy because TLS is scary. It's handled being linked on the front page of a few major sites with no issues. In my case, I just prefer coding in that language over PHP et al. It's on a $2.50/mo VPS and I can spawn a new instance in…
Oh hey, you are still using Vultr? How have they been? I'm pretty sure I'm the one who suggested it some years ago on the forum and have wondered ever since if the at least then-unproven VPS company ended up being reliable. It looks like their prices have stayed competitive at least!
It’s super simple UI to start an instance with a basic script (like update distro and developer tools etc). Lastly, you can pass in your pub keys and just ssh directly without doing it yourself the moment you log in for the first time.
All in all highly recommend it!
Re: Building a Website with C++
#84Its always interesting to see C++ but as someone else mentioned I expected to see Wt. If I want nearest to C++ speeds I rather go with D (using vibe.d) or Rust. C++ isn't my area of expertise though but those two other languages are years more approachable for me personally. Not saying I could never do C++ though. I know OkCupid is C++ using Wt iirc. I wish they'd give D a try or Rust to see how much more productive…
Why would you assume that D or Rust would be make developers more productive? If the developer already knows C++, then switching to D or Rust would make the developer significantly less productive over six months to a year, after which, the developer would likely be just as productive as he/she was when writing C++. Languages are not panaceas. Rust and D are both hard languages, as is C++. Selecting one of these only…
Because D is very obviously C++ but better. Rust isn't, though. But D, down to the very name, has lots of things that appeal to C++ users. It has advanced metaprogramming, is multiparadigm, it compiles down to machine code, and has very similar syntax to C++.
D has had other influences, but it is written by C++ compiler writers who think they can do better than C++. I say this as someone raised on C++ and who is now trying D. It is a very natural progression to make, if you're inclined to try something new.
Furthermore, Vibe.d is kind of a burgeoning "killer app" for D. D's package manager, for example, was originally made for Vibe.d. This isn't the only way in which Vibe.d has influenced D development. Vibe.d is one of the most popular D libraries. It's the only D library I know that has its own published book,
https://dlang.org/blog/2017/09/13/the-making-of-d-web-develo...
Re: Building a Website with C++
#85Earlier quoted context omitted.
If you say that C++ is not memory safe you really don't know the modern C++. Of course you can use only `void *` everywhere... but you can also write your software in a totally different way. My C++ code has no pointers, just objects, which are automatically destroyed when I want to. The nice feature is that I know when the destructor is called, so the object will clear itself in a very nice way.
It's futile battle though to achieve both performance and safety in C++: as an example, safety requires avoiding moves, using reference counting, while achieving performance means avoiding copies and passing occasional references around, among other things. That's why advertising C++ solution as fast does not work well with "but C++ can be safe too!".
Rust is essentially a bet on the impossibility of working around that trade-off in C++. And they are right, it is impossible to close that gap completely. C++ simply doesn't have the language features to enforce all necessary ownership rules without a performance penalty.
But I see trouble on the horizon for Rust, because that gap is quickly shrinking to its formally irreducible minimum as more C++ libraries are adopting a "modern" style. What's left of that gap may be too small to fit an entire new programming language built around fixing this single issue.
Re: Building a Website with C++
#86Using CGI is silly and slow, for all but the simplest, stateless servers. If one wishes to avoid the overhead of learning a new framework, at least FastCGI should be considered. A relevant (but dated) discussion about web frameworks in C++ can be found in [1]. I am personally a big fan of CROW [2] and have used it many times in the past. [1] https://softwareengineering.stackexchange.com/questions/5362... [2] https://…
CGI isn't slow -- starting interpreters is slow. Starting Python or Ruby can easily be 1000x more expensive than starting a process in C, which takes MICROSECONDS, not hundreds of milliseconds. See this 7 year old message by Richard Hipp (of sqlite): https://www.mail-archive.com/fossil-users@lists.fossil-scm.o... https://news.ycombinator.com/item?id=3036124 This server takes over a quarter million requests per day, 1…
Re: Building a Website with C++
#87Earlier quoted context omitted.
You missed IoT. Preferably one would use some kind of network protocol with a native management console, but nowadays it is fashionable to have a mini webserver exposing a Web UI instead.
> You missed IoT. I did? I just read the article again, and I don't see any mention of IOT or small or embedded devices aside from Docker, can you point me to what you saw? The article is assuming Apache is running...
> Do people have other good use cases that justify paying the dev cost of using C++ for a web server?
Re: Building a Website with C++
#88Earlier quoted context omitted.
> You missed IoT. I did? I just read the article again, and I don't see any mention of IOT or small or embedded devices aside from Docker, can you point me to what you saw? The article is assuming Apache is running...
I was replying to your question, which I should have quoted. > Do people have other good use cases that justify paying the dev cost of using C++ for a web server?
Re: Building a Website with C++
#89Earlier quoted context omitted.
Oh hey, you are still using Vultr? How have they been? I'm pretty sure I'm the one who suggested it some years ago on the forum and have wondered ever since if the at least then-unproven VPS company ended up being reliable. It looks like their prices have stayed competitive at least!
I’m using vultr now and I vastly prefer it over Linode (I’ve yet to fully try DO). It’s super simple UI to start an instance with a basic script (like update distro and developer tools etc). Lastly, you can pass in your pub keys and just ssh directly without doing it yourself the moment you log in for the first time. All in all highly recommend it!
Remarking on that, Digital Ocean is nothing special, but they have added some nice features in the past year or two. I like that their control panel supports multiple teams with permissions, I like that it has a nice tag-based firewall, the DNS service works fine, and it has an S3 clone called Spaces which is pretty handy. I believe they also announced recently that private networking would be isolated per-team instead of being the entire data center, another networking improvement that most low-end VPSes do not provide.
All in all, if you just need a low end VPS, I would say there's no fault in going with something like Vultr, but Digital Ocean adds a few extra features that might be more useful if you're developing a medium-complexity system. Of course though, at that point, you probably want to at least consider Google Cloud Platform, a reasonably cost-effective host with very rich features. (And AWS, but my feelings for AWS have shrunk in recent times after having better experiences with GCP consistently at my day job.)
Re: Building a Website with C++
#90I run https://byuu.org using C++. Not just for page generation, but also for the server itself. It's all a single package, so no CGI is involved. Although I do use nginx as an HTTP->HTTPS proxy because TLS is scary. It's handled being linked on the front page of a few major sites with no issues. In my case, I just prefer coding in that language over PHP et al. It's on a $2.50/mo VPS and I can spawn a new instance in…
Oh hey, you are still using Vultr? How have they been? I'm pretty sure I'm the one who suggested it some years ago on the forum and have wondered ever since if the at least then-unproven VPS company ended up being reliable. It looks like their prices have stayed competitive at least!
Pretty great. Infinitely better than anyone else I've ever used (especially InMotion Hosting that corrupted my SQL database, and misconfigured Apache to return my PHP source code to every visitor.) Not perfect, but very reliable uptimes.
If I had to nitpick:
The New Jersey instance lost the ability to reach it over IPv6. Their support staff wanted root access to my box to take a look. Nice that they were willing to do that, but I just moved to Chicago instead. IPv6 with the exact same configuration works fine there.
Their two-factor authentication does not allow SMS as a backup option. I don't like printing out codes.
Like everyone else, their bandwidth scaling is really poor. You have to scale up your entire server, even if you really don't need the CPU, memory or disk space. The price increases quadratitically while the bandwidth increases linearly.
You have to e-mail them your driver's license or something to enable SMTP. I think their fine print says they'll fine you $250 for every spam mail you send or something scary like that.