How to understand the C++ specification?

D

doublemaster007

Is there any way i can understand C++ specifications? Every time i
read..i find it diff to understand..so i read more books on C++ and
come back..still the result is same..Are there any links, refereces
or documents which helps to parse specification easily?? I really
wanna understand that..pls help me..
 
N

Nosophorus

Hi!

The first C++ book I read was "Rescued By C++". I thought it a fairly
nice introductory C++ book. It is not as "profound" as "Thinking In C+
+" (which you can get for free from web). BUT, as a first contact with
the language, it is nice.

I recommend "Rescued By C++" as an introduction and, then, "Thinking
In C++" as the next step. After those two books, maybe, the reader is
well suited to wonder through Stroustrup's "The C++ Programming
Language".

Marcelo de Brito
 
D

doublemaster007

Hi!

The first C++ book I read was "Rescued By C++". I thought it a fairly
nice introductory C++ book. It is not as "profound" as "Thinking In C+
+" (which you can get for free from web). BUT, as a first contact with
the language, it is nice.

I recommend "Rescued By C++" as an introduction and, then, "Thinking
In C++" as the next step. After those two books, maybe, the reader is
well suited to wonder through Stroustrup's "The C++ Programming
Language".

Marcelo de Brito

Hmm..Actually i am confiratable with C++ and have 2 years of
experience in C++. I have read some other advanced books like
Effective C++ , more effective C++ , etc..I feel that C++ standard i
should be reading because it decides sytanx and semantix of the C++.
But it uses tough notations, definations that i am finding little diff
to understand!
 
S

steve.cpp

Hmm..Actually i am confiratable with C++ and have 2 years of
experience in C++. I have read some other advanced books like
Effective C++ , more effective C++ , etc..I feel that C++ standard i
should be reading because it decides sytanx and semantix of the C++.
But it uses tough notations, definations that i am finding little diff
to understand!

Your experience is fine but post a specific example of something you
can't understand. I have less experience but am finding the standard
reasonable so please post something specific.
 
N

Noah Roberts

Is there any way i can understand C++ specifications? Every time i
read..i find it diff to understand..so i read more books on C++ and
come back..still the result is same..Are there any links, refereces
or documents which helps to parse specification easily?? I really
wanna understand that..pls help me..

I disagree with the assessment of others here, that you don't need to
read the standard. The standard should be on everyone's desk. It is
the only way to know what's going on with your code in many situations.
What's funny is that most the people who say you don't need it also
refer to it regularly to answer questions asked in this newsgroup.

As with all things, reading the standard takes practice. Just keep
trying. Make sure to read the first section where all the definitions
are defined in rigor.
 
B

Bo Persson

Noah said:
I disagree with the assessment of others here, that you don't need
to read the standard. The standard should be on everyone's desk. It
is the only way to know what's going on with your code in many
situations. What's funny is that most the people who say you don't
need it also refer to it regularly to answer questions asked in
this newsgroup.

I believe some of those people also have 20 years of experience, and a
ton of other books in their bookshelf. None of them started out with a
standard document.

The thing is that you cannot learn to program from the standard, so
you shouldn't start there. Read a couple of other books first, and get
some practical experience.

As with all things, reading the standard takes practice. Just keep
trying. Make sure to read the first section where all the
definitions are defined in rigor.

And don't forget to read another book or three first!


Bo Persson
 
I

Ian Collins

Hmm..Actually i am confiratable with C++ and have 2 years of
experience in C++. I have read some other advanced books like
Effective C++ , more effective C++ , etc..I feel that C++ standard i
should be reading because it decides sytanx and semantix of the C++.
But it uses tough notations, definations that i am finding little diff
to understand!

The standard is a reference document, treat it as your would any other
reference. It isn't light reading!

It's clear that you aren't a native English speaker and this will make
the precise and terse language of the standard hard going.

Stick with the books and check the standard when you need clarification.
 
J

James Kanze

Hmm..Actually i am confiratable with C++ and have 2 years of
experience in C++. I have read some other advanced books like
Effective C++ , more effective C++ , etc..I feel that C++
standard i should be reading because it decides sytanx and
semantix of the C++. But it uses tough notations, definations
that i am finding little diff to understand!

The standard is written in a variant of English sometimes called
standardese. It's designed (or at least intended) to be
absolutely precise and unambiguous, even at the cost of
understandability. It doesn't always succeed with its intent,
but in all cases, precision and a lack of ambiguity have
precedence over readability.

