OO and C: Still a Good Idea?

T

Tony

Objective C was an attempt to bring Object Orientation to C. At the time if
it's incarnation, the prevailing thought was that OO meant not only objects,
but sending messages to them, probably because of the increasing popularity
of event-driven GUIs at the time. (Note that Smalltalk was another muddling
of the two orthogonal concepts).

(At least the above is how I think about the technology of that time).

Personally, I think C is a great place to implement OO "on top of " and
moreso for having the luxury of analyzing the weak aspects of the C++ object
model. I would opt for a departure "new" language though rather than being
100% backward compatible with C (one of C++'s Achille's heels).

Is OO in C's future? Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

Tony
 
D

dj3vande

Objective C was an attempt to bring Object Orientation to C. At the time if
it's incarnation, the prevailing thought was that OO meant not only objects,
but sending messages to them, probably because of the increasing popularity
of event-driven GUIs at the time. (Note that Smalltalk was another muddling
of the two orthogonal concepts).

If everything happens synchronously in a single thread of control and
the sender/caller waits until the message/method processing is
complete, "sending a message" is EXACTLY EQUIVALENT TO "making a method
call on an object".
If you care enough, you can implement this (from either perspective)
with C as it currently exists. There are good reasons to want to do
this, but not very many of them.
If you want to build an object system instead of doing everything by
hand every time, there's a pretty good chance you're going to end up
with something that looks a lot like either Objective-C or C++
(possibly with different syntactic sugar), depending on which
perspective you're thinking in terms of.

Is OO in C's future? Who's for it?

If you want Java/ObjC/Smalltalk/CLOS/OCaml/Ruby/C++/whatever, you know
where to find it.


dave
 
J

JC

Sigh...

I would opt for a departure "new" language though rather than being
100% backward compatible with C (one of C++'s Achille's heels).

It's not 100% backward compatible.
Is OO in C's future?

OO programming is in C's present, in fact. Other languages have
constructs that make it more convenient, but nothing limits you from
OO style programming in C.
Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

You will likely find inspiration here:

http://ldeniau.web.cern.ch/ldeniau/cos.html

That's Laurent Deniau's take on it, which recently came up in yet
another incarnation of a somewhat similar discussion on c.l.c++:

http://groups.google.com/group/comp.lang.c++/browse_frm/thread/83ec35fb1ade5f05

Jason
 
F

Frank

Objective C was an attempt to bring Object Orientation to C. At the time if
it's incarnation, the prevailing thought was that OO meant not only objects,
but sending messages to them, probably because of the increasing popularity
of event-driven GUIs at the time. (Note that Smalltalk was another muddling
of the two orthogonal concepts).

(At least the above is how I think about the technology of that time).

Personally, I think C is a great place to implement OO "on top of " and
moreso for having the luxury of analyzing the weak aspects of the C++ object
model. I would opt for a departure "new" language though rather than being
100% backward compatible with C (one of C++'s Achille's heels).

Is OO in C's future? Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

Tony

Tony,

This is an example of a troll. You are not a troll, if I'm to judge.
Furthermore, I refuse to judge.

Ask how OO's going in fortran right now: It's a pain in the ass, but it
basically works if you're not doing anything fancy.

OO would be a disaster for C. Enough decision makers concur so that the
proposal is a compleat non-starter. I hope it never happens, so that I
have some hook in a language that Bjarne hasn't forked up.

I'm trying out a new 'nym and am much distressed to see this output.
--
Frank

