Need a C++ book for complete idiot!

J

jacob navia

Andy Champ a écrit :
I am familiar with neither of the two gentlemen. However, I must
disagree with you on that.

My understanding (and I'm prepared to be corrected on this) is that when
you write

double a = 12.345;

you are requesting the compiler to produce a value in the variable "a"
which is the double equivalent nearest to 12.345.

True

You are not forcing the compiler to do this; an optimiser may decide to
remove the statement completely.

Maybe

You are certainly not instructing it to initialise it by loading it from
a constant of that value.

Sure you do. At the start of the function the code will execute a load
from a 64 bit constant in the general case. If the compiler can prove
that a float (or even an integer) would do, maybe it does emit other
ionstructions. But in the *general* case you load a 64 bit constant from
memory with the FPU, then you store it in the address of the variable a.
Certain constant values are best produced in
different ways. In the Intel/Microsoft world (which is the one I'm most
familiar with) this statement would probably result in a load into an
FPU register from a single precision float in memory.

Exactly. Here you say that I am right...
It almost
certainly would not load a 64-bit memory location - which is what a
double is - with a value, because intermediate computations are carried
out in 80-bit registers.

The FPU can load 80 or 64 or 32 bit floats with different
opcodes.
Sadly I can offer no good texts for non-programmers in C++. If you want
some hints for Java I can get them - I barely know the language myself,
but my son has just finished his degree!

Andy


Yeah... The next generation will probably use something else.

Thank you for your contribution Andy.

jacob
 
B

Balog Pal

Stuart Golodetz said:
Not sure quite what you're saying here, sorry! I was just trying to answer
Andrew's question as to why universities might prefer to teach in Java
rather than C++ - I think it's because C++ obscures what they're trying to
teach

Sure. And so does Java.
(generally NOT a specific language) in a bog of extraneous language
details.

Then how Java enters the picture?
Personally, I find all the intricate details of the language
interesting - but I can see why lecturers might not pick it as their
language of choice.

Sor those very reasons normal teachers used syntax- and baggage-free
languages like lisp, later python.

Java is just bad on this field too.
This doesn't mean that I think there's anything wrong with learning C++ as
your first programming language - I don't.

LOL. I definitely do. ;-) C++ is created by evolution, and to solve [not
listed] problems by people who already know programming. It has much stuff
picked up as 'compromissum', especially compatibility with C (that picked
compatibility with ... going far back and arbitrary stuff of the time), what
sucks blood on use too -- dealing with all those obstracles while one should
concentrate to learn programming is simply not good.

Java is not created by evolution, it was created with freedom starting from
scratch, but had no fortune with having poor quality fathers lacking both
knowledge and wisdom. And later editions were not brave enough to make a
good turn, so by now it gained back most of the stuff that was cut foe
'being confusing' just in a crippled form without the power.
If you do, though, you should be prepared to learn a lot about the
language (and your tools) to avoid shooting yourself in the foot. There
are other languages that are more forgiving to beginners.

'Forgiving' is probalby bad -- or worse. The most important stuff to
learn is the discipline, and sticking to correctness. Clear feedback on
going wrong is the student's best friend.
Incidentally, I also think it would be a good thing if universities did
teach more C++,

I'd be overly glad if unis could at least teach reasonable general approach
to programming, to creation of software, creation of a system, etc. My
experience is quite sour this far -- the few people I know as good
practicioners did not learned it from teachers in university -- more like
took very different education, or got good *despite* the teachers and
courses.

I also experienced big amount of arrogance in people with CS-like diplomas,
while they in practice lacked the most basic knowledge. The purpose of an
university would be to open horizons and provide the very ooposite:
humility, and means to progress in learning.
since it's a language in widespread use in many branches of industry (e.g.
my major interest of game development). I don't think that should be at
the expense of existing courses in things like object-oriented
programming, however.


What I should have said is that it's arguably easier to learn about e.g.
object-oriented programming in Java than in C++.

A beg to differ -- just because java's single idiom is OO does not create an
edge. You can do the same things in C++, and it is easy to create dialect or
environment that is ways better than java is or can be made. The amount
of "magic incantations" to use would not differ much.

In java you dont'd have destructors and value semantics. So you are forced
to deal with all the pointer-related madness, and without much help from the
system that would allow 'self-managing' objects.

And if you teach not OO? Guess OO is not a very good starting point. ;-)
you get completely hosed immediatly.
Whilst it can be argued that the ease of *teaching* shouldn't be a factor,
the ease of learning clearly should be - if you can communicate something
in two different ways, you're better off picking the way which makes you
more easily understood (assuming you want to be understood, that is). So
teaching you OOP in Java makes sense.

IMO that is the usual delusion that is repeated over and over without much
motivation to verify the truth behind. Connections do not work that way,
and the worls is NOT limited to C++ and Java, so if C++ turns out poor for
learning will not make java win. In either absolute or relative way.
Unfortunately the side-effect is that you get less exposure to languages
like C++ which you might be using in your job - which is why I think they
should teach you C++ as well. Time constraints, though, I guess...!

The side effect is way more than that -- read 'perils of javaschools' of
Joel Spolsky.
 
B

Balog Pal

jacob navia said:
I do not know him either. What bothers me is these general personality
destruction gatherings where a guy is given to pasture and
destroyed by a MOB!

Perviously you stated millions supported him by buying books.

Just for curiosilty: did YOU read his books and find them useful enough to
personally recommend for the purpose in question?
 
B

Balog Pal

"Andy Champ"
And you're right there. But if the compiler chooses to initialise the
80-bit register, which it's using as an internal approximation of a
double, with a 32-bit float because it's close enough, where in memory is
the double 12.345?

Or if you used some special values (0, 1, pi... ) those could be loaded by
opcodes taking no argument at all. ;-)
As you pointed out in your reply to SG, there's something - in that case,
a shift left 5 - which produces the desired value. The actual value
doesn't need to be there at all.
So going back to the statement

## An object is either a variable or a constant that resides at a
## physical memory address.

this is demonstrably false - a constant does not need to be at any memory
address. The constant 32 that SG produced from his code, and the constant
12.345 used to initialise "a" in your example are not in memory anywhere.

Yea.

Though the statement did not claim that every constant is in memory. It
paraphrases the standard's definition of 'object'. What IIRC is like
'region of storage'.

So proving that constants can live elsewhere only leads to 'so then such
constants are not (necessarily) objects' (in C/C++ sense)'. and if you
try to "prove" it within the language, and say take the address to print
out -- the compiler will restrict to code where storage actually exists
I'd also point out that an object with no virtual methods (hence no vtbl)
and no data has zero size in memory.

That is a pretty different use of term 'object' and has little to do here
besides confusing. ;-)
 
J

James Kanze

Alf P. Steinbach a écrit :
Look, I went there, and I landed
inhttp://www.lysator.liu.se/c/schildt.html
There, I can read:
<quote>
3.14
## An object is either a variable or a constant that resides at a
## physical memory address.
In C, a constant does not reside in memory, (except for some string
literals) and so is not an object.
<end quote>
This is completely wrong. Outside some constants that are
inlined by the compiler because the processor supports inlined
constants, all other constants are just like a character
string.

Not according to the C standard. The language isn't really
concerned that much with implementation details, and obviously,
at some point or another, even a constant must appear somewhere
in memory (e.g. as part of a load immediate instruction). But
an object (both in C and in C++) has an address, and literals,
except for string literals, don't have an address.
For instance in a x86 implementation:
double a = 12.345;
The double constant 12.345 will reside in memory. The same for
long double constants, for structures initialized by
constants, for 64 bit constants, etc etc.

Maybe, maybe not. How one implementation works is irrelevant to
the language.
The only constants that are initialized inline are the inlined
constants accepted inline by the processor (in the code
stream)

