News for hackers. Stuff that matters.
Re:Should we stop writing functions? (C++) by memefrog on Sunday August 06, 2023 @09:17PM (#37028806)
>If you want people to switch to something better, make something better.

We already have C, which is better. It existed before C++. It will exist long after C++ is dead. If you don't over-architect and over-abstract your code you can be more productive in C than in C++ precisely because you avoid the kind of nonsense that this article (and the endless other articles about overcoming C++'s shortcomings and cognitive overheads) talk about. In the time you spend waiting for C++ code to compile, you can instead just write more code in C.

Look at all the articles that get posted here about C++. There was a post a day or two ago about trying to work around C++ compilation times. How long does it take to compile C projects? Not long at all, if you follow standard rules that have been well-known for decades like forbidding #include in header files.

>If all the other compilers and languages were THAT much better, they would be used.

Argument from popularity/Blub paradox. If C++ is so good why does it need to be constantly updated and extended? If you think C++23 is better than C++20, then surely you accept that C++23 can at least potentially be worse than things that already exist.

---

People have an attitude towards C. They think "oh but what about std::vector? I will have to write my own containers". But 90% of the time you will have good enough or even better performance with a few lines of code. Often you know statically the maximum size and can just allocate that at compile time, or you know before filling a collection what the size will be. In C++, most code dealing with vectors that I have seen pre-sizes the vector anyway. That could just be a 'malloc' or a static array. The result is that you compile in debug mode and your program actually works, you can use a debugger, everything Just Works. Programs run at almost full speed in debug mode, and debuggers work. It's glorious.

In C++, you spend a hundred thousand lines of code reimplementing standard library containers anyway because anything more complicated than std::vector is unsuitable for non-trivial programs, and then the only way your program will run is with optimisations on, because your 'zero-cost' abstractions are actually very high cost if you aren't compiling with -O3.

Oh yay I have a big standard library in C++. Thanks for saving me from having to use the old ugly BSD sockets API to do networking. I can use a nice modern networking API in C++. Oh... it doesn't exist? Oh well, I'll use a nice modern filesystem API in C++. Oh, it only was added recently and lacks basic functionality? Oh well, I guess in return for learning the 50 different ways of initialising a variable, and all the subtleties of argument-dependent lookup and glprxvalues and template deduction guides and template⟨T=std::enable_if⟨std::is_void⟨void_t⟨int⟩⟩::type⟩::value⟩ I will get the benefit of using a high-quality standard library that contains std::regex and std::random and std::chrono and std::thread and std::vector<bool> and std::unordered_map and all the other VERY high quality standard library facilities provided by the C++ standard library!

Oh they're all crap. Pity.