The biases the media has are much bigger than conservative or liberal.
They're about getting ratings, about making money, about doing stories that
are easy to cover.
~~ Al Franken,
%
[G. W. Bush's] pro-air pollution Clear Skies Initiative is designed to
clear the skies of birds.
~~ Al Franken,
%
And just like in 1984, where the enemy is switched from Eurasia to
Eastasia, Bush switched our enemy from al Qaeda to Iraq. Bush's War on
Terror is a war against whomever Bush wants to be at war with.
~~ Al Franken,
%
Mistakes are a part of being human. Appreciate your mistakes for what they
are: precious life lessons that can only be learned the hard way. Unless
it's a fatal mistake, which, at least, others can learn from.
~~ Al Franken,
%
In many ways I'm still a Hubert Humphrey Democrat -- someone who believes
in afflicting the comfortable and comforting the afflicted. A society is
judged by how it treats the elderly, the sick, the impoverished. To me it's
a matter of ethics and compassion.
~~ Al Franken, Playboy interview
%
When you encounter seemingly good advice that contradicts other seemingly
good advice, ignore them both.
~~ Al Franken,
%
And by the way, a few months ago, I trademarked the word 'funny.' So when
Fox calls me 'unfunny,' they're violating my trademark. I am seriously
considering a countersuit.
~~ Al Franken, in response to Fox's copyright infringement lawsuit
%
The irony upon irony of this lawsuit was great. First, Fox having the
trademark 'fair and balanced' -- a network which is anything but fair and
balanced. Then there's the irony of a news organization trying to suppress
free speech.
~~ Al Franken, CNN interview
%
[Roger Ailes, Fox News Founder, Chairman and CEO, and former
Nixon-Reagan-Bush strategist, is] a cynical Republican ideologue with no
regard for fairness and balance.
~~ Al Franken,
%
I once asked the most fabulous couple I know, Madonna and Guy Ritchie, how
they kept things fresh despite having been married for almost seven months.
'It's a job, Al,' Guy told me. 'We work at it every day.'
~~ Al Franken,
%
A brief digression on whether that suspicious-looking mole is actually
cancer. ... Take this simple test called the ABC test. 'A' is for age. What
is your age? Is it over thirteen? If so, it's cancer. That's how the ABC
test works.
~~ Al Franken,
%
[Newt Gingrich] is the most unpopular politician in America. His favorable
rating is only four points higher than the Unabomber.
~~ Al Franken, 1996
%
I said that Sean Hannity took residence up Newt Gingrich's butt from 94 to
98. I got that from British intelligence. It turns out he only took up
residence in 95.
~~ Al Franken
%
I do personal attacks only on people who specialize in personal attacks..
~~ Al Franken, Playboy interview
%
There's no liberal echo chamber in this country. There's a right-wing echo
chamber. I want to create a countervailing echo chamber.
~~ Al Franken, Chicago Tribune interview, on
%
I think some people hold [G.W.Bush] in high esteem because they watch Fox.
And they get their news from Rush Limbaugh. And they are fooled.
~~ Al Franken, in response to the 2004 SOTU address
%
No Child Left Behind is the most ironically named act, piece of legislation
since the 1942 Japanese Family Leave Act.
~~ Al Franken, in response to the 2004 SOTU address
%
I think if you're going to do a movie about Reagan you do it about the fact
that he created the huge deficit, that he armed the mujahadeen, that he
armed Saddam, that he armed Iran, he armed 2/3s of the Axis of Evil, he
funded terrorists in Central America, he was in my mind a terrible
president.
~~ Al Franken, Book TV, on CBS's Reagan movie
%
During the Reagan Administration, Bob Dole was present at a ceremony that
included each living ex-president. Looking at a tableau of Ford, Carter and
Nixon, Dole said, 'There they are: Hear No Evil, See No Evil and Evil.'
~~ Al Franken,
%
If you put the two Bushs together in their over seven years of their two
presidencies, not one new job has been created. Numbers do not lie. If you
extrapolated from that, if the Bushs had run this country from its very
beginning to the current time, not one American would have ever worked.
We'd be hunter-gatherers.
~~ Al Franken, in response to the 2004 SOTU address
%
Most of us here in the media are what I call infotainers...Rush Limbaugh is
what I call a disinfotainer. He entertains by spreading disinformation.
~~ Al Franken
%
Drug war, well, as Rush Limbaugh said, anyone who uses drugs illegally
should be prosecuted and put away. I don't agree with him; I think they
should be treated, but that's what Rush believes and so, you know, we're
praying for Rush because he's in recovery and you take responsibilities for
your actions so I'm sure any day now Rush will demand to be put away for
the maximum sentence and ask for the most dangerous prison and we'll be
praying for maybe an African American cellmate who saw the Donovan McNabb
comments on ESPN. So we're prayin'.
~~ Al Franken, Book TV, on Rush Limbaugh's illegal drug arrest and racist
remarks
%
If [Stuart Saves His Family] had actually been successful it would have
been a lot better teacher for me than the failure that it was, because it
would have given me the opportunity to do more movies,
~~ Al Franken, CNN interview
%
It's the Power of the Almighty, the Splendor of Nature, and then you.
~~ Al Franken
%
A concussion.
~~ Al Franken, Playboy interview, when asked what it would take for his
name to appear on the masthead of National Review or The Weekly Standard.
%
Oh, What Doesn't Kill You Can Have Lingering Aftereffects!
~~ Al Franken,
%
That's just stinkin' thinkin!
~~ Al Franken,
%
Listen to me. I'm should-ing all over myself.
~~ Al Franken
%
Whining is anger through a small opening.
~~ Al Franken
%
I'm good enough, I'm smart enough, and doggone it, people like me.
~~ Al Franken
%
I'm going to die homeless, penniless, and 30 pounds overweight.
~~ Al Franken
%
It's easier to put on slippers than to carpet the whole world.
~~ Al Franken
%
I would never ordinally say this, but... is there any way you can get to a
pound cake?
~~ Al Franken
%
I'm a perfectionist and if I start making changes, I'll never stop.
~~ Al Franken
%
My father grew up in the Great Depression - his mother's.
~~ Al Franken
%
....it's obviously how his disease manifests itself, any kind of substance
dependency is very deep, issues of self esteem, you can just tell that he's
a really insecure and vulnerable person -- and I love him. You know,
sometimes I listen to him on the radio, and he's very judgmental, he's a
very angry person, and I just want to remind him that anytime you have a
finger pointing at someone else, there's three pointing back at you.
~~ Al Franken
%



Picture of the Day http://apod.nasa.gov/apod/
 
U

user923005

Objective C was an attempt to bring Object Orientation to C. At the time if
it's incarnation, the prevailing thought was that OO meant not only objects,
but sending messages to them, probably because of the increasing popularity
of event-driven GUIs at the time. (Note that Smalltalk was another muddling
of the two orthogonal concepts).

(At least the above is how I think about the technology of that time).

Personally, I think C is a great place to implement OO "on top of " and
moreso for having the luxury of analyzing the weak aspects of the C++ object
model. I would opt for a departure "new" language though rather than being
100% backward compatible with C (one of C++'s Achille's heels).

Is OO in C's future? Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

If we want a C that has OO abilities, we have Objective C and C++.
An object model is not always the best possible solution.
Sometimes a procedural model fits more naturally.

I think it is a mistake to try to warp the native C language into an
OO model, since we already have those attempts.

I don't think anybody knows what the future of C is.
I think that when we try to guess, we usually get it wrong.
 
L

Laurent Deniau

Objective C was an attempt to bring Object Orientation to C. At the time if
it's incarnation, the prevailing thought was that OO meant not only objects,
but sending messages to them, probably because of the increasing popularity
of event-driven GUIs at the time. (Note that Smalltalk was another muddling
of the two orthogonal concepts).

(At least the above is how I think about the technology of that time).

Personally, I think C is a great place to implement OO "on top of " and
moreso for having the luxury of analyzing the weak aspects of the C++ object
model. I would opt for a departure "new" language though rather than being
100% backward compatible with C (one of C++'s Achille's heels).

Is OO in C's future? Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

Tony

for a short introduction you can read:

http://cos.cvs.sourceforge.net/viewvc/cos/CosBase/share/doc/cos/slides-cos.pdf.gz

for a longer but a bit obsolete:

http://cos.cvs.sourceforge.net/viewvc/cos/CosBase/share/doc/cos/cos-overview.pdf.gz

What is missing to C to do OOP is not an object model (various can be
implemented) but features related to (already proposed) extensions to
C like anonymous structure component or type _Alias (!= typedef).
These features would improve the syntactic sugar of OO in C but the
concepts can already be implemented in C.

a+, ld.
 
B

Bartc

I would opt for a departure "new" language though rather than being 100%
backward compatible with C (one of C++'s Achille's heels).

You want a new language, not compatible with C, that has OO?

There isn't enough choice out there?
 
T

Tony

If everything happens synchronously in a single thread of control and
the sender/caller waits until the message/method processing is
complete, "sending a message" is EXACTLY EQUIVALENT TO "making a method
call on an object".

When I think of "sending a message", I think of something like:
SendMessage(destination, "Hello Chatters!").
If you care enough, you can implement this (from either perspective)
with C as it currently exists. There are good reasons to want to do
this, but not very many of them.

1. The defficiency of other implementations.
If you want to build an object system instead of doing everything by
hand every time, there's a pretty good chance you're going to end up
with something that looks a lot like either Objective-C or C++
(possibly with different syntactic sugar), depending on which
perspective you're thinking in terms of.

There's more than syntax that is of issue.
If you want Java/ObjC/Smalltalk/CLOS/OCaml/Ruby/C++/whatever, you know
where to find it.

Part of my point was that those languages leave something to be desired and
C can "one up" them all if "it" wanted to.

Tony
 
T

Tony

Sigh...

I would opt for a departure "new" language though rather than being
100% backward compatible with C (one of C++'s Achille's heels).

"It's not 100% backward compatible."

Still, backwards compatibility hinders C++, IMO.
Is OO in C's future?

"OO programming is in C's present, in fact. Other languages have
constructs that make it more convenient, but nothing limits you from
OO style programming in C."

First class support is what I was talking about. The cliche you presented
above gets quite annoying (as do all cliches).
Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

"You will likely find inspiration here:

http://ldeniau.web.cern.ch/ldeniau/cos.html"

I downloaded that yesterday, but haven't read it yet.

"That's Laurent Deniau's take on it, which recently came up in yet
another incarnation of a somewhat similar discussion on c.l.c++:

http://groups.google.com/group/comp.lang.c++/browse_frm/thread/83ec35fb1ade5f05"

Yes, I've been tracking that thread.

Tony
 
T

Tony

Frank said:
Tony,

This is an example of a troll. You are not a troll, if I'm to judge.
Furthermore, I refuse to judge.

I wasn't trolling. I have a number of techniques that I use in C++ to get
closer to my "ideal language". Now I'm analyzing whether C wouldn't be a
better jumping off point to base a new OO-capable language on. I want to
develop (perhaps) a proprietary/in-house language to use rather than
something for mass consumption.
OO would be a disaster for C.

Yes because of the backward compatibility thing. But a language that
jettisons most (not all) of that seems lucrative to me. Most people take it
too far though and end up with yet another C++ level language rather than
something in between C and C++. IMO, that sweet spot has never been attained
by any language. YMMV.
I'm trying out a new 'nym and am much distressed to see this output.

I don't grok that.

Tony

P.S. Your tagline is abusively long!
 
T

Tony

Objective C was an attempt to bring Object Orientation to C. At the time
if
it's incarnation, the prevailing thought was that OO meant not only
objects,
but sending messages to them, probably because of the increasing
popularity
of event-driven GUIs at the time. (Note that Smalltalk was another
muddling
of the two orthogonal concepts).

(At least the above is how I think about the technology of that time).

Personally, I think C is a great place to implement OO "on top of " and
moreso for having the luxury of analyzing the weak aspects of the C++
object
model. I would opt for a departure "new" language though rather than being
100% backward compatible with C (one of C++'s Achille's heels).

Is OO in C's future? Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

"If we want a C that has OO abilities, we have Objective C and C++."

I have issues with both of those though (which I won't go into here and I
haven't looked at Objective C for years but probably should do so again
given my current needs).

"An object model is not always the best possible solution."

There's that annoying cliche again.

"I think it is a mistake to try to warp the native C language into an
OO model, since we already have those attempts."

Yes we do. I would just use C as a starting point create a new language that
is not nearly as concerned with backward compatibility. (Interfacing DLLs
would still be important for one thing).

"I don't think anybody knows what the future of C is."

A relic in the Smithsonian may be quite nice.

Tony
 
T

Tony

Malcolm McLean said:
I'd do something like the Windows model. You have a central message queue,
and windows register themsleves with the system. Events then get placed
into the queue and called on the windows, one at a time.

Replace "window" with "object" and you've got an OO system.

Ewww. Then you have Smalltalk and the muddling of "event-driven/msg-based"
with OO. That works for windows but is hardly always appropriate.

Tony
 
T

Tony

Bartc said:
You want a new language, not compatible with C, that has OO?

Yes. But that is very C-like and doesn't go overboard like C++ does, IMO.
There isn't enough choice out there?

Apparently not. That's why I'm considering rolling my own.

Tony
 
T

Tony

Les Harris said:
Cos was already mentioned but GObject <http://library.gnome.org/devel/
gobject/unstable/> might be of interest to you as a heavily used C-based
OO system.

In general, it provides most C++-type OO features albeit in a more clunky
way.

That's the 3rd time it's been mentioned. I'll read the pdf later today.
The functionality you want is here today.

I'm still skeptical as I have been searching.

Tony
 
J

JC

Sigh...



"It's not 100% backward compatible."

Still, backwards compatibility hinders C++, IMO.

Not really.
"OO programming is in C's present, in fact. Other languages have
constructs that make it more convenient, but nothing limits you from
OO style programming in C."

First class support is what I was talking about. The cliche you presented
above gets quite annoying (as do all cliches).

Ask a cliche question, get a cliche answer.

It's a cliche because it's repeated again and again and again. The
reason it's repeated again and again and again is because uninformed
posters / trolls forget that and post the same questions again and
again and again.

HTH,
Jason
 
D

dj3vande

[note followups]

When I think of "sending a message", I think of something like:
SendMessage(destination, "Hello Chatters!").

That's not what Smalltalk or ObjectiveC people are talking about when
they talk about "sending a message to an object".
Do you know anything at all about what you're talking about?

1. The defficiency of other implementations.

OK, I'll bite.
What deficiencies do you see in CLOS that you think you can build a new
system without, without introducing new ones that are worse?

There's more than syntax that is of issue.

Well, yeah. And if you actually look at what the options are, you'll
notice pretty quickly that there are good reasons why the semantics are
what they are.
If you want to do something different, your chances of getting
something that that actually is substantially different and even
*works*, never mind is better, are pretty small.


If somebody gives you an object system, can you give good reasons why
it's inadequate and how you plan to improve on it? (Prove it - start
with CLOS, as mentioned above.) If somebody gives you a base system,
can you give good reasons why it's better than C as a base to build
on? (Prove it - start with Erlang.)
If you want to make something "better" than what already exists, it
would help to understand what already exists.


