View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12940 Members
Join this group to post and comment.
radha gogia
radha gogia • Jan 12, 2015

What is the effect of primitive data types on the nature of programming languages?

why the languages which are having primitive data types in them are considered to be not purely object oriented ,why is said that any language which depends on such primitive data types has actually an involvement of the machine architecture and hence it is not called a pure-object oriented programming language
Anoop Kumar
Anoop Kumar • Jan 12, 2015
You might heard that "Using primitive type is faster and cost effective (memory+time) than using object oriented". This is the reason object oriented languages still allow primitive types.

Why it is faster and cost effective:
How class variable works:
When you declare String str = new String ("Z").
variable str will point to a memory location to an object. Now this object has it's own instance variable which creates an array of char to store the value passed in, i.e. : "ABC".
(And some other things whatever String class require to initialize and store the value).
For java see: code of String.java.

Now primitives:
When you declare a char c = 'Z'; . variable c will point directly to a memory location where char ' Z' is stored.
So obviously using char is faster and cheaper.

I hope this answers your question. Now, what's the pro and cons, dig it out 😉

PS: I suggest, not to get involved in pure or object oriented languages. They develop for usability not to fulfill criteria of something called Pure Object oriented or not.

Share this content on your social channels -