2

I am doing MIT6.00.1x course from edX and in it, Professor Grimson talks about primitives of a programming language.

What does it actually mean and secondly, how it is different from the tokens of a programming language?

Please answer with reference to Python language.

ddlj
  • 131
  • 9

1 Answers1

0

It depends on the context, but usually:

  • primitives refers to built in data types of a language, that is, types that you can represent without creating an object. In python (and most other languages) such types are booleans, strings, floats, integers
  • tokens refers to a "word" (anything between spaces): identifiers, string/number literals, operators. They are used by the interpeter/compiler
blue_note
  • 27,712
  • 9
  • 72
  • 90
  • You are referring to the primitive data type but my context is related to the PRIMITIVE OPERATIONS. See this link - http://stackoverflow.com/questions/5069840/how-many-primitive-operations-in-a-simple-loop Now may you tell me about primitive operations w.r.t. programming? I am a noob. – ddlj Jan 13 '17 at 17:49
  • Sorry, then it probably means that even a single statement like `a = 1` is broken down to a number of primitive (assembly-level) operations (move register to some position in memory, load the value, move to some other, store the value, etc). But this is too low-level and architecture specific, I don't know where you can find a description about how python statements map to assembly – blue_note Jan 13 '17 at 17:58
  • @ddlj: Take a look at https://docs.python.org/3/library/dis.html – blue_note Jan 13 '17 at 18:08