I am new to javascript and still cannot understand the difference.
Thanks!
java - What is the difference between the terms non-primitive type and object type? - Stack Overflow
What is meant by a primitive data type? - Software Engineering Stack Exchange
What's the difference between a primitive and data object? (Python)
What is the difference between primitive and non-primitive data types? When are both used? Can you use them synonymously?
Videos
Part of this confusion may be in that, in C#, (mostly) everything inherits from Object. To refer to an Object type in the same way, would refer to every type in the language, and essentially be useless.
In C#, the primitive types are Boolean, Byte, Char, Double, Int16, Int32, Int64, IntPtr, SByte, Single, UInt16, UInt32, UInt64, UIntPtr. These types still inherit from object, though they are treated differently by the language. There are a few types that don't inherit from object, but they are not what you would consider primitives (ie Interfaces). The list of C# primitives can be acquired with this code, taken from here:
var primitives = typeof(int).Assembly.GetTypes().Where(type => type.IsPrimitive).ToArray();
A more appropriate dichotomy, if you wanted such a thing, would be value types versus reference types. When you begin considering that difference, then you can include things such as Enum types, and other values type, like structs.
in Java:
the primitive variables are categorized in 8 data types: boolean,byte,short,int,long,float,double and char.Every primitive variable has his own range of space in memory.
The references variables,refers to objects(Array,String,ArrayList,StringBuilder,...), and doesnt matter the space of the object referred.
Differences:
1.references types can be assinged as null /primitives dont.
2.references types can be used to call methods when they dont point to null/primitives uses literals.
3.references types have all the same size / in primitives depends of the
data type
4.primitives declarations starts with lowercase/java classes with
Uppercase
It kind of depends on the language.
For example, in languages like C and C++, you have a number of built-in scalar types - int, float, double, char, etc. These are "primitive" in the sense that they cannot be decomposed into simpler components. From these basic types you can define new types - pointer types, array types, struct types, union types, etc.
Then you have a language like old-school Lisp, where everything is either an atom or a list. Again, by the above definition, an atom is "primitive" in the sense that it cannot be decomposed into something simpler.
Edit
As far as I'm concerned, the terms "primitive", "basic", and "built-in" are pretty much interchangeable. If you want to get really pedantic, though, you can distinguish between types that are "built-in" (those explicitly provided by the language definition) and types derived from the built-in types that are still "primitive" or "basic" in that they cannot be decomposed into simpler elements. C's typedef facility allows you to create new type names for existing types. Ada allows you to create new scalar types that have constraints on them. For example, you can derive a Latitude type from the built-in floating type, with the constraint that it can't take on values outside the range [-90.0, 90.0]. It's still a primitive or basic type in that it cannot be broken down into any simpler components, but since it's user-defined, it's not considered a "built-in" type.
Again, these concepts are a little fuzzy, and it really depends on context. For example, the notion of a "built-in" type is meaningless for a typeless language like BLISS.
From the Java perspective:
In Java, there is a very clear distinction between primitive and non-primitive types.
A variable of a primitive type directly contains the value of that type (in other words, they are value types).
A variable of a non-primitive type doesn't contain the value directly; instead, it is a reference (similar to a pointer) to an object. (It is not possible in Java to create user-defined value types).
Java has eight primitive types: byte, short, int, long, char, boolean, float and double. Anything else is a non-primitive type.
Sorry for the stupid question. Just started learning to program in my CS degree and was really tripped up about this. Any help is appreciated!