Having said that: the major problem with readability I have is
finding what I'm looking for. Who'd think to look for "lifetime
of temporaries" in the section on "special member functions"?
And the definition of a POD struct refers to the definition of
an aggregate, which is in the section on initializers. Once
I've found it, however... The quality of the prose varies, but I
find most of it pretty readable... and not always as precise and
unambiguous as I'd like.
 
J

James Kanze

I disagree with the assessment of others here, that you don't
need to read the standard. The standard should be on
everyone's desk. It is the only way to know what's going on
with your code in many situations.

If that's true, then the code you're writing is too complicated,
and makes too much use of limit conditions. About the only time
I'll refer to the standard when writing code is for library
functions, and that's just because I don't have any other
documentation on line.
What's funny is that most the people who say you don't need it
also refer to it regularly to answer questions asked in this
newsgroup.

That's because a lot of questions here concern things you
shouldn't be doing in production code anyway:).
 
N

Noah Roberts

James said:
If that's true, then the code you're writing is too complicated,
and makes too much use of limit conditions. About the only time
I'll refer to the standard when writing code is for library
functions, and that's just because I don't have any other
documentation on line.

Yes, we've already established that "Hello World!" is about as involved
as your software gets. Some of us though have to work a little harder
for our living and are not afraid of using the language to its full
potential in order to get that job done.

Frankly, if I'd never needed the standard to answer a question about a
problem I'd run into...I'd certainly never admit it. It could only mean
one of two things: 1) I'm an intermediate programmer at best who's never
run into the least complication in one of the most complex languages out
there or 2) I think I already know everything and just hack at things
until they work. Which are you?
 
J

James Kanze

Yes, we've already established that "Hello World!" is about as
involved as your software gets. Some of us though have to
work a little harder for our living and are not afraid of
using the language to its full potential in order to get that
job done.

Getting the job done, in my case, means writing code that works,
and that can be maintained. I know that that's an unusual
requirement. It's much more fun to experiment.
Frankly, if I'd never needed the standard to answer a question
about a problem I'd run into...I'd certainly never admit it.

So you have to maintain poorly written code. It happens. I've
also had to check the standard once or twice to know exactly
what some poorly written code meant. (I'm not sure that the
author realized himself what it really meant.)
It could only mean one of two things: 1) I'm an intermediate
programmer at best who's never run into the least complication
in one of the most complex languages out there or 2) I think I
already know everything and just hack at things until they
work. Which are you?

What it means is that I don't use constructs I (or my collegues)
can't understand, and that we don't know what they do. It's
called writing working, maintainable code. If you need to check
the standard for code you're writing, then it's probably a
concept you're not familiar with.
 
N

Noah Roberts

James said:
What it means is that I don't use constructs I (or my collegues)
can't understand, and that we don't know what they do.

....and of course you know exactly what everything in C++ does without
looking at the standard...ever.

Well, James, looks like I'm just not as smart as you are. In order to
know what things do in C++ I have to read how the various combinations
of constructs work within C++. Only then can I write maintainable code
I understand. Looks like you just started out knowing everything so in
that regard I would have to say you're a very lucky man; I had to work
for my knowledge.
 
N

Noah Roberts

Oh, and...

James said:
Getting the job done, in my case, means writing code that works,
and that can be maintained. I know that that's an unusual
requirement. It's much more fun to experiment.

I think you just proved my point. If you've never HAD to experiment
then you've simply never written anything particularly difficult. I
suppose you spent your entire learning period not experimenting too.
That's just sad.

Yes, I'm proud to admit that much of my knowledge comes from
experimenting, failing, and having to look at the standard to see why
what I'm doing is nonsense. My knowledge came from years of hard work
and many, many mistakes. Where did yours come from?
 
J

James Kanze

...and of course you know exactly what everything in C++ does without
looking at the standard...ever.
Well, James, looks like I'm just not as smart as you are. In
order to know what things do in C++ I have to read how the
various combinations of constructs work within C++. Only then
can I write maintainable code I understand.

If you have to look things up in the standard, then you're not
writing code you (or someone else) can maintain. You're working
too near the limits (and the code wouldn't pass code review in
any place I've worked).
 
J

James Kanze

Oh, and...
I think you just proved my point. If you've never HAD to experiment
then you've simply never written anything particularly difficult. I
suppose you spent your entire learning period not experimenting too.
That's just sad.

Isn't it beautiful, people who like to play word games, instead
of worrying about real issues.

Obviously, I experiment. But I don't deliver experimental code.
And I don't need to look things up in the standard to
experiment, since I know that if I do, even if the experiment
works, I can't use it, because 1) my collegues won't understand
the code, and 2) it's likely that some compiler will not get it
right either (and in the end, what matters isn't what the
standard says, but what the compiler does). I don't experiment
with the language much (except for amusement); I have enough
other problems which have to be solved. (As one employer put
it: I'm not being paid to stress test the compiler. *IF* you're
employed to test a compiler for compliance, then of course you
will read the standard. A lot. But that's not the case of most
of us.)
Yes, I'm proud to admit that much of my knowledge comes from
experimenting, failing, and having to look at the standard to
see why what I'm doing is nonsense.

