On Friday, 20 September 2013 at 13:00:49 UTC, H. S. Teoh wrote:
On Fri, Sep 20, 2013 at 09:14:28AM +0200, PauloPinto wrote:
On Thursday, 19 September 2013 at 23:50:04 UTC, H. S. Teoh
wrote:
[...]
I dislike C, and will take C++ safety and abstraction
capabilities
over C, unless forced to do otherwise.
[...]
C++ does have some parts that improve over C, it's true. But
it's also a
minefield filled with pitfalls. Due to its insistence with C
compatibility, it basically can only paper over C's flaws, but
push hard
enough and you're floundering in C problems once more. Well,
actually,
don't even push -- write straightforward code, and it's almost
always
wrong. And of the exponential number of ways to write
*non*-straightforward code, only one is correct (if that even
exists in
C++ -- maybe I should rather say, only one is least
problematic, 'cos
they all are).
It's unfortunate that due to C++ basically giving you a gun
that can
shoot you in the foot backwards while you're aiming at
something else
(all convniently abstracted away behind wrappers so you won't
even
notice the bleeding), it's just sooo easy to abuse. As I said
many times
before, at my job they migrated from C++ back to C, because,
for all of
its flaws, C at least has a well-understood core and well-known
ways of
managing its risky parts. The C++ codebase we used to have was
completely unmaintainable because it just combines so many C++
features
in the worst possible ways -- something inevitable when it has
passed
through so many hands. Both C and C++ require a lot of coding by
convention and extreme attention to detail, but at least in C,
mistakes
tend to be noticed rather quickly, whereas in C++ you could be
coding
for months, years, before you even notice anything wrong. And
by then,
it's too late to fix it because half the codebase is already
written in
the "wrong" way. (And there are just too many wrong ways to
write C++
code.)
It's such a refreshing change whenever I get to work with D in
my free
time. D does have its own warts and problems, it's true, but
it's a
world of a difference from C/C++. It's like the difference
between being
pricked by a needle every now and then vs. drinking glass
shards.
T
I understand you situation.
In my case, when I met C, I already knew Turbo Pascal, so C
seemed a bit of stone age due to string handling, no modules,
unsafe by default, no reference types, no OO.
C++ gave me some of the Turbo Pascal comfort back, together with
C compatibility and portability. Although writing portable C and
C++ code in the 90's, meant lots of #ifdefs.
Anyway, as I mentioned on my previous post, both languages hardly
play any role in the type of work my employer targets.
I guess it is always a matter of how we got to learn our tools,
and personal experience.
--
Paulo