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

    radha gogia

    radha gogia

    @radha-BTDzli
    Updated: Oct 26, 2024
    Views: 1.4K
    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
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Anoop Kumar

    MemberJan 11, 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.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register