I have a question about java main (). java main() does not return anything. Per software engineering, a block of code which does not return anything is called a Procedure.​ So why do we call main() a method? should we call it the main procedure instead?

Please refer: Method vs Function vs Procedure


Should we call main() method as main() procedure?

Informally, sure. There's no problem with that.

Per software engineering, a block of code which does not return anything is called a Procedure.​

While this is fine, it is not 100% standard across all languages and all of software engineering. Procedure is a fairly general term and can be used in various contexts at various levels of abstraction and generality.

For example, in the Java language specification, the word "procedure" appears 41 times, none of which are used to refer to "functions vs. methods vs. procedures".

Almost all uses of the term "procedure" in the spec refer to a well-defined algorithm, most often specifically the algorithm of class initialization as a complex, internal, and stateful operation of the language & its runtime, rather than as something you can invoke.

By contrast the word "method" appears 2049 times, one of which is "method declaration", so this term represents a syntactic and semantic construct in the language that programmers will use.

We call main a method, in Java because that is what it is by the terminology of the language — a "static void method". The Java language does not offer the term procedure as something that can be invoked or something like a function without a return value.

Languages are typically defined by a fairly rigorous specification. These specs introduce terminology for use in the rest of the specification, and for the purposes of clarity, such terminology is usually clearly defined. The authors of a language and of its specification have the privilege to redefine common terms with language specific meanings. They go to great lengths to use these terms consistently within their language specification. The terminology they introduce in specification tends to become used by programmers in the context of that programming language.

The same exact terms may differ in meaning between two languages. They may also differ from common, informal use broadly across programming, where terms are not as rigorously defined as within a language specification.

  • Erik, Thanks for the detailed explanation. It makes sense per Java spec. – VK2 Mar 24 '18 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.