Hello,
I cant able to understand why c language is not object oriented.
Why have functions and variables if not?
Some sites saying that c language is object oriented programming language and some are saying it is not like that.
please help me
"C" is not an object oriented language. Its procedural language.
C is not OO language- because the creators wanted it to be the way it was designed.
Can you tell us which sites tell that C is OO? May be they are talking about Objective C?
A look at the timelines... C, the programming language started in the late 1960's or early 1970's. Object oriented programming took off in the late 1970's or the more conservative estimate, 1980's.
So, when C was invented, Object Orient Programming won't be invented yet for anothr 10 years. I think that it is safe to assume that C is *not* an object orient language.
sorry Henry, what about Lisp (70s) and Simula (-67) the predecessors of Smalltalk (-71)?
Even C++ itself is a kid of the 70s - Bell Lab's C w/ classes 1979 but 80s when it comes to the first commercial release (Glockenspiel 1985).
C has functions, not methods and there is no name space, just modules with 'private' functions declared 'static'.
What about defining a C 'struct' w/ void pointers holding functions and more pointers to other structures?
Wrap it all in macro definitions so the pre-processor extracts them to modules and voila, you have classes Well, inheritance and encapsulation still are problems then, but I'm sure you can fix that with macros as well.
In C there is no encapsulation and no inheritance, that what makes for me the main difference of OO versus Procedural languages.
Mohamed Sanaulla wrote:"C" is not an object oriented language. Its procedural language.
C is not OO language- because the creators wanted it to be the way it was designed.
Can you tell us which sites tell that C is OO? May be they are talking about Objective C?
yes absolutely....if c is not object oriented then what is objective c? we use objects in that....
siva chaitanya
Greenhorn
Joined: Jul 05, 2011
Posts: 10
posted
0
Paul Clapham wrote:Your title suggests that you believe that only object-oriented languages can have functions and variables. That is completely incorrect.
hello Paul, In Java object's internal state is stored in variables and exposes its behavior through methods. So Java is called as object oriented programming language. C language also have functions and variables but why it is not an object oriented programming language. That's my question actually.
siva chaitanya wrote:hello Paul, In Java object's internal state is stored in variables and exposes its behavior through methods. So Java is called as object oriented programming language.
You say "Java has variables and methods, and therefore we describe it as object-oriented"? Sorry, but I repeat, that is completely incorrect. That is in no way a definition of object orientation.
Siva - it's clear you don't understand what "object oriented" means. The Wikipedia article should clarify this for you.
"C" and "Objective C" are different languages, as are BASIC and COBOL, which also have a "C" in their names. What applies to one doesn't necessarily apply to the other.
siva chaitanya wrote:yes absolutely....if c is not object oriented then what is objective c? we use objects in that....
Objective C is an Object Oriented language that kept parts of C to ease transition and acceptance.
Java is an Object Oriented language that kept parts of C to ease transition and acceptance.
Could you, if you are seriously motivated, write ObjectOriented code in pure K&R C? Mostly. You could get close, but it would be a lot of work. You can write object oriented code in any good assembler if you are motivated.
Most modern use of Objective C is for IOS and OS-X development. If you look at the code, nearly all of the hard work is handled by the Apple frameworks. People do not write much complex "C code" in Objective C, but they could, as under it all, there is a boring old GCC compiler.
When the creators of C++ were thinking about the adoption of the new language and thinking about how to get existing C programmers to use the language, they decided to incorporate everything in the C language into C++ and to make it compatible with existing C programs.
At the end of the day, C++ could then be marketed and percieved as a "super-set". But in the beginning, C++ was a very different language than C.