Re:C Strings and my slow descent to madness
by bobajeff on Thursday April 06, 2023 @09:32AM
(#35468090)
I've been wondering lately why many people write c in c++ rather than just c. I think this might be the reason.
[ Parent
| on HN ]
Re:C Strings and my slow descent to madness
by qsort on Thursday April 06, 2023 @09:38AM
(#35468160)
People write C in C++ because they don't actually know C++ and think it's "basically C with classes and strings".
There are legitimate reasons why someone would rather write C, but "I don't understand RAII" is not one of them.
Re:C Strings and my slow descent to madness
by owlbite on Thursday April 06, 2023 @09:56AM
(#35468365)
C with basic templates is normally what I want. Occasionally other C++-isms drift in, but normally to the harm of the code quality.
Re:C Strings and my slow descent to madness
by wruza on Thursday April 06, 2023 @11:56AM
(#35470226)
C++ doesn’t require you to commit to all of its features and/or paradigms. Using it as you see fit is valid. Just don’t advertise yourself as a C++ programmer to the job market, as it’s not what most people expect.
There’s nothing wrong with “C with classes and strings” idea by itself, if that is your choice or a consciously sufficient level of competence.
Re:C Strings and my slow descent to madness
by qsort on Thursday April 06, 2023 @12:10PM
(#35470448)
It doesn't require you to commit to all of its features, that's certainly correct. But it does require you to commit to its principles; if you're needlessly passing naked pointers around, you're really writing C code with a C++ compiler.
Re:C Strings and my slow descent to madness
by wruza on Thursday April 06, 2023 @01:58PM
(#35471959)
I don’t see how it requires you to commit to any principles, if you can avoid those you don’t need and still successfully compile. That’s called “suggests” or “allows”, not “requires”. Yes, some people are writing C code with classes and strings in C++. That’s why we call this mode “C with classes and strings”. I believe that you are attached to these principles (see their benefits), and that is fine. But not everybody likes full-on C++.
Re:C Strings and my slow descent to madness
by tjoff on Thursday April 06, 2023 @10:07AM
(#35468483)
For a long time on windows the official MS recommendations was to use the c++ compiler for c projects.
Which was exerbated by an obsolete c compiler that only supported c89.
Re:C Strings and my slow descent to madness
by zabzonk on Thursday April 06, 2023 @11:30AM
(#35469720)
the usual accusation is that many people write c++ code as if it were c. also, the the code in 2nd ed of K&R was all compiled with stroustrup's c++ compiler, as there wasn't a c compiler that could handle it.