Is it proper practice to have a main method

I’m learning Julia, and right now I’m only working with one file, let’s call it main.jl. Is it proper practice to include a main method, as outlined here?

I found this thread from last year, but for simple introduction level projects, would a simple main method be sufficient?

Generally the function main is intended for programs which will be run as an executable or script, so if that’s what you’re building, I’d say it makes sense (that’s usually how I create scripts in Julia too). Otherwise, if you’re writing a package to be a library, main doesn’t make sense.

6 Likes