Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Given the choice C++ is way better than C, given that it allows to use higher level abstractions and replace all unsafe C heritage by library based safe constructs.

You may have noticed that C++ is not always deemed universally better than C. What language are all the top web servers implemented in?

C has library based safe constructs as well, and C++ still has all of C unsafety. You just get to exercise those bugs at a higher level of abstraction.

> Of course, the best option would be to replace them by other languages with native compilers.

I think that is anything but clear. Certainly the option of doing so has been around. You just don't see a ton of big moves that worked out well.

> However at the level these languages are used, it will only happen when OS vendors push new languages for their OS.

Most OS's actually have a pretty small API footprint (Windows being the obvious outlier). If it were really just about the language bindings, it would not be a real impediment. A language runtime can abstract out the OS (as the C runtime does).

> So there isn't any OS vendor left that would push new system programming languages for their OS.

I'm going to claim this could well be a function of Darwinian forces.



> C has library based safe constructs as well, and C++ still has all of C unsafety.

The problem C's lacking one of most important primitives - data structures.

Bugs in standard library happen pretty rarely, I guess. So, C++ users have most common data structures for free.

And when I open some C-based project's code the first thing I usually expect and see is some homegrown linked list and/or map implementations (of SIGSEGV fame). I know, there are tons of libraries that offer them, but in my experience of "hey, that server crashed, could you figure out what went wrong"-type tasks, they're very rarely used.


> And when I open some C-based project's code the first thing I usually expect and see is some homegrown linked list and/or map implementations (of SIGSEGV fame). I know, there are tons of libraries that offer them, but in my experience of "hey, that server crashed, could you figure out what went wrong"-type tasks, they're very rarely used.

Fortunately, C++ developers just always use the STL because it is considered the bastion of all that is good in collection classes:

http://www.codeofhonor.com/blog/avoiding-game-crashes-relate... http://engineering.adap.tv/2012/03/29/why-we-use-c-without-u...

Don't get me wrong. I love C++ and use the STL by default, but it's all too rare that I look at a decent sized C++ project and see anything different from what you'd expect if the project were written in C.


I wonder if we will get a GTL a la guava :p



> You may have noticed that C++ is not always deemed universally better than C. What language are all the top web servers implemented in?

Apache and nginx => C

Tomcat, Jetty => Java

IIS => C++/C#

> Most OS's actually have a pretty small API footprint (Windows being the obvious outlier). If it were really just about the language bindings, it would not be a real impediment. A language runtime can abstract out the OS (as the C runtime does).

If developers aren't forced to use it, then they won't use it, even if made available.

> I'm going to claim this could well be a function of Darwinian forces.

That is my hope, after all we only need a few generations of developers and then the issue is taken care of by itself.


> Apache and nginx => C > Tomcat, Jetty => Java

Okay, if you are going to throw in Tomcat & Jetty, you should also throw in the likes of lighttpd, mongrel2, etc., all of which are written in C. Pretty much all the load balancers/reverse proxies are written in C too. Hmm.... is it maybe possible that it isn't always better to use C++ instead of C?

> IIS => C++/C#

Yup, the one outlier no doubt owes about 0% of its success to its tech stack. In general, if you don't work at Google and want a C++ web server on anything other than Windows, you are looking at a C++ server framework that has an embedded HTTP stack (tntnet, Wt, etc.).

> If developers aren't forced to use it, then they won't use it, even if made available.

I know. I spend all my time watching them because if I don't they just start doing everything in assembly.

> That is my hope, after all we only need a few generations of developers and then the issue is taken care of by itself.

I think you missed my point. ;-)


> > Apache and nginx => C > Tomcat, Jetty => Java > Okay, if you are going to throw in Tomcat & Jetty, you should also throw in the likes of lighttpd, mongrel2, etc., all of which are written in C. Pretty much all the load balancers/reverse proxies are written in C too. Hmm.... is it maybe possible that it isn't always better to use C++ instead of C?

No, they were developed by open source Linux guys that only care about C in what concerns compiled languages.

C++ was always badly received by the Linux community, in contrast with commercial UNIXes.

> IIS => C++/C# > Yup, the one outlier no doubt owes about 0% of its success to its tech stack. In general, if you don't work at Google and want a C++ web server on anything other than Windows, you are looking at a C++ server framework that has an embedded HTTP stack (tntnet, Wt, etc.).

Yes, nothing like contributing to have more insecure servers around.

>> That is my hope, after all we only need a few generations of developers and then the issue is taken care of by itself.

> I think you missed my point. ;-)

I surely got your point, but it is not about Darwin of languages, rather of developers.


> No, they were developed by open source Linux guys that only care about C in what concerns compiled languages. > C++ was always badly received by the Linux community, in contrast with commercial UNIXes.

You mean like KDE, Firefox, OpenOffice, OpenCV, VLC, bitcoin... heck even gparted is a C++ app.

The kernel developers obviously have a bias against C++ (and they'd argue that it is a justified bias). User space is a different land.

> Yes, nothing like contributing to have more insecure servers around.

? Not sure your point here...

> I surely got your point, but it is not about Darwin of languages, rather of developers.

> I surely got your point, but it is not about Darwin of languages, rather of developers.

My point was about Darwinian forces applied to language or developers.

I was responding to your point about OS vendors not being left around. It would appear that, for whatever reason, going with something other than C or C++ for your base OS doesn't seem to result in good survival odds.


>> No, they were developed by open source Linux guys that only care about C in what concerns compiled languages. > C++ was always badly received by the Linux community, in contrast with commercial UNIXes.

>You mean like KDE, Firefox, OpenOffice, OpenCV, VLC, bitcoin... heck even gparted is a C++ app.

>The kernel developers obviously have a bias against C++ (and they'd argue that it is a justified bias). User space is a different land.

I use Linux since 1995, and was for some time a Gtkmm contributor in the early days.

I know how it feels to be a C++ developer in Linux land.


> I use Linux since 1995, and was for some time a Gtkmm contributor in the early days. > I know how it feels to be a C++ developer in Linux land.

The GNOME crowd was self selected to be a bunch of "C not C++" bigots. The KDE community was quite different (even if MOQ is an abomination ;-). The only community I can think of that would be more hostile to C++ is the kernel devs.

I don't think your experiences are accurately reflective of the larger community. Particularly as C++ has improved (really, pre-gcc 3.0 there wasn't a good C++ compiler, and pre-2000 hardly anybody understood RAII, so C++ was kind of a pain), the larger community's attitude has changed. You can see this reflected in the success of the Boost project.


Coming from Turbo Pascal background I tend to be very critic of unsafe by design nature of C and C++. Specially given my focus in compiler design during the university, which allowed me to have a broad focus and experience in many languages, the average HN crowd might not be aware of.

Having said this, I was already coding in C++ in MS-DOS around 1993 (Turbo C++) and only used plain C when forced to do so.

So I have been part of the C++ community since the early PC compilers were available, and experienced this C vs C++ for quite some years now.

The funny part is remember the performance complaints back then about C and C++, that nowadays people state in HN about languages trying to replace them.

Oh, and I really like Boost.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: