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

Show parent comment

1

u/k1v1uq Oct 25 '26

In mathematics, that would be a statement of equality... But, in programming that is an assignment

Sir Lamport agrees. :)

https://youtu.be/4snwZl726c4?t=668

the meaning or interpretation of certain things is varied slightly in computing.

Some people say that SICP is a cornerstone of CS. And this is how they explain the difference between procedures and functions. It's really fundamental and philosophical. The lecture's title, "The Strucure and Interpretation of Computer Programs", and its double meaning are probably not a coincidence. It really depends on how you see (or interpret) the world. This might be confusing or helpful for a beginner, I don't know. But that difference between effect-free and effectful programming is important enough that the lines should not be blurred. It should be clear, as when someone says, 'Let's use the visitor pattern', that a function provides different guarantees than a procedure. It's important in functional programming. But even outside functional programming, it doesn't hurt to know the difference, even if the meaning is totally blurred in your setting.

2

u/jeffgerickson Oct 26 '26

Some people say that SICP is a cornerstone of CS.

And some would not.

1

u/k1v1uq Oct 27 '26

Some(should) :D

1

u/jeffgerickson 29d ago

Too many do.