K
Keith Thompson
Lew said:Keith said:[...]Arne Vajhøj said:Anyone that has read "Java for absolute beginners" know that
int's in Java are not objects and use the exact same number
of bytes as C (on platforms where C int is 4 byte).
Since this is cross-posted to comp.lang.java.programmer and
comp.lang.c, let me clarify that point.
C defines an "object" as a "region of data storage in the execution
environment, the contents of which can represent values". This has
nothing to do with object-oriented programming. Thus a declared
variable of type int certain is an "object" if you use the C
definition of the term. (Note that C++ uses a very similar
definition.)
I don't know how "Java" defines the term.
And I don't know why I put quotation marks around "Java".
That may be, but the context to which Arne replied and that you
excised claimed that Java has tons of memory overhead to represent an
'int' by virtue of being an object, which is a bloody falsehood.
And I'm sure that Arne was correct and the previous poster was wrong
on that point. That just didn't happen to be what I was commenting
on.
Clearly that poster was using "object" in the current conventional
computer-programming sense of the word, and not in your more
specialized frame.
Yes, clearly. But he did so in an article posted to comp.lang.c.
FYI, and it absolutely freaking *ASTOUNDS* me that anyone presuming to
call themselves a programmer today has not gotten familiar with
object-oriented programming at least enough to know what an object is,
I mean, come on, already! - an object in Java is exactly what it is in
any object-oriented programming environment. Roughly it's a struct
with built-in functions.
What makes you think I'm not familiar with object-oriented
programming?
I was making a relatively narrow point, that the term "object" can
have more than one meaning. Since this thread is cross-posted to
comp.lang.c (where we tend to use the C standard's definition of
"object") and comp.lang.java.programmer (where, quite reasonably,
I'm sure they use the Java definition of the term), I thought it
was a point worth making.
I just checked the Java language definition:
http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.3.1
An _object_ is a _class instance_ or an array.
So yes, an int variable in Java is not an "object" in the way that
Java defines the term. I'm not at all surprised to learn that,
nor did I say anything that implies otherwise.
And, as I mentioned, C++ (which is often considered to be an
object-oriented language) has a definition of "object" that's very
similar to the C definition; in C++, a variable of type int *is*
an object.
You really should expand your study. Start with the Wikipedia
definition, perhaps read Grady Booch. Being a C programmer is not a
good excuse. In fact, it's no excuse at all.
Excuse for what? (And I happen to program in C++ for a living;
I just don't discuss C++ in comp.lang.c.)