dave
 
C

CBFalconer

JC said:
Ask a cliche question, get a cliche answer.

It's a cliche because it's repeated again and again and again.
The reason it's repeated again and again and again is because
uninformed posters / trolls forget that and post the same
questions again and again and again.

No. Every newbie obviously knows how to access the various storage
areas and review all the mislabelled messages that discuss the
subject of interest. He also knows how to avoid the suppression of
messages by the silly no-access header, because he knows who
ignores it. So there is obviously no reason for any question to
ever be re-asked.
 
C

Chris M. Thomasson

Tony said:
Objective C was an attempt to bring Object Orientation to C. At the time
if it's incarnation, the prevailing thought was that OO meant not only
objects, but sending messages to them, probably because of the increasing
popularity of event-driven GUIs at the time. (Note that Smalltalk was
another muddling of the two orthogonal concepts).

(At least the above is how I think about the technology of that time).

Personally, I think C is a great place to implement OO "on top of " and
moreso for having the luxury of analyzing the weak aspects of the C++
object model. I would opt for a departure "new" language though rather
than being 100% backward compatible with C (one of C++'s Achille's heels).

Is OO in C's future? Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other relevant
thoughts also as this is just a brainstorming post).

FWIW, here is a very simplistic OO abstract interface scheme for C:

http://groups.google.com/group/comp.lang.c/browse_frm/thread/1b106926ba5db19f




