News for hackers. Stuff that matters.
Re:C++20, How Hard Could It Be by synergy20 on Sunday September 25, 2022 @12:21PM (#32972890)
or use a subset of c++ that does everything c does, plus OOP, RAII and smart pointers for free, and it compiles and links with c code smoothly as well. the only price to pay is that libstdc++ runtime must be present, which is just a few MBs that can even fit for small embedded boards.
Re:C++20, How Hard Could It Be by loxias on Sunday September 25, 2022 @12:48PM (#32973180)
I've written firmware, systems software, drivers and plenty else this way. Just because the language gives you rope doesn't mean you _have_ to use all of it. I enjoy how terse and straightforward even good ol' structured non-object oriented code can be.
Re:C++20, How Hard Could It Be by ncmncm on Sunday September 25, 2022 @04:42PM (#32975984)
"Object-oriented" is a niche technique.

Any big-enough system will naturally have some OO-ish parts, just because it has some of almost everything. Most small programs will have none.

Re:C++20, How Hard Could It Be by loxias on Sunday September 25, 2022 @07:42PM (#32977661)
Exactly. I couldn't have put it better myself, thanks.

They're techniques after all, models, tools.

Re:C++20, How Hard Could It Be by synergy20 on Sunday September 25, 2022 @12:56PM (#32973293)
same here, but I'm embracing modern c++ these days, not for all low level coding yet though.
Re:C++20, How Hard Could It Be by kfajdsl on Sunday September 25, 2022 @01:29PM (#32973692)
Yep, big thing for me is smart pointers and RAII. Everything else is secondary.

I have worked on template-heavy codebases that would really benefit from concepts, though.

Re:C++20, How Hard Could It Be by loxias on Sunday September 25, 2022 @08:00PM (#32977788)
Smart pointers and RAII do _so much_! I really like zero-cost abstractions, like a nested scope with a RAII object (which will get optimized out) to implement a BEFORE{} and AFTER{}.

That plus structured bindings return types. :)

Re:C++20, How Hard Could It Be by alar44 on Sunday September 25, 2022 @12:35PM (#32973024)
This is what I do. Write C in C++. You don't have to use all the fancy new shit. I'll never understand why people get so upset about it.
Re:C++20, How Hard Could It Be by ncmncm on Sunday September 25, 2022 @04:49PM (#32976052)
Then you are writing bad C++ code.

The new features are added specifically because they enable writing better programs. Avoiding them means you are choosing not to write better programs. It is allowed, but not a thing to brag about.

That does not mean every program has to use every feature. But when there is a choice between the new way and the old way to do something, the new way is very probably better.

Passing a reference, where you can, is better than passing a pointer. Passing a lambda is better than passing a function pointer. New for-loops are better than old for-loops. A unique_ptr is a better member than a naked pointer. A compiler-generated destructor is better than a hand-coded one.

And so on.

Re:C++20, How Hard Could It Be by alar44 on Sunday September 25, 2022 @06:49PM (#32977213)
Absolutely, but none of those are really that new. I guess I'm talking more about boost libraries and that stuff. I just can't be bothered and it doesn't matter for anything I need to write.
Re:C++20, How Hard Could It Be by ncmncm on Monday September 26, 2022 @12:19AM (#32979373)
They are not especially new, but they are not in C.

C is the language that invites in mistakes. The less C we code, the fewer mistakes we ship.

Re:C++20, How Hard Could It Be by bluGill on Sunday September 25, 2022 @01:39PM (#32973822)
That C in C++ id the part where most of the serious bugs in C++ come from