News for hackers. Stuff that matters.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by utopcell on Wednesday December 12, 2018 @08:06PM (#18669091)
The author is not an unknown entity. ZeroMQ is one of the highest performing brokerless MQs, if not the highest. I do remember that the main pain points were wrt STL and not C++ (but it's been a while since I read that post.) Other people you might respect have tasted C++ and bailed on it (eg Linus Torvalds.) For me, going to a template-less world would be a nightmare.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by jdashg on Wednesday December 12, 2018 @08:42PM (#18669263)
My respect for Linus does not extend to his opinions on programing languages. I haven't found any of Linus's objections to C++ compelling. I strongly believe that a C++ kernel developed with the same care as Linux would be strictly more robust. There are simply more and better tools for constraints and engineered safety in C++.

Besides arguments about portability, C's only "advantage" vs C++ is a lack of features. This isn't an advantage for a serious engineering project, or really any project with code review.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by dymk on Thursday December 13, 2018 @12:40AM (#18670106)
And if you're looking for an example of a kernel being developed in C++, look at Zircon [1] (the kernel for Google's Fuchsia project). It's certainly past the "trivial complexity" phase, and doing just fine.

And of course, things like RAII are incredibly useful when managing resources, and templates for encapsulating generic data-structure behavior in an operating system.

[1] https://fuchsia.googlesource.com/zircon

Re:Why should I have written ZeroMQ in C, not C++ (2012) by kevindqc on Thursday December 13, 2018 @11:41AM (#18673664)
I didn't spend much time looking at it, but to me the code looks more like C than C++ lol

https://fuchsia.googlesource.com/zircon/+/master/kernel/incl... https://fuchsia.googlesource.com/zircon/+/master/kernel/kern...

Even things like SpinLock, which I was expecting to use class for RAII, looks like it was implemented using C, then with a C++ wrapper: https://fuchsia.googlesource.com/zircon/+/master/kernel/incl...

So to me (I'm no C/C++/Kernel/etc. expert) it looks like they are writing the kernel mostly in C, with C++ goodies sprinkled in some places, where it's useful (ie: RAII for spinlock guard)

Re:Why should I have written ZeroMQ in C, not C++ (2012) by maxlybbert on Thursday December 13, 2018 @12:57PM (#18674406)
That’s because Google’s style guide is very restrictive.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by undefuser on Wednesday December 12, 2018 @11:11PM (#18669795)
Lack of features can be a good thing. There will be no “language feature anxiety” for the people who is writing code. The code is easier to comprehend for new people who just joined an ongoing project, because there are no non-obvious execution flows. And C code can be compiled so much faster than C++ due to the language being simpler.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by Koshkin on Wednesday December 12, 2018 @11:40PM (#18669876)
I usually spend the compilation time staring at code, only to realize, somewhere in the middle, that I have to abort the build because I must make another change in a large and complicated template in header file that is included almost everywhere. At times, I do miss C, especially its classical variant, where you often didn't even have to include anything and instead could just write the declaration of something you needed - right next to where you need it...
Re:Why should I have written ZeroMQ in C, not C++ (2012) by maxlybbert on Thursday December 13, 2018 @01:01PM (#18674466)
You can still use forward declarations. You can even use them in C++. But you have to be sure to get the signature exactly right (one of my favorite passages from “Design & Evolution of C++” involves Stroustrup’s discovery that a lot of programmers were cavalier about their forward declarations, e.g., using “...” as in any declaration where it would be syntactically valid).
Re:Why should I have written ZeroMQ in C, not C++ (2012) by zamalek on Thursday December 13, 2018 @12:57AM (#18670186)
> For me, going to a template-less world would be a nightmare.

I could do with just generics. I am honestly sold on the idea that OOP is flawed. I've tried to do "real" projects in C, but the continuous casting just felt like unnecessary ceremony.

Re:Why should I have written ZeroMQ in C, not C++ (2012) by int_19h on Thursday December 13, 2018 @06:22AM (#18671485)
"defer" or equivalent is another major missing piece.
Re:Why should I have written ZeroMQ in C, not C++ (2012) by pif on Thursday December 13, 2018 @08:44AM (#18672233)
> Other people you might respect have tasted C++ and bailed on it (eg Linus Torvalds.)

Sorry, Linus didn't say anything compelling against C++. He explained very clearly why C++ didn't fit with his own personal way to work, and that's fair.But his message did never contain anything more than this!