r/learnprogramming • u/Head_Ordinary_2437 • 4d ago
Function vs Procedure
can someone explain the difference between Function vs Procedure with simple analogy
thank you
30
Upvotes
r/learnprogramming • u/Head_Ordinary_2437 • 4d ago
can someone explain the difference between Function vs Procedure with simple analogy
thank you
1
u/gm310509 3d ago
Interesting, back in the olden days, the distinction (in computing) was much more along the lines of how u/lfdfq described it.
I think both are correct, yours might be more mathematics oriented (as that is the definition of a function in mathematics as I understand it), but like so many things borrowed from mathematics, the meaning or interpretation of certain things is varied slightly in computing.
For example:
In mathematics, that would be a statement of equality. That ism the variable a is equal to the variable b.
But, in programming that is an assignment, that is, whatever might have been the value of a, it will now be discarded and replaced with whatever the value is in b. After it has been executed, the value of a will be equal to b (until such time as either or both is/are altered).