# Question on package vs modules

**URL:** <https://discourse.julialang.org/t/question-on-package-vs-modules/42196>\
**Category:** New to Julia\
**Tags:** packages, modules\
**Created:** [June 28, 2020, 2:00pm UTC](https://discourse.julialang.org/t/question-on-package-vs-modules/42196 "2020-06-28T14:00:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiggunjer](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jiggunjer](https://discourse.julialang.org/u/jiggunjer)\
**Post date:** [June 28, 2020, 2:00pm UTC](https://discourse.julialang.org/t/question-on-package-vs-modules/42196/1 "2020-06-28T14:00:23Z")

</div>

I’ve read the official documentation on packages and modules, but I get the impression the two concepts get conflated. Can someone say if the following statements are true or false, and if false then why:

1. A single Github repo may host 1 or more packages.
2. A single package with name `X` will _always_ contain a file `X.jl`.
3. `X.jl` will _always_ define a module named `X`
4. You can’t have other top-level modules in a single package (see [here](https://github.com/JuliaLang/Juleps/issues/8) and [here](https://stackoverflow.com/questions/30783197/can-i-make-a-julia-package-containing-multiple-modules-that-can-be-independently)).

Thank you

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 28, 2020, 2:08pm UTC](https://discourse.julialang.org/t/question-on-package-vs-modules/42196/2 "2020-06-28T14:08:55Z")

</div>

At least for me:  
1 repo, 1 package.  
The structure can be profitably left up to [User Guide · PkgTemplates.jl](https://invenia.github.io/PkgTemplates.jl/stable/user/). `PkgTemplates` will generate your package with all the right components.  
And, yes, package `X.jl` should have an src directory with “X.jl” in it.  
I always have a top module called `X` for the package.

But things may be rather different for _projects_. These do not need to have this relatively rigid structure.

---

<div class="post-metadata">

**Author:** ![jiggunjer](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jiggunjer](https://discourse.julialang.org/u/jiggunjer)\
**Post date:** [June 28, 2020, 2:18pm UTC](https://discourse.julialang.org/t/question-on-package-vs-modules/42196/3 "2020-06-28T14:18:06Z")

</div>

It was my understanding that packages _are_ projects. Although projects need not be packages.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 28, 2020, 2:26pm UTC](https://discourse.julialang.org/t/question-on-package-vs-modules/42196/4 "2020-06-28T14:26:13Z")

</div>

Correct. That was a slip up. Please replace _projects_ with _applications_.  
More [here](https://docs.julialang.org/en/latest/manual/code-loading/#Project-environments-1), and [here](https://julialang.github.io/Pkg.jl/v1/glossary/).

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [June 28, 2020, 4:19pm UTC](https://discourse.julialang.org/t/question-on-package-vs-modules/42196/5 "2020-06-28T16:19:58Z")

</div>

If you have a module for things you do on your own, leaving it as only a module and putting it in your LOAD\_PATH makes sense. I have a few little things like that.

If you plan on sharing the material with others or, more seriously, using it to support a journal `publication, then it makes a lot of sense to put it in a project or application with the right .toml files. That make the dependencies clear and helps your colleagues/readers/collaborators reproduce results. The escalation from module to application/project almost surely means you have to learn how github supports that stuff, learn enough about pkg to build the .toml files, and put X.jl in the right place.

If your project becomes a bigger deal, say a tool for a class you teach, a group you lead, or a book, then making it a package is a good idea so you can do CI and distribute it more easily.

This is, of course, my opinion as of today. I’ve changed my mind on this a couple times in the past.

---

<div class="post-metadata">

**Author:** ![tim.holy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tim.holy/32/52_2.png) [@tim.holy](https://discourse.julialang.org/u/tim.holy)\
**Post date:** [June 30, 2020, 2:37am UTC](https://discourse.julialang.org/t/question-on-package-vs-modules/42196/6 "2020-06-30T02:37:02Z")

</div>

2-4 are correct, though you should understand that they are conventions of the package manager rather than built into the language itself. To me that seems exactly right: the package manager should enforce certain conventions, but the language keeps the concepts orthogonal.

1 should be amended to “0 or more modules.” You can put a script in a repo and push it to GitHub.
