Live data from Hacker News

Building a Website with C++

blog.sourcerer.io

101–110 of 122 posts

Re: Building a Website with C++

#101
> I know it sounds strange, and perhaps even an exercise in novel futility, but it isn’t.

Oh come on, C++ is a systems programming language and certainly can handle this, so “futility” seems over the top. Hell, you can write cgi handlers in assembly.

Around 94 I wrote Cygnus’ web interface (and then cron job too) to our big system in sh. Sure, I wouldn’t make the same choice today, but it’s hardly absurd.

Re: Building a Website with C++

#102
post #87

Earlier quoted context omitted.

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?

Most router admin panels are probably written in C++

> Most router admin panels are probably written in C++

What makes you say that? The modern routers I've used all run a full embedded Linux like BusyBox, and they have no need for compiled high performance panels. It'd be more expensive and less portable to write the admin panel in C++, and I can't really think of any strong benefits that would make it worth using C++. I would have assumed they run a scripting language. But I'm checking some of the OS projects now instead of assuming.

Poking around, I see that Tomato is a busybox distribution, all the Linux tools including httpd are C (not C++), and the admin panal pages are .asp (written in VBScript).

DD-wrt appears to have PHP admin panels.

Looks like Asuswrt-Merlin uses .asp.

M0n0wall is all php.

Let me know if you find one with admin panels in C++, I'm interested.

Re: Building a Website with C++

#104

Earlier quoted context omitted.

I know it's more than that. But what you can't do, in my opinion, is love Rust for its other modern features and merely tolerate the new approach to memory management. Memory management in Rust is so dominant in terms of syntax and in terms of restrictions imposed on common idioms that it must be either embraced or rejected wholeheartedly. This is just my personal opinion obviously, not any sort of truth or predictio…

Yeah, I totally hear you. I shared that opinion too, but, surprisingly enough, it seems to some degree that that's in the minority. Or at least, there's a pretty significant number of people who do "love Ruts for its other modern features and merely tolerate the new approach to memory management." I feel that way myself now, but figured that I was just too close to have a mainstream opinion about it :)

That's good to know. Perhaps I just need more practice then.

Re: Building a Website with C++

#105
post #97

Pion[0] is a fairly robust and well-written HTTP server implementation in C++. You can spin up a server very quickly and reverse proxy through Apache or Nginx. Microsoft has a cross-platform offering of some sort in the works using C++11, now I don’t remember the name but I think Herb Sutter has a write-up in it from a couple years ago. It’s definitely possible to write modern web applications in C++, I feel like the…

> Microsoft has a cross-platform offering of some sort in the works using C++11 Casablanca, but I'm not sure how active is the project nowadays.

It's called the C++ REST SDK (https://github.com/Microsoft/cpprestsdk) now and is fairly active. I've used it client-side and I've really enjoyed it.

Re: Building a Website with C++

#106
post #87

Earlier quoted context omitted.

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?

Most router admin panels are probably written in C++

Many are written in shell, terrifyingly, usually running as root.

Re: Building a Website with C++

#107

Earlier quoted context omitted.

Rust is more than just safety though. We had a huge community discussion last year: https://brson.github.io/fireflowers/

I know it's more than that. But what you can't do, in my opinion, is love Rust for its other modern features and merely tolerate the new approach to memory management. Memory management in Rust is so dominant in terms of syntax and in terms of restrictions imposed on common idioms that it must be either embraced or rejected wholeheartedly. This is just my personal opinion obviously, not any sort of truth or predictio…

Two main components of Rust's approach to memory management are i) the imposing/exploiting of scope lifetimes on objects and references, and ii) the restriction that a mutable reference may not co-exist with any other references (to the same object).

I suggest that with C++ there is kind of the option of embracing the former, without so much of the latter, to achieve a performance-safety combination that is closer to Rust's than current "modern C++" practices. That's sort of the premise of the SaferCPlusPlus library [1]. If you're a C++ programmer, the barrier to adoption is low. Though without a "borrow checker" or something equivalent, you wouldn't be able to match Rust's performance-safety combination in all cases.

[1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus

edit: edited the link

Re: Building a Website with C++

#108
post #90
post #81

Earlier 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!

> Oh hey, you are still using Vultr? How have they been? 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 t…

>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.

...Wow. The other stuff is par for the course really, but that sounds, a bit insane.

On the other hand, I assume (hope?) they just mean port 25 stuff, not encrypted SMTP...

Re: Building a Website with C++

#109
post #64

Earlier quoted context omitted.

The performance would be notable. However, hardware is cheap these days.

> The performance would be notable. Can you quantify & explain what you mean by notable? I've written a lot of C++ and also a lot of scripted web services like node.js and flask (python). For most normal websites, I doubt that you could make significant and noticeable performance improvements to a decent scripted backend by switching to c++, from the user's point of view. A latency savings of a millisecond or two acr…

What exactly is the "performance" you're talking about? How you define it?

Re: Building a Website with C++

#110
post #64

Earlier quoted context omitted.

> The performance would be notable. Can you quantify & explain what you mean by notable? I've written a lot of C++ and also a lot of scripted web services like node.js and flask (python). For most normal websites, I doubt that you could make significant and noticeable performance improvements to a decent scripted backend by switching to c++, from the user's point of view. A latency savings of a millisecond or two acr…

What exactly is the "performance" you're talking about? How you define it?

> What exactly is the "performance" you're talking about? How do you define it?

You can see that that was precisely my question, right? Did you mean to reply to the parent comment? The article says the reason to use C++ over rails or node or another scripting language is "performance", the parent comment to mine said that the performance difference would be "notable". I'm asking exactly what you're asking -- what is performance, what is notable?

On top of that, I did define performance loosely in my comment -- as something that is noticeably faster to the user. If a user running Chrome can feel the difference on a site, and the only difference is the language it was written in, then I could buy that C++ gives better "performance". I suspect it's rather difficult to write a custom C++ web server and make it load or run any faster, from the point of view of the person on the other end, than a generic rails/flask/nodejs web site, for most sites.

Post reply on HN