When will C have an object model?

T

Thomas Matthews

Tech07 said:
When will C have an object model?
Please explain your definition of "object model"
and how you think it will pertain to the
C language.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
 
K

Kaz Kylheku

When will C have an object model?

C isn't an extensible programming language. So adding an object system to C
means that a new language is created (possibly one which has significant
backward compatibility).

This has already happened, quite long ago, and the results were given names
like C++ and Objective C.
 
L

ld

C isn't an extensible programming language.

You could be interested by

http://cos.cvs.sourceforge.net/viewvc/*checkout*/cos/doc/cos-draft-dls09.pdf

to see how C itself is extensible and can do better than Objective-C.
The C Object System is a C library which adds a rather complete object
model to C (like CLOS to Common Lisp) and allows to build component
(reusable generic object) that you can't built in C++ or Objective-C.

One great thing with C is that it _hasn't_ an object model and
therefore you can have your own. C is just missing two _syntactic_
extension to emulate subtyping and overloading (backward compatible)
and be qualified as an OO language.

cheers,

ld.
 
G

Guest

| When will C have an object model?

It doesn't need one. Applications may need one, but languages don't.
If you application needs one, choose a language that has one.
 
W

Wolfgang Draxinger

| When will C have an object model?

It doesn't need one. Applications may need one, but languages don't.
If you application needs one, choose a language that has one.

And even then you can choose any language you like. You'll just have a
little more work to do, implementing all the object system's backend stuff.

Or use a ready to use object system. For C there is GObject. (Please no
debates, GObject works and does it's job very well. In my experience GNOME
is a lot more stable than KDE, and I'm saying this as a mainly-KDE user).


Wolfgang
 
K

Kenny McCormack

Malcolm McLean said:
Opinion is moving against object-oriented programming.

Is it? I want to make it clear that I have no opinion on the subject,
nor any stake in the outcome. I am just curious.

But I will say this: The statement above looks like a political
statement - like you generally see in the political/religious (Yes, at
least in America, they are one in the same) groups. I.e., a "He said,
she said" situation. For example, you often see this (in fact, this and
variations of it are about all you do see in the political/religious
groups):

A: The Republican party is dead (marginalized, of no consequence).
Note that its standards bearer these days is Sarah Palin (snicker, snicker)

B: (No it's not) Surveys show that Americans are becoming more
conservative (pro-life, etc, etc)

So, what makes you think it (programming) is moving against OO?
 
K

Kenny McCormack

Malcolm McLean said:
Stuff I've read. You used to read plenty of articles attacking C++, but not
object-oritented programming itself. Now I've notice far more material
attacking the very concept of object oriented programming.

Dijkstra said "Object-oriented programming is an exceptionally bad idea
which could only have originated in California"

The Wikipedia entry on "object-oriented programming" has a list of critics.

I'd admit this isn't a very scientific survey, more an impression about they
way the wind is blowing.

OK. What do you think is going to be "the next big thing"?

BTW, the way these things go is that by the time business/industry has
firmly adopted something, that's the clue that it is time for the
academics and other smart people to disparage it and move on to "the
next big thing." I.e., down in the trenches (business and industry)
they seem to like OO just fine.
 
R

Richard Tobin

Malcolm McLean said:
Dijkstra said "Object-oriented programming is an exceptionally bad idea
which could only have originated in California"

If Dijkstra said it that's hardly evidence of opinion turning that
way, since he's been dead for years. And of course Dijkstra was
hardly a mirror of general opinion...

-- Richard
 
M

Mark Storkamp

ld said:
You could be interested by

http://cos.cvs.sourceforge.net/viewvc/*checkout*/cos/doc/cos-draft-dls09.pdf

to see how C itself is extensible and can do better than Objective-C.
The C Object System is a C library which adds a rather complete object
model to C (like CLOS to Common Lisp) and allows to build component
(reusable generic object) that you can't built in C++ or Objective-C.

I may be wrong about this, but I was always under the impression that
C++ and Objective-C were super sets of C. If that's true, how can it be
said that something can be done in C, but not C++ or Objective-C?

Or in a strict sense, would it be said that C++ and Objective-C
compilers are able to compile C code, but when doing so, they are not
actually C++ or Objective-C compilers at that moment in time.
 
K

Keith Thompson

Mark Storkamp said:
I may be wrong about this, but I was always under the impression that
C++ and Objective-C were super sets of C. If that's true, how can it be
said that something can be done in C, but not C++ or Objective-C?

C++ is very nearly a superset of C. There are valid C programs that
are not valid C++ programs, and there are even a few valid C programs
that are valid C++ programs with different semantics. But in general,
for a given valid C program, it's not difficult to convert it into
a valid C program with the same semantics that's also a valid C++
program with the same semantics.

Objective-C is said to be a strict superset of C.

I suspect what ld was saying is that the C Object System can be used
to do things that can't be done using the object-oriented features of
C++ or Objective-C. I can't comment on the accuracy of that claim.

Presumably the COS library could be compiled as C++ or Objective-C,
perhaps with some tweaks -- but that would be a rather odd thing to
do.
Or in a strict sense, would it be said that C++ and Objective-C
compilers are able to compile C code, but when doing so, they are not
actually C++ or Objective-C compilers at that moment in time.

No, they're still C++ or Objective-C compilers, and the programs
they're compiling are still C++ or Objective-C programs (that also
happen to be C programs).
 
