M
MikeP
Rui said:Why do you believe that using std::string hinders "interoperability
amongst programmers"?
Just the opposite. Maybe I misunderstood the other post.
Rui said:Why do you believe that using std::string hinders "interoperability
amongst programmers"?
I'm not saying C++ is a "simple" language. However, it is, by this
definition, *simpler* than C.
There are, of course two problems with that:
1) It's not standard, and hence if you need to do a project somewhere
where you don't have your toolset, you'll have to start from scratch.
Also, it doesn't help others to understand your code if they haven't
used the same toolset.
2) Most generic tools you could write in C are harder and less safe to
use (compared to most other languages, including C++). Typically the
more generic the library, the less efficiency, type safety and
usability.
If you use your own tool instead of a standard tool even in
situations where the standard tool would be perfectly suited, that's
not very smart.
Rui said:If you really wish to know that then all you have to do is put in the
leg work and check it for yourself. Why did you failed to do that
and instead opted to simply whine?
You can whine about anything you wish, really. The fact is, I've
criticized an attempt at evaluating the market share of a set of
languages and, to complement that, I've provided a more objective,
quantitative way to evaluate that.
You, on the other hand, threw a
set of questions to which, as a demonstration on how relevant you
think they are, you don't even want to get the answer to and, based
on that silly permisse, went forward to bitch about how "lame" this
source of data was.
So, if you really want to discuss how "lame" a source of data is then
at the very least provide any data which you believe is better than
this. Until that, tone down your "lame" posts.
Joshua said:I laughed when I saw your acronym. I assume that was just made up on
the spot.
The point is, C++ programmers can choose between "The C way"(tm) and
templates. C people are stuck with one side of the tradeoff. I don't
think you're disagreeing, but I'm just being contrarian to your
contrarian.
Juha said:What's that, exactly?
Nobody said:C exceptions (i.e. longjmp) also require it.
I suppose it depends upon whether legibility is important/necessary or
merely a convenience. The contortions required to get by without it
can be pretty ugly. Similarly, one could ask whether high-level
languages are important/necessary, or merely a convenience.
Joshua said:That's a matter of opinion.
The first thing that Bjarne Stroustrup added to C to make C++ was
destructors, more or less. In his own words in this forum, it predated
all the other cool things, like templates, virtual, exceptions, by
years. I agree with Bjarne that the thing I miss the most when I'm
forced to do C, or maintain C-like C++ code, is destructors.
The utility of destructors is not mere syntactic sugar like a ranged-
based for loop ala Java and C++0x or even the virtual keyword.
Implicit calling of functions when objects leave scope is incredibly
"powerful" and useful. It greatly reduces a whole class of programming
errors. It does this IMHO in two main ways. First it helps the
programmer not forget to add a free-resource call to a deinit call
(now also usually a destructor), and helps the programmer not forget a
free-resource call (now also usually a destructor) on an exit path in
a function.
Second, it helps foster a certain kind of programming paradigm where
the coder ensures that all resources have an owner at all times. Most
of the time, that is except for the occasional no-throw block or no-
throw operation which transfers ownership or allocates a resource, you
can unwind the stack at any time and you will not leak resources -
required with exceptions, but still useful otherwise. When all
resources have a clearly identified owner (and thus destruction
condition), and the ownership graph in large part has all of its roots
in stack objects, leaks become much rarer, especially with the
idiomatic usage.
Juha said:I don't understand where this notion is coming from.
Even if exceptions were disabled (in many compilers you can disable
them so that they will never be thrown) it would still be a nightmare
to develop a large project without RAII.
I would say the opposite of you: RAII is essential. The fact that it
allows making code exception-safe is a nice side-effect, but not the
main point.
Rui said:I don't believe that the differences between C++ and C are equivalent
to the differences between a house with indoor plumbing and
electricity and a cave. I see it more as the difference between a
house fully stocked with a hefty set of conveniences and features
such as home automation, HVAC and even HAL from 2001: A Space
Odyssey, and the exact same house with barely any furniture and
stripped of any of those bells and wistles. Both are good houses,
you can live confortably in any of those but in some cases you don't
have those gadgets helping you/constantly getting on your way.
MikeP said:Innovation? Looks like a quite nice and convenient side-effect.Keith said:[...] I would say that
the C++ automatic constructor/destructor paradigm (which was a C++
innovation as far as I know?) is also extremely valuable.
MikeP said:RAII has become such a clouding concept to the underpinnings.
It seems like there is some terminology conspicuously absent
in between the mechanisms and the high level idiom RAII
MikeP said:Type "template code bloat" or "C++ template code bloat" into your favorite
internet search engine and you'll get a long listing.
But not impossible. And creativity counts. Do/undo and keep functions
short (the C way) and then you're out of the realm of "nightmare". (Not
that I'm suggesting one do it that way).
The scoped lifetime of classes on the stack is nifty, yes. I think the
RAII idiom necessarily brings in the exception stuff though. It's the
best way to do it, but not the only way (unless you turn on the exception
switch on the compiler). Constructors and operators need exceptions,
exceptions necessitate RAII... it's a chain reaction of which there are
at least a few of in the design of C++.
The point is that C advocates try to ride on the concept of language
simplicity. With other languages simplicity means not only that the
language specification is relatively short, but also that writing
programs is simple and straightforward (because, among other things,
the programmer is not burdened by memory management and other similar
issues). The simplicity of the language directly correlates to how much
you have to write in order to implement a given task, and how much of
what you write is directly related to the task itself (rather than to
ancillary things like memory management). Also, how easy it is to
understand the code.
Keith said:[...] I would say that
the C++ automatic constructor/destructor paradigm (which was a C++
innovation as far as I know?) is also extremely valuable.
Innovation? Looks like a quite nice and convenient side-effect.
Nobody said:In terms of understanding the code, the ability of C++ to "hide" code in
constructors and overloaded operators can be seen as an impediment to
legibility. The C++ perspective is that you don't need to know the
details; you just trust that the implementation behaves correctly. In
situations where C is the correct choice, the details often matter.
That argument makes no sense. Constructors and overloaded operators
are just functions. C supports functions as well. Functions whose source
code might not be available at all. I don't understand your argument.
Dombo said:The difference is that C if you want some thing to happen you must
explicitly write code for it; what you see is what you get. In C++ lots of
things can happen because of an innocently looking statement or even when
there is no code at all (destructors); you may very well get more than
that you see.
Balog said:Is there any real difference?
C was created as a "portable assembler".
You lost the "what you see" attribute right with that step.
By design certainly, that was the point -- you write code using abstract
types like int, short, pointers, "arrays", and the approppriate assembly
code is generated for the platform.
Can you tell what machine instructions you will get from a C source? For
some level, yes: if you know the semantics.
But the very same is true for C++.
Is there any real difference? C was created as a "portable assembler".
You lost the "what you see" attribute right with that step.
By design certainly, that was the point -- you write code using abstract
types like int, short, pointers, "arrays", and the approppriate assembly
code is generated for the platform.
Can you tell what machine instructions you will get from a C source? For
some level, yes: if you know the semantics.
But the very same is true for C++.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.