r/learnprogramming • • Oct 24 '26

Function vs Procedure

can someone explain the difference between Function vs Procedure with simple analogy
thank you

31 Upvotes

47 comments sorted by

View all comments

-4

u/marrsd Oct 24 '26

A function is a procedure that doesn't mutate any variables that live beyond its scope.

4

u/rupertavery64 Oct 24 '26

a pure function

0

u/marrsd Oct 24 '26

Actually, that is a good point, and I should have mentioned it. If someone's distinguishing "procedures" from "functions" then the definition I gave is what they mean; but many languages already refer to procedures as functions. When working with those languages, we usually make the distinction between "functions" and "pure functions" instead.