Live data from Hacker News

Building a Website with C++

blog.sourcerer.io

111–120 of 122 posts

Re: Building a Website with C++

#111
post #40

Really? Escaping, people! This code isn't practical or useful; it's dangerous and sloppy. cout \n"; ... cout \n"; FWIW I wrote an article about HTML escaping and shell here: http://www.oilshell.org/blog/2017/09/19.html Followup: http://www.oilshell.org/blog/2017/09/29.html Also if you want to use a native language for web sites (which I don't), Go is a better choice, as the standard library has html/template which pr…

> In this article, I’ll explain how you can use C++ to develop a website and some concrete reasons why you might consider doing so. I dont find any reasons at all. That article ist just a clickbait nonsens.

"Building a Website with C++" "Is This Even Possible?"

We can just "flag" articles like this one.

Re: Building a Website with C++

#112

Interested parties desiring production quality security and significanlty better performance than CGI, check out the C++11 library Restbed https://github.com/corvusoft/restbed Restbed replaces Apache, or put another way puts the web server inside your application, so your C++ app is its own server. It is easy to create REST APIs with executable as small as 100K, and that is all you need - no Apache or Nginx other web…

Looks great but it's AGPL unless you buy a license.

Sometimes, software is worth paying for...

Re: Building a Website with C++

#113
post #110

Earlier quoted context omitted.

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…

> as something that is noticeably faster to the user

you know, there might be MORE THAN ONE user

so if server is done in, say, python, then user #11 will get slowdown. With C++, slowdown might start with user #50 (or 100, or ...)

Re: Building a Website with C++

#114
post #72

Earlier quoted context omitted.

C++ advocates often talk about the performance gains. The problem with that is that what C++ buys you is not better performance or even predictable performance, but repeatable performance, which is not that useful for anything not hard-realtime. For typical large OO codebase some kind of tracing GC is almost always better than various reference counting and tracking schemes. For the unpredictability the problem has t…

C++ only has repeatable performance if used in certain ways. > various reference counting and tracking schemes. Reference counting doesn't always have repeatable performance. Maybe for a program image started from scratch on exactly the same non-real-time input. But then almost anything has repeatable performance for that, including ordinary mark-and-sweep garbage collection.

My point was that only reason to use C++ is when you want repeatable performance which implies that you will not do things that are against this goal (and in fact C++ makes various tricks to achieve this goal trivial, eg. per-timestep heaps)

My other point was that for anything other you do not want to use C++.

Edit: and also "when used in certain ways" is exactly the problem with C++ I tried to point out. The language and it's interactions with real implementations is simply too complex for any kind of useful analysis.

Re: Building a Website with C++

#115

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

Slashdot started in 1997, the first release of mod_perl was on 12.03.1998. They certainly used cgi at first, just check the url here: https://web.archive.org/web/19980113191337/http://slashdot.o... - it says cgi right there.

Edit: Seems I was wrong about the date, it was actually 28-Jul-1997[1], nevertheless slashdot was only launched two months later, and as the link above witnesses didn't seem to have used it at first.

[1]: https://web.archive.org/web/19971210053529/http://perl.apach...

Re: Building a Website with C++

#116
post #110

Earlier quoted context omitted.

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

> as something that is noticeably faster to the user you know, there might be MORE THAN ONE user so if server is done in, say, python, then user #11 will get slowdown. With C++, slowdown might start with user #50 (or 100, or ...)

Thanks. Yes. I said this very thing in my top comment. It takes a lot of users (many more than 10!) in any modern web server framework to get noticeable slowdowns, unless you've done something horribly wrong. So the question on the table -- still -- is what web applications might actually require a C++ web server, in practice?

Re: Building a Website with C++

#117
post #52
post #40

Really? Escaping, people! This code isn't practical or useful; it's dangerous and sloppy. cout \n"; ... cout \n"; FWIW I wrote an article about HTML escaping and shell here: http://www.oilshell.org/blog/2017/09/19.html Followup: http://www.oilshell.org/blog/2017/09/29.html Also if you want to use a native language for web sites (which I don't), Go is a better choice, as the standard library has html/template which pr…

Yeah... this example code is bad. Not to mention that CGI is slow, problematic, and chock full of potential security issues. At the very least, spawning a process per request is a DOS attack waiting to happen, even if the code were immaculate.

Then I have good news for you !

https://en.wikipedia.org/wiki/FastCGI

Also: DOS attacks against capacity sound positively benign compared to what they translate to on cloud : DOS on your credit card.

Re: Building a Website with C++

#118
post #37

> In this article, I’ll explain how you can use C++ to develop a website and some concrete reasons why you might consider doing so. I only saw one reason: performance. Did I miss some? Do people have other good use cases that justify paying the dev cost of using C++ for a web server? I'd guess with caching and a decent backend, it would be fairly hard to demonstrate a true need for performance that requires C++, but…

Wouldn't this have very similar performance characteristics to something like serverless functions on Amazon/Google cloud ? (assuming using same language)

Re: Building a Website with C++

#119
post #11

Earlier quoted context omitted.

Might want to integrate an existing C++ code base into a server without developing an API or IPC in between the two. The security issues would be similar in either case and this would be much quicker to develop.

this would be much quicker to develop. There is almost literally no chance that this is the case. The amount of pointless boilerplate code that you'd have to write would be many, many, many times in excess of a thin API layer.

How do you suggest writing a thin API layer to expose an interactive real-time stream consumed over WebSocket?

Re: Building a Website with C++

#120
post #52
post #40

Really? Escaping, people! This code isn't practical or useful; it's dangerous and sloppy. cout \n"; ... cout \n"; FWIW I wrote an article about HTML escaping and shell here: http://www.oilshell.org/blog/2017/09/19.html Followup: http://www.oilshell.org/blog/2017/09/29.html Also if you want to use a native language for web sites (which I don't), Go is a better choice, as the standard library has html/template which pr…

Yeah... this example code is bad. Not to mention that CGI is slow, problematic, and chock full of potential security issues. At the very least, spawning a process per request is a DOS attack waiting to happen, even if the code were immaculate.

What is lambda?
Post reply on HN