News for hackers. Stuff that matters.
Re:Switching to C over 'Modern' Programming Languages by kaba0 on Thursday April 13, 2023 @09:11AM (#35554883)
So your answer is “because they are not C”…?

What does language complexity has to do with anything? It will get compiled down to machine code, and both can be and are used for embedded. They occupy the exact same low-level niche as C, hell, they may be even more level as they can also do things like SIMD.

Linux kernel is C because Linus doesn’t like C++, it’s that easy. And usually no, why would you use multiple languages in a project if you don’t have a good reason?

Re:Switching to C over 'Modern' Programming Languages by cozzyd on Thursday April 13, 2023 @09:55AM (#35555509)
It is quite difficult to write idiomatic C++ without memory allocation, for one, which is often a requirement for embedded code or any high-availability code that is not allowed to have memory fragmentation.

Sure, it's possible (you can write C in C++, for the most part, and to its credit, C++ has placement new). But many of C++'s niceties require memory allocation, making much of its value-add over C questionable.

Re:Switching to C over 'Modern' Programming Languages by pjmlp on Thursday April 13, 2023 @03:30PM (#35560914)
It super easy, we did it all the time back in the MS-DOS days.
Re:Switching to C over 'Modern' Programming Languages by cozzyd on Thursday April 13, 2023 @05:30PM (#35562328)
right, but that was pre C++ niceties like the STL :).
Re:Switching to C over 'Modern' Programming Languages by pjmlp on Friday April 14, 2023 @02:20AM (#35566133)
C++ compilers shipped their own collections, for Borland compilers it was BIDS.

The first version used preprocessor macro tricks for generatic code, basically what Go folks re-discovered with //go:generate, we already had it in 1992.

BIDS 2.0 already used templates.

It was exactly because even C++ for MS-DOS provided safer library than C, that I was never that into C. It wasn't better than TP in features and safety, only in portability, and that I could get from C++ anyway.

Re:Switching to C over 'Modern' Programming Languages by cozzyd on Friday April 14, 2023 @11:52AM (#35570926)
That's fair! Perhaps I should amend to say that "current" idiomatic (almost got autocorrected to idiotic on my phone) c++ code is allocation heavy. Probably there exist suitable libraries I don't know about that basically implement the STL using predefined arenas for storage.