Posted Dec 23, 2012 15:02 UTC (Sun) by lu_zero (guest, #72556)
[Link]
Absolutely you do
We can continue saying "yes you can, no you cannot" till you try to provide an example.
Between C (and its dreadful macro system bound to cause aberrations) and C++ (and its horrible template system bound to spawn horribly verbose code as hard to track, if weren't for clang error reporting mitigating it) you have a
richer but brain damaged standard library and a plethora of features you should not use (or at least not all of them together).
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 23, 2012 23:22 UTC (Sun) by robert_s (subscriber, #42402)
[Link]
"code as hard to track"
What do you mean "hard to track"? At least templated code is fully interactive-debuggable - good luck trying to use debugging tools on code than heavily uses macros.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 26, 2012 12:03 UTC (Wed) by lu_zero (guest, #72556)
[Link]
gcc annotates macro and let you track them in gdb up to a point. That's something I'd love to see improved surely.
clang let you delve in template nests a lot better than gcc and that makes it a really useful tool on the other hand
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 23, 2012 23:27 UTC (Sun) by daglwn (subscriber, #65432)
[Link]
You cannot do RAII in C. End of story.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 23, 2012 23:36 UTC (Sun) by walters (subscriber, #7396)
[Link]
Posted Dec 24, 2012 8:15 UTC (Mon) by khim (subscriber, #9252)
[Link]
If you have GCC then you have C++, too. The lu_zero's fit of hysteria is related to the fact that you may have only some other, quite limited and deficient compiler instead. Which probably means that not only GCC extensions are not permittable but that ANSI C is "too new" and K&R C should be supported forever.
I think that since it's exclusively his problem (most other guys do a bootstrap using some other platform with full-blown GCC nowadays not a vendor-provided compiler) he can support any compiler he wants in said state, but it's not a good enough reason to make life for everyone else miserable.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 26, 2012 12:06 UTC (Wed) by lu_zero (guest, #72556)
[Link]
Would be _nice_ to stick to the standards and have standards improve.
The great thing about gcc is/was the fact you can get a good compiler to replace the shoddy one you had or that is just there.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 26, 2012 20:02 UTC (Wed) by daglwn (subscriber, #65432)
[Link]
1. That is not C.
2. That does not cover all cases.
One must have proper exception handling as well as destructor-like routines.
talloc as an RAII alternatives in C
Posted Dec 24, 2012 8:35 UTC (Mon) by scottt (subscriber, #5028)
[Link]
> You cannot do RAII in C. End of story.
Apache and Samba manage resource handles through apr_pool_t and talloc and they fair pretty well despite being written in C.
talloc as an RAII alternatives in C
Posted Dec 24, 2012 19:56 UTC (Mon) by Cyberax (✭ supporter ✭, #52523)
[Link]
Nope. They don't have RAII, they have refcounted pools. It's about the best you can do in plain C.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 24, 2012 22:31 UTC (Mon) by paulj (subscriber, #341)
[Link]
You can do RAII in C, you just need explicit scaffolding to setup the context that will destroy the objects. E.g. you can lift the destruction out of the code doing the work, by using a wrapping function that holds the state and cleans up after the "work" function - explicitly doing something equivalent to what a C++ compiler would do.
If you define RAII as requiring destruction to be tied into the scope in the language, then yes C doesn't have it. If you mean something more abstract, then you can implement it in C just fine. You have to implement it yourself then, of course, rather than let the C++ compiler do the work, but it's still possible, AFAICT. Surely?
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 25, 2012 0:18 UTC (Tue) by Cyberax (✭ supporter ✭, #52523)
[Link]
Well, yeah. You can do pretty much anything in C (except non-sjlj exceptions which require true compiler support), but you have to do it manually.
And that's the point - doing things manually is error-prone and code-bloating.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 25, 2012 12:47 UTC (Tue) by paulj (subscriber, #341)
[Link]
Having to create your own infrastructure - doing it manually - doesn't of course mean you have to do it manually from scratch at every point. You can re-use your infrastructure of course. It will take a little more typing than "}" though, sure. That needn't mean it's more error-prone though, imho.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 25, 2012 21:35 UTC (Tue) by Cyberax (✭ supporter ✭, #52523)
[Link]
Everything that is not automatic is error-prone. Especially in rarely-tested code paths.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 26, 2012 20:17 UTC (Wed) by lu_zero (guest, #72556)
[Link]
Everything is error prone then.
One of the issues I do have with C++ is that you must use a really strict subset (defeating the whole purpose of having such large standard library) in order to be reasonably sure your code will build and behave as you expect across different compiler/libstdc++ implementations.
And that because C++ is so complex and hard to implement that you have lots of interesting pitfalls.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 26, 2012 20:25 UTC (Wed) by Cyberax (✭ supporter ✭, #52523)
[Link]
Not everything, only the stuff that humans do directly.
> One of the issues I do have with C++ is that you must use a really strict subset
The only reason is to avoid incomprehensibly complex code.
> (defeating the whole purpose of having such large standard library) in order to be reasonably sure your code will build and behave as you expect across different compiler/libstdc++ implementations.
That hasn't been true for ages. All modern STL implementations are reasonably compatible - you won't find problems with standard containers and algorithms.
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 27, 2012 16:53 UTC (Thu) by bronson (subscriber, #4806)
[Link]
> ... you must use a really strict subset in order to be reasonably sure your code will build and behave as you expect across different compiler/libstdc++ implementations.
To be fair, this is true of libc too. "Always use glibc" dodges the problem (and not very successfully since glibc has so many obscure, dark corners).
GNU sed 4.2.2 released; maintainer resigns
Posted Dec 26, 2012 20:03 UTC (Wed) by daglwn (subscriber, #65432)
[Link]
> If you define RAII as requiring destruction to be tied into the scope in
> the language, then yes C doesn't have it.
Well of course that's what I mean! That is the whole point.