miniblog.

← Back to all posts
53
I'm coming round to the view that a main function shouldn't take arguments. For example, in Rust you have to call std::env::args() to get CLI arguments. This makes Hello World less verbose, and gives you more flexibility in setting up CLI argument parsers.

3 Comments

@wilfredh I agree. Haskell does this too, and hence the Hello World program is just `main = putStr "hello world"`. Because of this, many #Haskell libraries export a `defaultMain` function that process the args for you, and do setup for the libraries' main action.
it's something that never made sense to me, cli args are more complex than a function input, you cannot really transcribe them as such
argv argc in C main functions always looked like a very bothersome way to represent cli args, and what's worse is that it's possibly one of the most sensible ways