# Best practices for structuring larger projects

**URL:** <https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652>\
**Category:** General Usage\
**Created:** [March 14, 2017, 3:26am UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652 "2017-03-14T03:26:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![little-big-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/little-big-h/32/718_2.png) [@little-big-h](https://discourse.julialang.org/u/little-big-h)\
**Post date:** [March 14, 2017, 3:26am UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/1 "2017-03-14T03:26:06Z")

</div>

I have a project that is becoming unwieldy in size and I’d like to break it up into modules. It doesn’t yet have parts that could be factored out as packages but I don’t want to rule out that it is heading that way. It has, however, reached a point at which I could have some submodules depend on others. However, there doesn’t seem to be a proper way to organize such projects in Julia.

The pattern I see (e.g., in Debug.jl) is to have a single “central” module-file that includes files that (sometimes) contain submodules. In that approach, dependencies between the submodules seem to be encoded in the order in which they are included in the central file. This strikes me as neither very robust/resilient nor scalable. Is there any best practice guide or an example project that people would refer to to illustrate how to structure projects like mine?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [March 14, 2017, 5:24am UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/2 "2017-03-14T05:24:02Z")

</div>

A lot of package ecosystems use a “Base package” for its type hierarchy and for defining common functions, and then use satellite packages which build the true functionality off of that. I describe it a bit in more detail here:

> **[Modular Algorithms for Scientific Computing in Julia - Stochastic Lifestyle](http://www.stochasticlifestyle.com/modular-algorithms-scientific-computing-julia/)**
>
> When most people think of the Julia programming language, they usually think about its speed. Sure, Julia is fast, but what I emphasized in a previous blog post is that what makes Julia tick is not just-in-time compilation, rather it's...

You should look at things like JuliaDiff, JuliaDiffEq, etc. for more details.

---

<div class="post-metadata">

**Author:** ![little-big-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/little-big-h/32/718_2.png) [@little-big-h](https://discourse.julialang.org/u/little-big-h)\
**Post date:** [March 14, 2017, 1:50pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/3 "2017-03-14T13:50:10Z")

</div>

Well, this is interesting but not quite solving my problem: the complexity of my package doesn’t stem from the need to provide multiple (optimized) implementations for the same interface. It stems from the fact that I have many different components that _have_ to work together. I could break them up into multiple packages but the “satellite” packages would be pretty much useless which seems to defy the point of packages.

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [March 14, 2017, 2:02pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/4 "2017-03-14T14:02:39Z")

</div>

Maybe this could help:

[https://github.com/simonster/Reexport.jl](https://github.com/simonster/Reexport.jl)

if you want to have submodules and not worry much about where symbols are from.

---

<div class="post-metadata">

**Author:** ![little-big-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/little-big-h/32/718_2.png) [@little-big-h](https://discourse.julialang.org/u/little-big-h)\
**Post date:** [March 14, 2017, 2:56pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/5 "2017-03-14T14:56:54Z")

</div>

Also interesting but also not solving my problem :-). This isn’t really making it any easier to structure my project in multiple files. I guess we could use the inspiration and build a macro-package to provide a higher-level import mechanism. Much the way Javascript folks ended up with RequireJS we might end up with a hacky quasi-standard. However, the JS folks have the excuse that their language is 20 years old. I think Julia needs a good project structure/submodule story **soon**.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 14, 2017, 3:08pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/6 "2017-03-14T15:08:17Z")

</div>

Maybe the structure of [https://github.com/JuliaDocs/Documenter.jl](https://github.com/JuliaDocs/Documenter.jl) is useful to look at?

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [March 14, 2017, 3:50pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/7 "2017-03-14T15:50:46Z")

</div>

You might take a look at the current version of LightGraphs - we broke out related functions into separate files. We’re moving away from this (towards submodules) in the next major update, but the existing structure has served us well until now.

---

<div class="post-metadata">

**Author:** ![little-big-h](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/little-big-h/32/718_2.png) [@little-big-h](https://discourse.julialang.org/u/little-big-h)\
**Post date:** [March 14, 2017, 8:28pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/8 "2017-03-14T20:28:19Z")

</div>

LightGraphs is a nice example (potentially the cleanest project I’ve seen while looking into this). I still don’t like the idea of having a single file in which all the “subfiles” are included though.

Do you have any efforts on the way towards submodules that I could look at?

---

<div class="post-metadata">

**Author:** ![Tem\_Pl](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Tem\_Pl](https://discourse.julialang.org/u/Tem_Pl)\
**Post date:** [March 14, 2017, 8:57pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/9 "2017-03-14T20:57:56Z")

</div>

Check out these github issues. [https://github.com/JuliaLang/julia/issues?q=is%3Aopen+is%3Aissue+label%3Amodules](https://github.com/JuliaLang/julia/issues?q=is%3Aopen+is%3Aissue+label%3Amodules)

Any of them seem like they would help?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [March 14, 2017, 9:13pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/10 "2017-03-14T21:13:50Z")

</div>

> I still don’t like the idea of having a single file in which all the “subfiles” are included though.

Would you like to expand on that? What is is that you object to?  
It seems to work well for many Julia packages.

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [March 15, 2017, 3:01pm UTC](https://discourse.julialang.org/t/best-practices-for-structuring-larger-projects/2652/11 "2017-03-15T15:01:33Z")

</div>

LightGraphsExtras has a modular structure that might be of interest.
