4 ms·
Is it just me, or are disillusioned C++ refugees who've gone back to C now trying to wreck it a second time? Probably just me. Since the 80's, C++ served as a
by smcameron 3y ago
Is it just me, or are disillusioned C++ refugees who've gone back to C now trying to wreck it a second time? Probably just me. Since the 80's, C++ served as an excellent decoy to absorb craziness and keep C sane.
- zabzonk 3y agoit is just you. why would anyone go back to C from C++? if you want to write C in C++, you can do that, with the advantages of stronger type checking.
- SV_BubbleTime 3y agoYou can use the C syntax in C++. But you are not using C, your compiler is still C++.
- zabzonk 3y agoyes the compiler is the same (for example gcc or msc) but why would you care?
- SV_BubbleTime 3y agoFirst off… GCC is not the compiler. It is the toolchain collection. Second, no, g++ does act identical to the c compiler component of GCC.
- burstmode 3y agoMany people, Especially sice C++ has become a playfield for CS language theorists, who invent more and more overcomplicated language "features" with little to no practical use.
- pjmlp 3y agoThat is still Haskell. Getting features into WG21 still requires some effort to get them through, regardless of what people in the outside think, and yeah I do agree it could get some more direction. C++ may seem to get everything dumpped into it, however any language nerd that feels like diving into what the history of languages with similar age (Python, Perl, Ada, C#, Java, F#, OCaml,...) have across all their versions, standard library, main interpreter/compilers, .... will find out those aren't much better either.
- zabzonk 3y agonobody makes you use these features, but when or if you come to writing a library, you may well find them useful.
- uecker 3y agoI switched back to C from C++. The reasons were that C removes a lot of unnecessary complexity which helps concentrating at the problem at hand. It also removes a lot of features that when used incorrectly makes the code much harder to understand. So if one often has to work with code written by unexperienced programmers (as I have to do), I found C++ very problematic. The stronger type checking is largely a myth.
- chlorion 3y agoIt's definitely not a myth. A trivial example is assigning pointers to incompatible types or passing them to incompatible function parameters not being an error. GCC 14 and Clang 16 are only just now making these errors by default. C++ never had this problem. Another example, is having type safe generic functions and classes. Using void* to pass around arbitrary types is something that you don't need to do in C++ because it supports generic programming. In C++ you can for example, pass an array of a specific length to a function, and make it a compile time error to pass an array of incorrect length, using std::array. In C arrays decay to pointers. static_case is also a thing in C++ that allows you to cast between types much more safely. There are so many things that I could probably spend several hours typing them out and I don't think that is really needed. C++ is certainly more type safe than C, whether or not you think the tradeoffs it makes are worth is something to debate for sure, but it gives you tools to write type safe code that simply don't exist in C. https://wiki.gentoo.org/wiki/Modern_C_porting#What_changed.3F https://wiki.gentoo.org/wiki/Modern_C_porting#What_changed.3...
- uecker 3y agoOk, let's debunk this point for point: - passing incompatible types is a constraint error in C just as in C++. Whether this is a warning or not depends on the compiler and on compiler flags. And as you observed yourself, the defaults are now even the same. - Passing void* around is also generally not necessary in C. - There is no reason to let arrays decay in pointers in C. One can take the address of an array and then get the same type checking. - Whether static_casts really makes much of a difference is debatable. In my C code I avoid casts and the rare exceptions I wrap in type-safe macros. So in summary, I think this just confirms that C++ people think it is safer because they do not know how you would do this in modern C.
- vbtemp 3y agoIt's not just you. The only thing I'm confused about is why more C standards keep coming out. C is what it is. Work with the archaic parts of it as need be. You use C for ultimate cross-platform compatibility (every exotic platform and its mother has an ANSI-C/C99 compiler). If you're able to run on the most bleeding-edge C compiler supporting the most recent WG version of C... then why not just use another language? I say this as someone who loves C. If there are bits that feel old, you just create a DSL to get around these problems that compiles down to C... but you don't change C itself.. Just my perception working with all this for many years now.
- hgs3 3y agoFor me the big problem with most C competitors is they go overboard. The only alternative I've tried that sparked my fancy was D with -betterC flag. It's unfortunate that it's not its own language, but rather a "profile" of a much much larger language.
- rwbt 3y agoThere's a lot of feature gap between C and C++. Many including me like to program in C but want just a _little_ more safeguards, syntax sugar and some established ideas (like defer) that improve the programming experience. Now there are languages like Odin, Zig and C3 that are trying to fill that niche but having C evolve slowly to accommodate such users is also a great idea. C99 added Designated Initializers which IMHO is probably the most innovative declarative syntax to initialize anything and it took C++ roughly 20 years to adopt such a thing (and then they had to nerf it).
- deleted 3y ago[deleted]