I fail to see how you can find out whether something is nonsense
by looking it up in the standard. (For that matter, the
standard is often "wrong", compared to the compilers I'm using.)
My knowledge came from years of hard work and many, many
mistakes. Where did yours come from?

Most of it comes from communicating with collegues. I've
learned an awful lot from other peoples mistakes. And vice
versa, of course. My collegues learn from my code. Which is
one of the reasons why it's so important to make it readable.
 
N

Noah Roberts

James said:
If you have to look things up in the standard, then you're not
writing code you (or someone else) can maintain.

Well, if you say so it must be true. Guess I'll just have to live with
my unmaintainable code, unmaintainable code that's as sure to be
standard compliant as I can make it.
 
N

Noah Roberts

James said:
I fail to see how you can find out whether something is nonsense
by looking it up in the standard. (For that matter, the
standard is often "wrong", compared to the compilers I'm using.)

Case in point. Yesterday one of the developers ran into a problem with
a virtual function not being called. He was subclassing an object
residing in a library we are using. Had I not a decent grasp of the
language, by reading the standard, I would not have been able to tell
him exactly why it's broken and send the bug information to the library
developer allowing them to fix it that day. Granted, it was a rookie
mistake but knowing these things allowed me to say with absolute clarity
that it was this that caused it and not something else.
Most of it comes from communicating with collegues. I've
learned an awful lot from other peoples mistakes. And vice
versa, of course. My collegues learn from my code. Which is
one of the reasons why it's so important to make it readable.

Great, you learn from each other. Like I don't. I suppose none of you
step OUTSIDE your little circle either?

You like to call the areas where the standard is important "too near the
limits". Well, I've found it incredibly easy then to reach the "limits"
(as you call them) of C++. Why did my code work on one compiler and not
the other? Why, look in the standard and find I'm doing something
slightly wrong...or...the compiler I used originally was broken and now
the new one is fixed and my code must change...or, the compiler I'm
using is NOT compliant and I need to make a special case for it. These
cases are simple (template friendship, templates in general,
availability of member addresses) and often run into.

I suppose if you live in some happy, nonexistant la-la land where all
compilers are compliant then you don't have to worry about these things.
Tell me, how do YOU know which compiler is compliant without looking
at the standard?

Furthermore, the standard is the absolutely best reference for the
library that exists. The Josuttis book is a great tutorial but the std
is a much better reference. Standards compliance issues in production
code are also quite often involving misuse and misunderstanding of the
library. Nothing teaches a new programmer how NOT to do something like
being able to explain exactly why what they are doing is wrong, rather
than point to some tutorial book that says, "Don't do this." Short of
understanding the standard I see no other way to accomplish this.

Yet further, who says it's all MY code I have to understand?? Have you
never worked on something written by someone else? Have you never been
stuck trying to make heads or tails of some pile of spaghetti that some
lone wolf "expert" wrote? Guess you haven't since you never have to
look at the standard.

You can tell people that they don't need the standard all you want. I
strongly disagree. Your complaint that using the standard to make sure
code is compliant and to ascertain exactly what's wrong under certain
"limit" conditions is nothing but an opinion. I think it's a crock. I
suppose for those who don't care if they know C++ fully can get by
without the standard, but ANYONE that wants to develop expert level
knowledge absolutely needs it and every workplace should have a language
lawyer in it.

As to your insistence that my code, which you've never seen an example
of, would never pass review at your place of work...that's just a plain
ignorant statement. It tells me with absolute certainty that your
opinions are not at all based on fact or evidence but simply your own
thick headedness. It also tells me that, since you don't need the
standard, that standard compliance is not important at your place of
work and is not considered in review. It is certainly my opinion that
this should be a minor concern at the least (knowing full well it's way
too easy to write non-compliant code without knowing it until a compiler
upgrade or switch).

I'll let you know a little known secret: once you become so stubborn and
set in your ways that you can tell someone their code is shit without
even seeing it, your ability to learn anything new has become incredibly
limited. Hopefully you're correct in your assessment and have nothing
new to learn anyway. I doubt that very much though.
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top