4 ms·
> what options do I have? I have to pick up c++ in this case. it falls to the saying "a language is either blamed, or nobody uses it". You could just use C.
by logicchains 4y ago
> what options do I have? I have to pick up c++ in this case. it falls to the saying "a language is either blamed, or nobody uses it".
You could just use C.
- synergy20 4y agoor 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.
- alar44 4y agoThis 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.
- bluGill 4y agoThat C in C++ id the part where most of the serious bugs in C++ come from
- ncmncm 4y agoThen 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.
- alar44 4y agoAbsolutely, 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.
- ncmncm 4y agoThey 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.
- loxias 4y agoI'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.
- synergy20 4y agosame here, but I'm embracing modern c++ these days, not for all low level coding yet though.
- kfajdsl 4y agoYep, 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.
- loxias 4y agoSmart 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. :)
- ncmncm 4y ago"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.
- loxias 4y agoExactly. I couldn't have put it better myself, thanks. They're techniques after all, models, tools.