The link to the code in the post is broken. Here is fixed link:

http://webpages.charter.net/appcore/vzoom/example/interface.zip




Sorry about that.
 
C

Chris M. Thomasson

Chris M. Thomasson said:
Tony said:
Objective C was an attempt to bring Object Orientation to C. At the time
if it's incarnation, the prevailing thought was that OO meant not only
objects, but sending messages to them, probably because of the increasing
popularity of event-driven GUIs at the time. (Note that Smalltalk was
another muddling of the two orthogonal concepts).

(At least the above is how I think about the technology of that time).

Personally, I think C is a great place to implement OO "on top of " and
moreso for having the luxury of analyzing the weak aspects of the C++
object model. I would opt for a departure "new" language though rather
than being 100% backward compatible with C (one of C++'s Achille's
heels).

Is OO in C's future? Who's for it? What are the minimal features to get
"adequate" OO capability in the language? (Feel free to add other
relevant thoughts also as this is just a brainstorming post).

FWIW, here is a very simplistic OO abstract interface scheme for C:

[...]

http://groups.google.com/group/comp.lang.c++/msg/6002fd4047cbbe1c
 
J

JC

... snip ...




No.  Every newbie obviously knows how to access the various storage
areas and review all the mislabelled messages that discuss the
subject of interest.  He also knows how to avoid the suppression of
messages by the silly no-access header, because he knows who
ignores it.  So there is obviously no reason for any question to
ever be re-asked.

I do not quite understand what you are saying, but Tony does not seem
to be a "newbie". Additionally, it is highly unlikely that I was
referring to all repetitive questions on any topic in general, and
highly likely that I was referring to this specific thread.

Jason
 

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,954
Messages
2,570,116
Members
46,704
Latest member
BernadineF

Latest Threads

Top