Linguistic meaning of 'let' variable in programming [duplicate]
Asked Answered
U

1

78

So, I'm a javascript programmer and the new version of JavaScript (ES6) has a new keyword for declaring variables: let, next to the old one var.

I know the difference between these two, but I was asking myself: what does let stand for? var obviously is an abbreviation of "variable", but let? Is it an abbreviation as well? Where does it come from?

I googled this and to my amazement, I couldn't find an answer. I already knew Swift also has a let keyword (they use it for constants), but apparently some other programming languages use it as well.

Unyoke answered 12/10, 2015 at 21:5 Comment(7)
hmm, I found this: programmers.stackexchange.com/questions/194227/…, but it doesn't really give a clear answerUnyoke
let stands for... drumroll please... let. You could read let x = 1; as "let x be 1" if that helps.Zasuwa
it's an english verb; "let this name be this value".Boltrope
seriously, just that simple?Unyoke
it stands for lettuce because it leaves itself behind...Boltrope
@Boltrope - hall of fame comment :-)Stefansson
"Let" is commonly used in mathematics: en.m.wikipedia.org/wiki/Choice_functionNoisome
K
95

It comes from the English word 'let'.

verb: "let", "letting". 1. to allow or permit:

// Hey computer, can you please
let 
// this
night = 'wonderful'

Lisp has the keyword let and it's been around since 1958, though it may have come from even earlier.

Krauss answered 12/10, 2015 at 21:8 Comment(4)
I've always assumed programming languages inherited it from the language of mathematical proofs, which often say e.g. "Let x be an integer..."Instructions
@Jordan that's completely likely. You find let used more in functional programming languages which are built on algebraic types and category theory.Krauss
I always think of it more along the lines of "let the keyword night equal 'wonderful'" but that's probably just me.Palma
@Jordan I found an example here: en.wikipedia.org/wiki/…Unyoke

© 2022 - 2024 — McMap. All rights reserved.