It depends on the languages, what you can do with them
- do you need a distinction
- is there a distinction in the syntax, or is it just convenience, when talking about code
AFAIK, in Basic, if you call something, which does not return anything, but performs a job with side effects, like printing, write to file or change a global variable, it was called a procedure.
If it returns something, it was called a function.
In an OOP-Language like Java I rarely met the term 'function', but 'method', and it was teached that functions are things which are global and can be called by everyone.
In the functional and OOP-language scala, a method isn't called function, but you can pass such a thing to another method, and then it becomes a function.
A subroutine is a routine, which is called by another routine, to my understanding.
In summary, I don't think there is a concise definition over all languages and more so paradigms. You have to consider the specific culture, you're in, if you use these terms - maybe you should introduce your definition first.
function
for methods are JavaScript and PHP. Both use the same keyword for non-methods (free functions), and in the case of JavaScript there isn't really a distinction between functions and methods, at least not at language level.Sub
is aFunction
without a return value. InPython
you can have a function that is not part of any class, so it is not a method. You can also declare functions within functions, and you can do that in C# as well. Sometimes they have different names for the same reason that apples and pineapples do: because they are different.