In what programming language did “let” first appear?

I was wondering about the origins of the “let” used in Lisp, Clojure, and Haskell. Does anyone know which language it appeared in first?

6

Well, BASIC had LET for assignment as part of the syntax from the start in 1964, so that would predate the use of let in Lisp, which as Chris Jester-Young points out didn’t appear until the 1970s according to Evolution of Lisp.

I don’t believe COBOL, Fortran, or ALGOL have LET in their syntax either. So I’m going to go with BASIC.

9

I’d like to add a theoretical point of view: In classical lambda calculi, let is just syntactic sugar. For example

let x = N in M

can be rewritten simply as

(λx.M)N

So its first appearance in early (functional) languages isn’t that interesting.

However, it become very important with the invention of Hindley-Milner type system and its type inference algorithm. In this type system let is indispensable, because it’s polymorphic (unlike λ-abstraction in HM). For example, consider this simple expression:

let id = λx . x in id id

Here id is polymorphic, it has type ∀α.α → α, and therefore id id type-checks – it’s type is id id : τ → τ for arbitrary τ. (For the first id we assign τ → τ to α and for the second id we assign τ for α.)

However, we can’t rewrite it using λ abstraction and application. Expression

(λid . id id)(λx.x)

doesn’t type-check, because within the first λ abstraction id must be assigned a monomorphic type id : σ for some σ, and there is no σ such that we could apply id : σ to id : σ.

You can try this yourself in Haskell. While let id = x -> x in id id :: t -> t type-checks, typing (id -> id id)(x -> x) fails with

Occurs check: cannot construct the infinite type: t0 = t0 -> t0
In the first argument of id, namely id
In the expression: id id
In the expression: id -> id id

9

Lisp is the oldest language of these having LET now. But BASIC was the first that got it, for Lisp had obtained it much later.

In Ada Lovelace Analytical Engine (1843) – no LET, a program looks as:

N0 6 N1 1 N2 1 × L1 L0 S1  L0 L2 S0 L2 L0 CB?11 '

In Plankalkül of Zuse (1943-45) the program looks:

P1 max3 (V0[:8.0],V1[:8.0],V2[:8.0]) → R0[:8.0]
max(V0[:8.0],V1[:8.0]) → Z1[:8.0]
max(Z1[:8.0],V2[:8.0]) → R0[:8.0]
END

Short Code was proposed by John Mauchly in 1949

X3 =  (  X1 +  Y1 )  /  X1 * Y1   

Intermediate PL of Burks, 1950, used for assignment ->

Rutishauser in 1952 used =>=

Böhms compiler, 1952, used ->

At the University of Manchester, Alick Glennie developed Autocode in the early 1950s. The first code and compiler was developed in 1952 for the Mark 1 computer at the University of Manchester and is considered to be the first compiled high-level programming language. Again, -> for assignment

Charles Adams, FORTRAN 0 of Backus’s group , Brooker’s Autocode 2, ПП1 of Lubimsky and Kamynin; all in 1954, again =

BACAIC (Grems, Porter), 1954, * for assignment!

Kompiler, ADES, 1955, =

IT, 1956, <-

FORTRAN, 1957, =

AT-3 (1956), Math-Matic (1957), again =,

but Flow-Matic in 1957 had two assignments, and both are in words

TRANSFER a TO b and MOVE a TO b

Bauer and Samelson’s machine, 1957: =>


Sorry, I can’t cover all languages between 1957 and 1964, but greater languages

1957 - COMTRAN (forerunner to COBOL)
1958 - LISP
1958 - ALGOL 58
1959 - FACT (forerunner to COBOL)
1959 - COBOL
1959 - RPG
1962 - APL
1962 - Simula
1962 - SNOBOL
1963 - CPL (forerunner to C)

have not LET for assignment. Or had not, in the case of LISP.


Dartmouth BASIC is the original version of the BASIC programming language. The first interactive version was made available to general users in June 1964;

 LET / = — assign formula results to a variable

Well, between those three, Lisp definitely had it first. Haskell came about in the 80s, and Clojure in the 00s, and let had been around long before either of those dates. 🙂

As to whether Lisp was the language to have invented it, I can’t vouch for that yet, but I’ll do some research and see. 🙂

Update: According to Evolution of Lisp (see page 46), it mentioned that let was invented in the 70s:

LET—itself a macro first invented and reinvented locally at each site—was a late-comer to the MacLisp world; according to Lisp Archive, it was retroactively absorbed into PDP-10 MacLisp from Lisp-Machine Lisp in 1979 at the same time as DEFMACRO and the complex Lisp Machine DEFUN argument syntax.

Still doesn’t quite answer whether it was invented in another language earlier, of course, but still another data point. 🙂

2

The first Revised Scheme report AIM-452 from January 1978 has LET. Page 9.

note that Lisp used earlier a different construct PROG to introduce local variables.

(let ((a 1)
      (b 1))
  (+ a b))

would have been written earlier approximately as

(prog (a b)
  (setq a 1)
  (setq b 1)
  (+ a b))

3

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật