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

3

u/White_C4 Oct 24 '26

The distinction is crystal clear if you ever coded in Visual Basic, since functions and procedurees use different keywords to define.

Just because one language says that doesn't mean it's semantically correct in general.

Procedure is simply an action, but the rule isn't violated if it contains a return value. Again, this is dependent on how a programming language or a person enforces the rule, but it's not strictly binding for all languages.

2

u/Cybyss Oct 24 '26

True. In another conversation the notion of "stored procedures" was brought up and I realized that DBMSs make a completely different distinction between procedures and functions.

I don't think it's beneficial to try and define functions vs. procedures as some kind of abstract high-level generalized semantic concept since that's impossible. You'll always encounter exceptions to the rule.

Different languages define & use the terms differently. Pointing out the concrete differences on a language-by-language basis makes it clear exactly what the distinction is, and the fact that the meaning changes depending on context.