# Open-sourcing the Blue Style Guide for Julia

**URL:** <https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495>\
**Category:** Community\
**Tags:** announcement\
**Created:** [October 4, 2019, 5:02pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495 "2019-10-04T17:02:32Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [October 5, 2019, 8:34pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/21 "2019-10-05T20:34:33Z")

</div>

> [@kristoffer.carlsson](#):
>
> When is `import` ever _required_ ? Personally, I think the `import` keyword can be removed completely and we just use `using Example: hello` everywhere and always specify module when extending.

You may want to import the functions from the module `Foo` without bringing them into the scope of `Bar`, so that you can make the function `Bar.f` without having to take into account what methods of `Foo.f` exist — e.g. if you don’t want to _extend_ `Foo.f` with new methods, but create your own function with the same name, which might have a completely different purpose.

---

<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:** [October 5, 2019, 8:54pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/22 "2019-10-05T20:54:25Z")

</div>

You can do `using Bar: Bar`.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [October 6, 2019, 2:41am UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/23 "2019-10-06T02:41:31Z")

</div>

Also, `using Foo: f` allows one to be lazy and write `f` unqualified. On the other hand, `import Foo` requires that I qualify all symbols from `Foo`, which is what I want when using `Foo` in another module.

---

<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:** [October 6, 2019, 9:46am UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/24 "2019-10-06T09:46:58Z")

</div>

> [@jlapeyre](#):
>
> Also, `using Foo: f` allows one to be lazy and write `f` unqualified

Don’t write that then… (`using Foo: Foo`)

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [October 7, 2019, 5:11am UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/25 "2019-10-07T05:11:01Z")

</div>

I find `import Foo` more clear than `using Foo: Foo`. But, if you can really do everything with `using`, then the small loss in clarity is worth the simplicity obtained by ditching `import`.

---

<div class="post-metadata">

**Author:** ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)\
**Post date:** [October 8, 2019, 2:08am UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/26 "2019-10-08T02:08:25Z")

</div>

Apparently, this is not a minor issue. I just googled: julia difference between … (I was not looking for import and using), but it autocompleted to “using and import”.

---

<div class="post-metadata">

**Author:** ![Nosferican](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nosferican/32/9275_2.png) [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Post date:** [October 12, 2019, 10:30pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/27 "2019-10-12T22:30:42Z")

</div>

The style I use concerning `using`/`import` is to always `using` and the exact additions to the namespace. I only qualify when there is ambiguity (`CSV.read` / `JSON3.read`). I only extend functionality to functions that are brought by `import Pkg: method_I_will_extend`. I like the distinction and safe approach that follows.

Example,  
[https://github.com/Nosferican/Econometrics.jl/blob/27659194ced8c913ca06dec5b5b4a11e7d634df9/src/Econometrics.jl#L7-L36](https://github.com/Nosferican/Econometrics.jl/blob/27659194ced8c913ca06dec5b5b4a11e7d634df9/src/Econometrics.jl#L7-L36)

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [October 13, 2019, 2:41pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/28 "2019-10-13T14:41:02Z")

</div>

The thing I don’t like about `import Foo: bar` is that then in some other place in the code you see `function bar(x::MyType) ... end` and it’s not very explicit that you’re extending some other package’s function rather than defining your own. I prefer to have `function Foo.bar(x::MyType) ... end` whenever I’m adding a method to another package’s function.

---

<div class="post-metadata">

**Author:** ![Nosferican](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nosferican/32/9275_2.png) [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Post date:** [October 13, 2019, 2:53pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/29 "2019-10-13T14:53:38Z")

</div>

The counterpoint would be that you can see every single function being extended in one place rather than go hunting across files to figure that out.

---

<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:** [October 13, 2019, 2:58pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/30 "2019-10-13T14:58:42Z")

</div>

Not so. Do a “Find in the project” of for instance `Base.count` (when extending `count`). It pops up readily.  
I think it would be harder to find if `count` wasn’t prefixed with `Base`.

---

<div class="post-metadata">

**Author:** ![Nosferican](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nosferican/32/9275_2.png) [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Post date:** [October 13, 2019, 3:07pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/31 "2019-10-13T15:07:28Z")

</div>

You would have to do so for every function for every module (Base, Core, stdlibs, submdules, transitive deps, etc.). I like being explicit in one place rather than explicit each instance, but everywhere.

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [October 13, 2019, 3:35pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/32 "2019-10-13T15:35:38Z")

</div>

Just a suggestion: you could use GitHub releases to set up a versioning scheme for the style guide. That way users can point to a specific version, rather than having a moving target (as the language itself continues to develop as well).

---

<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:** [October 13, 2019, 4:56pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/33 "2019-10-13T16:56:06Z")

</div>

You seem poised to cut a large swath 😉 I was talking more about files I can actually modify (i. e. that I own).

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [October 14, 2019, 12:57pm UTC](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495/34 "2019-10-14T12:57:49Z")

</div>

> [@Nosferican](#):
>
> The counterpoint would be that you can see every single function being extended in one place rather than go hunting across files to figure that out.

Good point - that’s a tradeoff. I think in practice I don’t often need to answer the question of which methods get extended, and generally if I want to know that I have followup questions about which of my types have new methods defined, so I think I end up going to the implementations anyways. But that seems like it’s wading pretty deep into personal workflow territory.

[Previous page](https://discourse.julialang.org/t/open-sourcing-the-blue-style-guide-for-julia/29495.md?page=1)
