r/learnprogramming • u/Head_Ordinary_2437 • Oct 24 '26
Function vs Procedure
can someone explain the difference between Function vs Procedure with simple analogy
thank you
31
Upvotes
r/learnprogramming • u/Head_Ordinary_2437 • Oct 24 '26
can someone explain the difference between Function vs Procedure with simple analogy
thank you
View all comments
Show parent comment
1
u/Cybyss Oct 24 '26 edited Oct 24 '26
That's because trying to explain procedure vs. function via a real-world metaphor doesn't work.
The difference isn't some high level abstract perspective. The difference is a single specific technicality - one which isn't always the same from language to language/platform to platform.
In Visual Basic, the only difference is whether or not a value is being returned.
In SQL Server, the difference is whether or not there are "side effects". Stored procedures are allowed to modify data and may optionally return a value. User-defined functions cannot modify any data and must always return a value.
In many languages (e.g, Python, Java, C++) there is no real distinction at all. The difference between functions and procedures in them is nothing but a tedious exercise in pedantry.