Schild is right and Mr Feather (that I respect of course) is
wrong.
No.

Mainly the other criticism are matters of style, where Mr
Feather differs from Mr Schildt. He would have more explained
about the standard, more precise stuff, etc.
For instance Schildt says:
this limits the total character set to 255 characters.
and Feather criticises:
Actually, it limits it to UCHAR_MAX characters, which is at
least 255, but can be more.
Great. Obviously Feather is pedantically right, but is it very
important?

It depends on the context. When commenting the ISO standard, it
is very important.
 
J

James Kanze

On 09/08/2009 07:35 PM, Jorgen Grahn wrote:

[...]
OTOH, I could not resist warning, that Bjarne Stroustrup,
Brain W. Kernighan and Denins M. Richie are not teachers;
their books might be good for the mature programmers, but
these lack good and useful examples from practical life.

In the case of Stroustrup, this is not true; he happens to be a
professor at Texas A&M. And his book "Programming -- Principles
and Practice Using C++" is the best introductory text to C++,
and to programming in general, that I know of, by far.
 
S

SG

SG a écrit :







You see the $5 there?
No?
You need better glasses...
:)
2 ^ 5 is 32.

I salute to you! (Did you seriously think I wasn't aware of this?)

Ok, what was the point of this exercise? I don't know. It actually
hasn't anything to do with the point I was trying to make because this
is an example produced by some implementation of the standard. The
standard text is more abstract and describes a specific model and a
terminology ("objects", "rvalues", "lvalues", "constant expressions",
etc etc). If you check the standard you'll see that a constant
expression like

12.345

is a scalar rvalue which, by definition, doesn't refer to a memory
location. It's just a value as far as the language is concerned. Sure,
constants somehow affect the machine code (when used) but they are not
required to have an address / be an "object" with respect to the
standard's definition of "objects". Implementation is a different
story -- a story that doesn't belong into an annotated programming
language reference.
OK. At least you have the honsety to acknowledge that without
starting to denigrate him without even knowing what he writes.

I actually read about 60% of the site you linked to and I have to say
I'm impressed. I'm assuming that the reviewer hasn't made anything up
and quoted correctly. Some comments really point out horrible
misunderstandings. Other comments may seem over-pedantic. Still, it's
supposed to be an annotated reference and not just a tutorial, for
God's sake.

Cheers!
SG
 
M

me

SG said:
Probably. But this is not what it's about. As far as the language is
concerned, this literal is a scalar rvalue and as such it refers to a
value and not to a memory location like an LValue or a class-type
RValue.

you guys are talking WAY over my head!
 
F

Francesco

you guys are talking WAY over my head!

Don't worry, simply ignore the posts you don't understand - those
posts aren't strictly on-topic here in your thread, all those people
are simply continuing a long debate that comes from comp.lang.c,
they've just changed the battlefield and acquired some other
contestant to both parties.

One day you'll be able to understand what they're talking about, till
then I suggest you to get along without interfering - which would be
just what I'm doing: most of it runs over my head just like over
yours.

Cheers,
Francesco
 
R

rabbits77

I'm trying to teach myself some C++

I have NO programming experience...... none....
zip...... null

Can you guys recommend a book for someone on my level I
can buy from Amazon?
I really like
Practical C++ Programming
from O'Reilly.
Author is Steve Oualline.
 
J

Jerry Coffin

[ ... ]
If that is true, then why do the vast majority of universities teach
first year computer science students in Java, and not C++ ? I'm sure
the professors setting the curriculum are quite familiar with C++, so
we must conclude that they would disagree with your position, right?

The choices of languages to teach at universities are affected by
quite a few factors -- and while the quality of the language _is_ one
of those factors, it's usually a fairly minor one.

First, most decisions at most universities are made by committees.
Committees _tend_ to make decisions that are relatively "safe". The
final decision is rarely the one that the most people favor --
instead, it's the one that the fewest people find strongly
objectionable. Of course, there are exceptions to this, especially if
one faculty member is sufficiently well known that few feel
comfortable arguing against his (sometimes presumed rather than
expressed) opinion.

Second, and this interacts strongly with the first, universities tend
to have two largely opposed tendencies. On one hand, they want to
teach the fundamental of computer science -- basic algorithms,
complexity, and so on. For this, the best choice is probably Lisp or
something very similar. OTOH, they also tend to be under pressure to
teach things that will be of direct, immediate use to their students
upon graduation -- prepare them for the real world. Teaching C++ is
generally seen as bowing to this pressure. To many, Java represents a
"balanced choice" -- fairly abstract, but also widely used.

Third, universities are subject to fashion as much as almost anybody
else. Their choices are often as much about projecting an image as
anything else. When Sun started pushing Java, one thing they did was
(largely successfully) attempt to portray essentially all existing
choices as dated and old fashioned. Teaching a language that wasn't
"designed for the information superhighway" was as passé as poodle
skirts or bell-bottoms...
 
A

Anand Hariharan

On 09/08/2009 07:35 PM, Jorgen Grahn wrote:

    [...]
OTOH, I could not resist warning, that Bjarne Stroustrup,
Brain W.  Kernighan and Denins M. Richie are not teachers;
their books might be good for the mature programmers, but
these lack good and useful examples from practical life.

In the case of Stroustrup, this is not true; he happens to be a
professor at Texas A&M.  And his book "Programming -- Principles
and Practice Using C++" is the best introductory text to C++,
and to programming in general, that I know of, by far.

I think it has been around a year since it's published, but somehow it
has not received as much recognition as other books targeted for the
same audience.

- Anand
 
J

Jorgen Grahn

Jorgen Grahn a écrit :
A word of warning: a lot of people would characterize Schildt's books
as books that /make/ you an idiot programmer.

What ?

Schildt is a world-recognized authority on programming. They have been
translated into all major foreign languages. [...]

This character assasination orchestrated by some obscure zealots in
usenet like this "Jorgen Grahn" of world fame can't go on like this.

I probably should just ignore things like this and just add to my
killfile, but one thing: I am not part of some conspiracy against
Schildt: I am just saying his books have an unusually bad reputation,
thus suggesting that this newbie should investigate that before buying
what "capricorn" suggested.

But yes, I should probably have avoided the word "idiot". It was a
word play on the subject line.

/Jorgen
 
P

ptyxs

To go back to the initial question, I think one of the best books to
begin studying C++ is the recent work by Bjarne Stroustrup (which is
NOT "The C++ programming language") :

Programming Principles and Practise Using C++

specifically written for beginners, and even for self-studying
beginners. Have a look at the interesting support website, with
corrected exercises and errata, and where you can read the whole
Preface of the book :

http://www.stroustrup.com/Programming/
 
P

ptyxs

And by the way, do any of you know the following book, also written
for beginners :

Absolute C++ by Savitch
what do you think about it ?
 
N

Nick Keighley

On Sep 8, 5:51 am, (e-mail address removed) wrote:




If you really have no programming experience whatsoever, C++ is a
really bad language to start with.  I would start by using a scripting
language to write and test some little programs.  

If by "scripting" I'd exclude most shell scripts and perl
as good places for beginners to start. Python maybe.

You can do this inside a web browser even:

   http://tryruby.sophrinix.com/

After that, I would move onto an OO language with a large standard
library and standard garbage collection like Java or C#.

yuk. Do you want you mind controlled by Mordor or Isengard?
 
B

Balog Pal

Victor Bazarov said:
I don't believe area of land or a castle can control anyone's mind. It's
another *mind* (sometimes collective) that can do that.

Ahem, and the masters of those places were pretty good at control...
 
V

Victor Bazarov

Balog said:
Ahem, and the masters of those places were pretty good at control...

It seems unfair for the places (and their population) to get bad rap
just because they once were ruled by evil...

V
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top