I am new to Julia, and I wonder what a package is.
I am quite familiar with Rust. In Rust, a crate can either be a library or an executable. As far as I read, the examples interpreting what package is are all about libraries, which another file can re-use the code in this package.
So if I just want to make a project for myself to use (which is much like an executable, but in interpreting languages, I can’t come up with a good name) rather than a library for others to use, should I make this project a package?
I know I can just use julia xxx.jl to run a Julia file, but I prefer Project.toml and Manifest.toml to make it more re-productable.
as you already know Project.toml and Manifest.toml gives you reproducibility. You’re totally free to make your own utility package, just create a pkg at somewhere and ]dev path_to_your_pkg and then you can just using MyPkg like normal.
Note that julia --project=/path/to/project script.jl will run the package in a specific project.
If you are not developing a package, you can just activate that project in the REPL and add the packages you need.
Does this mean that “package” is more of a utility, and the main() function of my project is encouraged to write in a plain file that uses that package?
I would just put it all in one module and have the module export the function main(). But yes, in general a “project” that isn’t intended to be used by others should still look like the packages you see on github, imo.
I like to think to a julia package as a software “piece” (in Julia, a module) plus the metadata to facilitate its discovering and interation with other software “pieces” (the Project.toml and Manifest.toml) and a conventional structure to facilitate its testing and documentation.