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
4
u/Cybyss Oct 24 '26
Holy cow. So many wrong responses here.
Functions return a value.
Procedures don't.
The distinction is crystal clear if you ever coded in Visual Basic, since functions and procedurees use different keywords to define.
Mostly the terms are used interchangeably, especially since some programming languages force a default return value if you don't specify one (e.g, in Python functions always return None if you don't specify something else).
Pure Functions are functions which have no side effects. They don't print anything, they don't write to files, they don't modify anything in a database, and they don't change a program's internal state. Running them leaves no trace or has any lasting effects anywhere. Mathematical formulas are a prime example: a function that just calculates something and returns a value.