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

radha gogia

radha gogia

@radha-BTDzli Oct 26, 2024
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

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Jan 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.