# Include inside and outside of module

**URL:** <https://discourse.julialang.org/t/include-inside-and-outside-of-module/137181>\
**Category:** General Usage\
**Created:** [May 19, 2026, 6:56am UTC](https://discourse.julialang.org/t/include-inside-and-outside-of-module/137181 "2026-05-19T06:56:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [May 19, 2026, 6:56am UTC](https://discourse.julialang.org/t/include-inside-and-outside-of-module/137181/1 "2026-05-19T06:56:49Z")

</div>

In Julia, the following code is ideomatic:

```julia
module A
include("A.jl")
end

```

while

```julia
module A end
A.include("A.jl")

```

is not. I 100% agree that the first option is more idiomatic, aesthetic, readable and should be preferred.

My question is, are there any technical advantages of the idiomatic way? Will the compiler or Revise perform better, or something like this?

The reason I ask is that I would like to mirror a module structure from protobuf, which supports “open modules”. The most faithful translation to Julia would be

```julia
module A end
module B end
A.incluce("A1.jl")
B.include("B.jl") # depends on what is in A1.jl
A.include("A2.jl") # depends on what is in B.jl

```

I wonder if there are technical issues with this.

---

<div class="post-metadata">

**Author:** ![lilachint](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@lilachint](https://discourse.julialang.org/u/lilachint)\
**Post date:** [May 19, 2026, 8:40am UTC](https://discourse.julialang.org/t/include-inside-and-outside-of-module/137181/2 "2026-05-19T08:40:02Z")

</div>

There’s the normal `include([mapexpr::Function,] path::AbstractString)` and the less idiomatic one `Base.include([mapexpr::Function,] m::Module, path::AbstractString)`.

In your case, `A.include` [is essentially `Base.include`](https://github.com/JuliaLang/julia/blob/15346901f0039751c5488744f1f62de7d87510a8/base/loading.jl#L2907) under the hood. The normal `include` [calls `Base.IncludeInto`](https://github.com/JuliaLang/julia/blob/15346901f0039751c5488744f1f62de7d87510a8/base/sysimg.jl#L43) under the hood, which in turn [calls `Base.include`](https://github.com/JuliaLang/julia/blob/cad4314e3be8e9e3aa6aa74551941854f4c4c2c3/base/Base.jl#L328) internally. So if I didn’t get things wrong, I wouldn’t really expect a performance difference there.