L

ld

C++ is very nearly a superset of C.  There are valid C programs that
are not valid C++ programs, and there are even a few valid C programs
that are valid C++ programs with different semantics.  But in general,
for a given valid C program, it's not difficult to convert it into
a valid C program with the same semantics that's also a valid C++
program with the same semantics.

This is right. In principle, COS could be compiled by a C++ compiler
which support variadic macros. The underlying code is C89 and I do not
use C++ keyword.
Objective-C is said to be a strict superset of C.

Yes, but since COS provide a super-set of Objective-C features, I
choose to use 'self' (and self1, self2, ...) to reference message
receivers (objects) inside their methods. Therefore, I am compatible
with the C++ 'this' but not with the Objective-C 'self'. This could be
changed in a 1/2 day but I don't see any reason to combine COS and
Objective-C while I may try one day to combine C++ and COS. Now the
real problem is why should I combine different object models together?
What I am interested in C++, it's not its runtime object model, but
things related to subtyping, overloading and templates (static
features).
I suspect what ld was saying is that the C Object System can be used
to do things that can't be done using the object-oriented features of
C++ or Objective-C.  I can't comment on the accuracy of that claim.

Yes, this is what I wanted to mean.
Presumably the COS library could be compiled as C++ or Objective-C,
perhaps with some tweaks -- but that would be a rather odd thing to
do.
Right.


No, they're still C++ or Objective-C compilers, and the programs
they're compiling are still C++ or Objective-C programs (that also
happen to be C programs).

Right.

Cheers,

Laurent.
 
K

Keith Thompson

pete said:
I don't know about that.

It is possible that what a program does,
can depend only upon whether the compiler considers
it to be a C program or a C++ program.

That doesn't falsify my statement. Certainly the *behavior* of a
program can depend (in certain corner cases) on which language it's
cpomiled in. But a C++ compiler compiling a C program is still a C++
compiler, even if the behavior of the program differs from the
behavior if it were compiled by a C program.

And before anyone jumps in, we've already acknowledged that not all
legal C programs are legal C++ programs.

There's probably a long argument to be had about whether a C and C++
program with the same source code but different behavior are the same
program. I don't plan to participate in such an argument.
 
H

Herbert Rosenau

You can do object-oriented programming In C, but it is messy because there
is no syntactical support so things like inheritance have to be scratched up
from tables of function pointers.

Every so often someone comes up with some extensions to C, and an object
model is a common thing to add. C++ is the best-known example. There will be
other attempts, but none so far has been accepted into the core language,
and probably never will be. Opinion is moving against object-oriented
programming.

C++ is not really object oriented. On that I miss real classes, class
factories instead of renamed structs.

You likes to program object oriented? Really object oriented, not ony
C with renamed structs (classes)?

Then look for CORBA.


--
Tschau/Bye
Herbert

Visit http://www.ecomstation.de the home of german eComStation
eComStation 1.2R Deutsch ist da!
 
D

Default User

Herbert said:
Done already more than 15 years back.

Google for CORBA.

Truly object oriented - mor that C++ will ever be.


CORBA? How is that a C object model?




Brian
 
T

Tech07

Wolfgang Draxinger said:
And even then you can choose any language you like. You'll just have a
little more work to do, implementing all the object system's backend
stuff.

Or use a ready to use object system. For C there is GObject. (Please no
debates, GObject works and does it's job very well. In my experience GNOME
is a lot more stable than KDE, and I'm saying this as a mainly-KDE user).

Seems to contradict the purpose of a language standard. (You said, "just
write one instead of suggesting that the language standard should codify
existing practice for the purpose of getting widespread reuseability".)
 
T

Tech07

Kaz Kylheku said:
C isn't an extensible programming language. So adding an object system to
C
means that a new language is created (possibly one which has significant
backward compatibility).

This has already happened, quite long ago, and the results were given
names
like C++ and Objective C.

C could one up them though given that the aforementioned are the tired old
models.
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top