Skip to main content
add examples
Source Link

Different languages are useful for writing very different kinds of programs, in different domains entirely.

Command-line interface might just not be the main way to interact with programs in a given language.

As you point out, most or all "general purpose" languages do have a way to access argv/argc.

But they don't have to be at the center of attention all the time, especially if most programs are not expected to use them.

Also, many languages (like C# you mentioned) actually let you choose whether to use int main(args) or void main().


(edit: adding examples from the comments)

When Java was originally released, it was popular for writing applets that run in the browser. When the program is an applet, the platform is the browser, and it doesn't expect a return value like a regular OS.

Even languages like Go, which seems to be geared for low-level programming and/or CLI/headless applications, can also be compiled to JS or wasm. Putting args and exit into a os package is a way to avoid tightly coupling one specific entry point design to the language. When designing a language it's usually a good thing to delegate concerns to libraries. When compiling for an environment without argv/exit, it's nicer to just have a missing os package than to have superfluous handling of fake empty arguments (from the perspective of both the language implementer and of the language user).

Different languages are useful for writing very different kinds of programs, in different domains entirely.

Command-line interface might just not be the main way to interact with programs in a given language.

As you point out, most or all "general purpose" languages do have a way to access argv/argc.

But they don't have to be at the center of attention all the time, especially if most programs are not expected to use them.

Also, many languages (like C# you mentioned) actually let you choose whether to use int main(args) or void main().

Different languages are useful for writing very different kinds of programs, in different domains entirely.

Command-line interface might just not be the main way to interact with programs in a given language.

As you point out, most or all "general purpose" languages do have a way to access argv/argc.

But they don't have to be at the center of attention all the time, especially if most programs are not expected to use them.

Also, many languages (like C# you mentioned) actually let you choose whether to use int main(args) or void main().


(edit: adding examples from the comments)

When Java was originally released, it was popular for writing applets that run in the browser. When the program is an applet, the platform is the browser, and it doesn't expect a return value like a regular OS.

Even languages like Go, which seems to be geared for low-level programming and/or CLI/headless applications, can also be compiled to JS or wasm. Putting args and exit into a os package is a way to avoid tightly coupling one specific entry point design to the language. When designing a language it's usually a good thing to delegate concerns to libraries. When compiling for an environment without argv/exit, it's nicer to just have a missing os package than to have superfluous handling of fake empty arguments (from the perspective of both the language implementer and of the language user).

Source Link

Different languages are useful for writing very different kinds of programs, in different domains entirely.

Command-line interface might just not be the main way to interact with programs in a given language.

As you point out, most or all "general purpose" languages do have a way to access argv/argc.

But they don't have to be at the center of attention all the time, especially if most programs are not expected to use them.

Also, many languages (like C# you mentioned) actually let you choose whether to use int main(args) or void main().