# About module creation

**URL:** <https://discourse.julialang.org/t/about-module-creation/1490>\
**Category:** General Usage\
**Created:** [January 15, 2017, 12:50am UTC](https://discourse.julialang.org/t/about-module-creation/1490 "2017-01-15T00:50:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FANG\_Colin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fang_colin/32/170_2.png) [@FANG\_Colin](https://discourse.julialang.org/u/FANG_Colin)\
**Post date:** [January 15, 2017, 12:50am UTC](https://discourse.julialang.org/t/about-module-creation/1490/1 "2017-01-15T00:50:12Z")

</div>

I saw the use of `Module()` somewhere and it seems an equivalent of `module A end`

However, it is not documented at all.

Is `Module(name)` a recommended way to create modules programmatically?

Also, I’d like to know how costly is module creation? Would there be any problem if I create a few thousand small modules in run time?

Are they as cheap as dictionaries?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [January 15, 2017, 4:19am UTC](https://discourse.julialang.org/t/about-module-creation/1490/2 "2017-01-15T04:19:56Z")

</div>

> [@FANG\_Colin](#):
>
> Is Module(name) a recommended way to create modules programmatically?

Macros are preferable. You could do things like `A = Module(:A)` and then `eval(A, :( ... ) )` but that’s not the intended interface.

> [@FANG\_Colin](#):
>
> Are they as cheap as dictionaries?

Cheap for what? Module bindings are stored internally in a symbol → binding hash table that is “fast”, but there’s some other associated state. If you need a dictionary, better to use a dictionary. That’s not what modules are for.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [January 15, 2017, 7:52am UTC](https://discourse.julialang.org/t/about-module-creation/1490/3 "2017-01-15T07:52:13Z")

</div>

Ref [julia - Best way to eval in a given scope / context which is in the form of a Dict? - Stack Overflow](http://stackoverflow.com/q/41639237/176071) for a little more context. I’d love to hear other solutions, but the problem is presented so abstractly that it’s hard to understand what the actual goal is. As I alluded to in the last paragraph there, using eval is typically a big red flag… and especially so if you’re using it in a place where performance is critical.
