I mostly write in Python and there is no var or let before declaring a variable, but there are many others. In this connection, there are a couple of questions.

  1. Why do we need these keywords?

  2. Why is let most often used as a constant? (Why the creators of the language did not use the word const)

  • 3
    where does the conclusion that let is most often used as a constant ? - Grundy
  • 3
    in different languages, the meaning of keywords may differ dramatically. Without specifying specific languages ​​- the question is too wide - Grundy
  • one
    Well ... if you already ask this, then write out all the languages ​​in one column, and the presence of let is on the other side. let is in basic, js. let almost everywhere, in python, c, c ++, c #, pascal, delphi, asmx86, sql (common). - nick_n_a
  • one
    Answer to the first question: such keywords set the behavior of a variable and its availability from different parts of the code (to detect errors in variable names at the compilation stage and to exclude accidental damage to the values ​​of variables because they forgot that some name is already was used). On the second one: why do let interests, the developers of the language are free in the name of this or that behavior. in perl for example, there are my, local and our - Mike
  • one
    @nick_n_a - I'll run it: let ’s have it in C #. - Alexander Petrov

1 answer 1

a long time ago, when computers were large, and they had a small typical memory (16Kb, 8Kb, 4Kb and even less), the developers were very perverted to fit into a small memory.

parsing is greatly simplified if all statements are syntactically the same:

оператор операнд [,операнд] 

for example, Assembler

but already in the first generations of languages ​​from such a hard format began to move to more free grammars and to a more convenient syntax for humans. In particular, the operand for the assignment instruction very quickly became optional.

for example, Basic with its keyword LET

Therefore, such keywords were needed to simplify the "high-level" parsers of languages ​​and to meet the tight memory restrictions of the time. After the victory of the structural style and general strict typification, the variables became declared using variable types. And now we are back to the automatic types and operators auto, var, val, let. But with a new meaning and new content.


Let in few places is used in the context of "constants". Is that in modern Javah. Let is rather a tribute to BASIC, where this operator meant an assignment operation. BASIC once performed the role that Java is now playing, a simple high-level language that is not tied to the architecture of a particular iron. BASIC had a strong influence on IT. And, to be honest, contributed to a significant increase in the number of programmers - "Every cook can code in BASIC"