T
Tony
Signal9 said:and you will be on the corner asking for change when they drop the only
tool you know how to use....
i got 25cents for ya...
But I am "they", so that's not likely.
Tony
Signal9 said:and you will be on the corner asking for change when they drop the only
tool you know how to use....
i got 25cents for ya...
I will argue that a person with one solid year of learning and working
with
C++ is (with very few exceptions) a novice who is just getting started.
That works with many languages. I had a professor who told us that a
programmer with 20 years experience in C probably didn't learn anything new
about programming languages in the past 19 years. Such a person had "one
year of experience twenty times", as he put it. Our prof suggested a
person who has exposure to many different languages will be a far better
programmer than one who has focused on only one.
I will argue that a person with one solid year of learning and working with
C++ is (with very few exceptions) a novice who is just getting started.
peter said:What do you mean about a "novice"? If it is a highschool student with
no programming expertise you may be right, but for someone with a
background in software engineering this is simply ridiculous. I spent
two weeks myself before I became productive, and those two weeks were
spent reading Stroustups and Lippmans books (at home), while I began
updating an existing codebase with fellow C++ programmers available for
questioning.
I had a background as a C programmer so I knew the "basics" and also
had read a bit about OO programming before. Also, my collegues were
knowledgeable and helpful, so I might have been a bit faster than
average. But one year is ridiculous.
/Peter
peter koch said:Steven T. Hatton skrev:
What do you mean about a "novice"? If it is a highschool student with
no programming expertise you may be right, but for someone with a
background in software engineering this is simply ridiculous. I spent
two weeks myself before I became productive, and those two weeks were
spent reading Stroustups and Lippmans books (at home), while I began
updating an existing codebase with fellow C++ programmers available
for questioning.
I had a background as a C programmer so I knew the "basics" and also
had read a bit about OO programming before. Also, my collegues were
knowledgeable and helpful, so I might have been a bit faster than
average. But one year is ridiculous.
/Peter
peter said:Steven T. Hatton skrev:
What do you mean about a "novice"? If it is a highschool student with
no programming expertise you may be right, but for someone with a
background in software engineering this is simply ridiculous. I spent
two weeks myself before I became productive, and those two weeks were
spent reading Stroustups and Lippmans books (at home), while I began
updating an existing codebase with fellow C++ programmers available for
questioning.
I had a background as a C programmer so I knew the "basics" and also
had read a bit about OO programming before. Also, my collegues were
knowledgeable and helpful, so I might have been a bit faster than
average. But one year is ridiculous.
/Peter
Steven T. Hatton said:That's a very hard thing to assess given that a productive C programmer is
productively using a subset of C++ already. The question is largely at
what point did you stop using C++ as extended C?
John Carson said:
Which ones?peter koch wrote: [snip]
That's a very hard thing to assess given that a productive C programmer is
productively using a subset of C++ already. The question is largely at
what point did you stop using C++ as extended C? There are many subtleties
to C++ that can have a significant impact on producing optimal results.
peter said:Steven T. Hatton skrev:Which ones?peter koch wrote: [snip]
That's a very hard thing to assess given that a productive C programmer
is
productively using a subset of C++ already. The question is largely at
what point did you stop using C++ as extended C? There are many
subtleties to C++ that can have a significant impact on producing optimal
results.
I believe that I wrote C++ code from day one - almost. My one failure
was my disliking of declaring variables at their first use. I
stubbornly declared them first in the function, much preferring that
approach for the "messy" C++ way of doing this.
That was only the first week, however. As soon as I saw Stroustrups
explanation of RAII, I was convinced that this was the way to go.
/Peter
peter said:Steven T. Hatton skrev:Which ones?peter koch wrote: [snip]
That's a very hard thing to assess given that a productive C programmer
is
productively using a subset of C++ already. The question is largely at
what point did you stop using C++ as extended C? There are many
subtleties to C++ that can have a significant impact on producing optimal
results.
I believe that I wrote C++ code from day one - almost. My one failure
was my disliking of declaring variables at their first use. I
stubbornly declared them first in the function, much preferring that
approach for the "messy" C++ way of doing this.
That was only the first week, however. As soon as I saw Stroustrups
explanation of RAII, I was convinced that this was the way to go.
/Peter
You would have to be insane to learn C++ by reading Stroustrup's book!
Trust me, I did it that way.
Right. But you should know that already - at least as soon as you'veActually, RAII, understanding references
and their consequences, and value vs. reference semantics (for recovering
Java programmers) are some of what I consider the most essential aspects of
C++.
Understanding what templates are (and are not) is also essential.
Koenig and Moo offer a very different perspective on C++ than does
Stroustrup. I would call the essential distinction "type-based"
programming to contrast it with OOP or generic programming. Stroustrup
covers the same set of facts, but the approach in _Accelerated C++_ opened
my eyes to what the STL really means.
I've been at this for a little less than two years[*] and can honestly say
there are several aspect of the language which I am not yet comfortable
with. For example, I still don't understand the subtleties of friend
declarations as they involve scopes and declarative regions. It doesn't
help that my compiler seems to get it wrong.
Signal9 said:If you invest your time in this language it will not steer you wrong.
Honestly I would say learn this as your major language, but also learn
other languages. Java and C# are very popular right now and have a
decent mature framework.
When you start as a professional developer you will end up changing
languages over the years and maybe on a project to project basis
(depending on the company you work for).
Actually I say this to you. Go learn C++ as much as possible, learn C
as well. Then for "fun" develop your own high level language. this
will teach you a lot. At this point you may want to get into some
Assembly (which is heavily used in driver and kernel development).
The world of software development is fun, do not forget that. So go
have fun !
Kai-Uwe Bux said:This compiles:
#include <vector>
typedef std::vector<int> int_vector;
int main ( void ) {
int_vector iv ( 2000 );
int_vector().swap( iv );
}
This does not:
#include <vector>
typedef std::vector<int> int_vector;
int main ( void ) {
int_vector iv ( 2000 );
iv.swap( int_vector() );
}
The consequences range from minor nuisances to more serious issues: when I
return proxy classes instead of non-const references to members, the
temporary instances of these proxy classes cannot be passed to functions
properly, which leads to absurd constructions like swap() methods that
take their parameters by value or const reference. I ran into these issues
several times.
Those temporaries that I do not bind to references can still be optimized
away.
Nope, you can't: it lacks the protected members you would need to do that.
1) I was not proposing that. What I meant is something like:
typeof( some_expression ) dummy;
should allocate a variable dummy if possible. There would be an exception
thrown if the type does not allow for default construction.
2) How do you know how useful this feature is. Maybe, there is a little
lack of imagination on your part.
For instance, it can help with the double dispatch problem.
Among my motivations for templates, this item does not even occur at all;
and I am doing template code all the time. Very likely, your statement is
made from the point of view of OO where templates may enter the picture as
an optimization hack.
Not really: the instantiation trace is indeed by and large necessary to
locate the error (at least there are obscure errors that you would not
spot without it). The compiler can format it nicely, but trimming the
trace correctly is probably equivalent to the halting problem.
Maybe you misread what I wrote. Anyway, std::list<T> can be complete for
incomplete T. In fact, all implementations of std::list<> that I know
already do this trick (except, maybe, g++ with concept checks turned on).
It's just that the standard does not make it a requirement.
std::list said:Yes: there is no guarantee that sizeof( void* ) <= sizeof( std::size_t ).
If you do it "without too much effort", you get a useless toy.
Steven said:That makes sense to me. In the latter, the lifetime of in_vector() ends
before that of iv. In the former you create an anonymous object which
lives until you exit the block.
Nonetheless, it imposes another requirement on the compiler to deal with all
possible contingencies.
peter said:Steven T. Hatton skrev:
Right. But you should know that already - at least as soon as you've
programmed in Pascal.
inline template <typename T>
T min(T const& i, T const& j) { return i < j? i: j; }
(This last step will probably be taken immediately if you are anything
than a beginning C++-programmer).
I haven't read Koenig/Moo (except for the sample chapters), but
Stroustrup actually emphasises that C++ is a multi-paradigm language,
not forcing OO or generic unto you.
I've been at this for a little less than two years[*] and can honestly
say there are several aspect of the language which I am not yet
comfortable
with. For example, I still don't understand the subtleties of friend
declarations as they involve scopes and declarative regions. It doesn't
help that my compiler seems to get it wrong.
Right. But in your practical day-to-day life how often does this
happen? Just how often do you get this tricky friend declaration as a
problem? I'd guess less than twice a year. With other C++ subtleties
slapping your face, I'd guess you'd need to check the standard perhaps
bimonthly and probably not that often.
Steven said:That makes sense to me. In the latter, the lifetime of in_vector() ends
before that of iv. In the former you create an anonymous object which
lives until you exit the block.
I am inclined to const violations as an indication of bad design on my
part.
A first I found it frustrating and even irrational. The more I worked
with it, however, the more I realized it was good for me.
Nonetheless, it imposes another requirement on the compiler to deal with
all
possible contingencies. From my perspective, you seem to be asking to get
away with something you probably should not be doing.
I guess I don't follow. How can a lack of a protected member in the least
derived type restrict what you can do with derived types?
Stroustrup contributed to a paper a while back which talked about
'automatic
type detection' or something like that. IIRC, the idea was to determine
the type of an lvalue based on the type of an assigned rvalue. It seemed
to me like a ticket to overly generalized design.
You can do what amounts to the same thing in Java.
There is nothing you can do with templates which cannot be done with OOP.
The only difference is when type-checking takes place.
There are ways of folding error messages so that you only see the level or
parts you are interested in.
Care to provide an example? I really don't see how you can define
std::list<T> if T is not defined.
Can you provide an example in which the value of a pinter to void is
larger
than any value possibly returned by sizeof()? Likewise for ptrdiff_t.
I know a lot of people who will disagree with you.
Steven said:You would have to be insane to learn C++ by reading Stroustrup's book!
bjarne said:You seem remarkably certain of your opinion. As far as I can tell
(1) there is no one best way to learn C++ for all people
(2) there is no one best book for learning C++ for all people
(3) many people have successfully learned C++ from TC++PL
(4) many people have successfully learned C++ from other sources
(5) many people have failed to learn C++ from TC++PL
(6) many people have failed to learn C++ from other sources
Here, "many" means "hundreds of thousands".
In http://www.research.att.com/~bs/bs_faq.html#best-book I give my
opinion on who might benefit from TC++PL: "The book is aimed at
programmers with some experience and a wish to master C++. It is not
aimed at non-programmers trying to learn their first programming
language or casual programmers trying to gain a superficial
understanding of C++ as fast as possible."
To each his/her own. People really do think and learn differently.
People really do have different interests, skills, and needs when it
comes to writing code.
The distinction I'm talking about isn't really an issue with Pascal. It has
to do with polymorphism and what happens when you assign objects of derived
types to objects of their base type, etc. Pascal is not object oriented,
so that never comes into play.
What makes you think so? Just because most stuff in Java is pointers,Java there is never a possibility of
slicing because you are always dealing with pointers.
I do not have that book: if you believe there to be problems with constSee page 59 of _C++ Templates: The Complete Guide_ for s discussion of
problems related to using const references.
I believe you would also like to get to a point where you felt you'dI've been at this for a little less than two years[*] and can honestlysay there are several aspect of the language which I am not yet
comfortable
with. For example, I still don't understand the subtleties of friend
declarations as they involve scopes and declarative regions. It doesn't
help that my compiler seems to get it wrong.
Right. But in your practical day-to-day life how often does this
happen? Just how often do you get this tricky friend declaration as a
problem? I'd guess less than twice a year. With other C++ subtleties
slapping your face, I'd guess you'd need to check the standard perhaps
bimonthly and probably not that often.
I would just like to get to a point where I feel like I have grasped the
entire language.
That one looks confusing. If you'd like an explanation from me I'd haveI expect I will be learning new ways of using it for as
long as I am programming with C++. It would be nice, however, to be able
to understand how both of the following statements from the Standard can be
true:
"friend declarations may introduce a name into an enclosing namespace".
"friend declarations refer to functions or classes that are members of the
nearest enclosing namespace, but they do not introduce new names into that
namespace".
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.