Re:Should we stop writing functions? (C++) by jenadine on Monday August 07, 2023 @12:21AM (#37030095)
No, C is not better. C is much worse. C lacks basic primitives that allow programmers to do useful abstractions and let them concentrate on the business logic rather than on the low level details of every functions.

You maybe can write small program easier on C as long as you can fit everything in someone's head. And that's why all complex low level programs are written in C++ and not C. (With the Linux Kernel being an exception, because of its stupborn maintainer)

And what about the drawbacks mentioned on the article? 99% of programmers don't need to care about them. The reasons such article exists is precisely because some people love C++ and like to play with their language.

---

> If C++ is so good why does it need to be constantly updated and extended?

Uh? To adapt and evolve to a changing environment. Instead of stagnating and becoming irrelevant. If it is so great, why is the iPhone constantly release new models? Why do every maintained software release new versions? And that's why you should use C++ instead of C.

Re:Should we stop writing functions? (C++) by memefrog on Monday August 07, 2023 @01:34AM (#37030538)
* * *
Re:Should we stop writing functions? (C++) by pjmlp on Monday August 07, 2023 @02:33AM (#37030945)
Better get one of those old C compilers that are still written in C then.
Re:Should we stop writing functions? (C++) by wizofaus on Monday August 07, 2023 @02:53AM (#37031101)
> If C++ is so good why does it need to be constantly updated and extended?

You could make that argument about almost any technology (certainly in the IT world). C23 is out this year which will make it the 6th "official" version - obviously a much more slowly evolving language than most, but nonetheless still being fairly regularly "updated and extended".

There's plenty of things I don't care for in C++, but I can (and do) choose not to use those parts. The few times recently I had to work with pure "C" code felt, well, decidedly primitive - but there was no choice but to grin and bear it. Which works great for some contexts, but I'm not sure I can imagine tolerating it for large-scale application development.

Re:Should we stop writing functions? (C++) by memefrog on Monday August 07, 2023 @03:24AM (#37031343)
C23 is a bad standard with a massive pile of misfeatures. The only reason there even is a C23 is that a bunch of C++ people have infiltrated the committee in an attempt to force changes into C23. For example, the guy whose website is 'thephd.dev' is a self-proclaimed Rust fanatic who wants to see the death of C. He is also on the committee in a leadership position. The C committee.

The problem is that it's a language that doesn't need to change much. It doesn't really need a committee. People that recognise this don't bother getting involved. That leaves it vulnerable to entryists.

You cannot pick and choose which C++ features to use in practice if you use any kind of library including the standard library.

Re:Should we stop writing functions? (C++) by Conscat on Monday August 07, 2023 @03:49PM (#37039983)
Actually, Jean Heyd Meneide (thephd, whose pronouns are they/them btw) joined WG14 before WG21, and they originally came in to work on standard unicode support. They also recently declared that they are ending their work on Rust features.
Re:Should we stop writing functions? (C++) by memefrog on Monday August 07, 2023 @05:54PM (#37041479)
He is a bad influence on C development and has stated multiple times on his blog that he wants C to die.

His contributions to the C23 standard are dire.

He has only stopped contribution to Rust because he created an enormous drama over a conference talk being downgraded from keynote to normal. This isn't something that saves his reputation. The opposite is the case. It makes him seem like even more of a massive tool.

He gets upset and complains whenever anyone pushes back on his awful, ill-thought-out attempts to contribute to C or C++. He unsubtly hints that anyone that disagrees with him is a racist. In other words, he wields his skin colour as an weapon when he doesn't get his own way.

> whose pronouns are they/them btw

No, I don't think so. He clearly is a guy, presents himself as a guy, wears suits to conferences, and has a guy's name. There is no indication anywhere on any of his social media of any request that people not refer to him in the natural way that people normal refer to men.

Re:Should we stop writing functions? (C++) by Conscat on Monday August 07, 2023 @11:12PM (#37044063)
I've deleted my previous post, because I felt it was too harsh. I will simply leave this at you are transphobic and bizarrely ill-informed about Jean Heyd Meneide in particular.
Re:Should we stop writing functions? (C++) by memefrog on Tuesday August 08, 2023 @02:13AM (#37045150)
It's not transphobic to refuse to believe the bizarre accusations of a random internet commenter when I cannot see any evidence whatsoever to back up your random ramblings.

Also it is not transphobic not to recognise 'they/them'/gender non-binariness. 'Transphobic', as the term implies, relates to transgender/transsexual. 'Trans' is a latin term. It essentially means 'across'. It refers to people that transition from one gender to the other gender. There are just two. This is the entire point of the concept of transgender: that there are just two of them.

This has become a 'controversial' thing to say in the US, but almost nowhere else is it even remotely controversial. It is blindingly obvious. And it has nothing to do with 'transphobia'. It would be 'transphobic' to say that a man can't become a woman.

I don't care if you label me as transphobic to say that a man can't become a woman. A man, after all, cannot become a woman. I do care if you label me as transphobic for referring to as a bloke a bloke who clearly presents himself as a bloke, acts like a bloke, and is a bloke, on every level, and who doesn't indicate in any of his bios on Linkedin, Twitter, his own website or apparently anywhere else that he should be referred to in any other way. Apparently this is just some secret knowledge that you have acquired. You've told me it, but why should I believe you? You're a random commenter on the bloody internet. You simply are not a reliable source in any way. And if I don't believe your random claim, for which you have provided no evidence, I am 'transphobic'? Fuck. Right. Off.