# Is there a Julia Style Guide?

**URL:** https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195
**Category:** New to Julia
**Tags:** question, formatting, best-practices
**Created:** [April 28, 2022, 9:32am UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195 "2022-04-28T09:32:04Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![dnldlg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnldlg/32/209465_2.png) [@dnldlg](https://discourse.julialang.org/u/dnldlg)
#### Post date: [April 28, 2022, 9:32am UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/1 "2022-04-28T09:32:04Z")

</div>

Hi, I’m learning Julia right now and want to teach myself a good coding style right form the start. Is there a Julia design proposal similar to the PEP guidelines for python?

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [April 28, 2022, 9:42am UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/2 "2022-04-28T09:42:33Z")

</div>

Not exactly, but there is this: [Style Guide · The Julia Language](https://docs.julialang.org/en/v1/manual/style-guide/)

There are also some related style guides, like [https://github.com/invenia/BlueStyle](https://github.com/invenia/BlueStyle) which is a bit more exhaustive, I belive.

---

<div class="post-metadata">

### Author: ![dnldlg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnldlg/32/209465_2.png) [@dnldlg](https://discourse.julialang.org/u/dnldlg)
#### Post date: [April 28, 2022, 10:55am UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/3 "2022-04-28T10:55:10Z")

</div>

Thank you!

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [April 28, 2022, 1:32pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/4 "2022-04-28T13:32:34Z")

</div>

If you’re also looking for more of a design document, you might find the original Julia paper interesting: [https://arxiv.org/pdf/1209.5145.pdf](https://arxiv.org/pdf/1209.5145.pdf) . This is more about how Julia itself was designed, rather than advice for writing Julia code today.

---

<div class="post-metadata">

### Author: ![palday](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palday/32/12640_2.png) [@palday](https://discourse.julialang.org/u/palday)
#### Post date: [April 28, 2022, 2:16pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/5 "2022-04-28T14:16:52Z")

</div>

Check out [JuliaFormatter](https://github.com/domluna/JuliaFormatter.jl) is you want style enforcement as part of your linting/CI process. The already mentioned [Blue Style](https://github.com/invenia/BlueStyle) and the [YASGuide](https://github.com/jrevels/YASGuide) are probably the most popular “official” styles.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [April 28, 2022, 2:48pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/6 "2022-04-28T14:48:47Z")

</div>

I am myself partial to the [JuMP style guide](https://jump.dev/JuMP.jl/dev/developers/style/). It is based in the Julia style guide and the Google style guide:

> In some cases, the JuMP style guide diverges from the Julia style guide. All such cases will be explicitly noted and justified.
> 
> The JuMP style guide adopts many recommendations from the Google style guides.

My preferred guidance is:

> The Julia style guide recommends avoiding underscores “when readable”, for example, haskey, isequal, remotecall, and remotecall\_fetch. This convention creates the potential for unnecessary bikeshedding and also forces the user to recall the presence/absence of an underscore, e.g., “was that argument named basename or base\_name?”. For consistency, always use underscores in variable names and function names to separate words.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [April 28, 2022, 3:00pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/7 "2022-04-28T15:00:32Z")

</div>

> [@Henrique\_Becker](#):
>
> and also forces the user to recall the presence/absence of an underscore, e.g., “was that argument named basename or base\_name?

Is that really an issue? How many cases are there of underscores in Base? Seems like you can mostly assume there is no underscore, the few cases really stand out.

Imho, if your function name has underscores, refractor, or come up with a better name.

I really like the naming convention in Base, it forces you to think long and hard about names, and not throw together three keywords describing your function with \_ between them. It leads to better names.

---

<div class="post-metadata">

### Author: ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)
#### Post date: [April 28, 2022, 3:00pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/8 "2022-04-28T15:00:33Z")

</div>

@dnldlg - I hope you don’t mind but I edited the title of your post for additional clarity.  
Originally read it as you were wondering about proposing changes to Julia but I see what you mean by asking more about a style guide.  
Cheers and best of luck with your learning! 😄

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [April 28, 2022, 5:22pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/9 "2022-04-28T17:22:35Z")

</div>

> Is that really an issue?

Yes, in my opinion it is, and I disagree with you in every point.

> How many cases are there of underscores in Base?

1. Cloning Julia repository and calling `git grep 'function [a-z0-9]\+_.*'` inside it will give pages and pages of names with underscores. One can argue that many are for internal use but, if the core developers frequently use underscores internally, does not this mean they help comprehension?

> Imho, if your function name has underscores, refractor, or come up with a better name.

1. It is, to me, absolutely ridiculous that your advice is to refactor or come up with a better name. First, not every function can be described with a single word, second, if you gonna use more than one word why not use an underscore? I see no advantage between the same name without underscores.

> it forces you to think long and hard about names

1. Using underscores does not hinder creating better names. You can think long and hard about a name and if it ends up comprising two or more words then using an underscore is always better in my opinion. You may argue that the value is in _forcing_ the user to consider better names, and that giving up the underscore is worth this extra nudge, to this I would answer: (1) you will find many users are impervious to this _forcing_ effect and the result are horrendous names (that would be slightly better if underscores were allowed); (2) suggesting against underscores does not only nudge in the direction of good names but may also nudge people farther away from good names if the names are the most intuitive ones but look silly when mashed together.

2. Finally, I am not a native English speaker and I have difficulties understanding non-underscored names. Not every non-native speaker will have the same issue, but I think the choice to not use underscores ends up (unintentionally) disadvantaging an already disadvantaged group.

I stand by my arguments.

---

<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: [April 28, 2022, 5:27pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/10 "2022-04-28T17:27:44Z")

</div>

I agree with the sentiment that underscores can _aid_ comprehension. In the past, I have followed the stricture that names should avoid underscores, and not with the best outcomes, I am afraid.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [April 28, 2022, 5:46pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/11 "2022-04-28T17:46:21Z")

</div>

You’re entitled to your opinion, and to choosing whatever identifiers you prefer.

I’m just really happy that Base, and many others nudge us towards concise names. And, it is “the power of nudging” I am thinking of. Both the nudge towards clean and concise names in Base, and the nudge towards long, meandering names encouraged by the snake\_case style. Long names make code hard to read.

Internal names should be as ugly as they want. They are the nuts and bolts and circuitry sitting under the smooth, shiny surface. Ugly names tell me that I’m looking under the hood.

(BTW, also non-native speaker here.)

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [April 28, 2022, 5:54pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/12 "2022-04-28T17:54:26Z")

</div>

I have only one last thing to say to you: `isstructtype`.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [April 28, 2022, 6:02pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/13 "2022-04-28T18:02:33Z")

</div>

> [@Henrique\_Becker](#):
>
> isstructtype

That name serves its purpose: I’ve never used that function, and probably won’t 😉

---

<div class="post-metadata">

### Author: ![jbu](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@jbu](https://discourse.julialang.org/u/jbu)
#### Post date: [April 28, 2022, 9:24pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/14 "2022-04-28T21:24:25Z")

</div>

> [@DNF](#):
>
> Imho, if your function name has underscores, refractor, or come up with a better name.

> [@Henrique\_Becker](#):
>
> Using underscores does not hinder creating better names.

Is it too late to make Julia variable names insensitive to underscores and letter case, like [Nim](https://nim-lang.org/docs/manual.html#lexical-analysis-identifier-equality) does? That might help solve the debate 🙃

(Kidding, that’s definitely [not an option now](https://discourse.julialang.org/t/psa-julia-is-not-at-that-stage-of-development-anymore/44872) 😆)

---

<div class="post-metadata">

### Author: ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)
#### Post date: [April 28, 2022, 9:27pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/15 "2022-04-28T21:27:55Z")

</div>

There’s also the guide by @ExpandingMan: [ExpandingStyle](https://expandingman.gitlab.io/ExpandingStyle/)

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [April 28, 2022, 9:32pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/16 "2022-04-28T21:32:36Z")

</div>

Just out of curiosity, why nobody seems to use camelCase any more ? I like it :-/

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [April 28, 2022, 9:57pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/17 "2022-04-28T21:57:08Z")

</div>

> [@mbaz](#):
>
> There’s also the guide by @ExpandingMan: [ExpandingStyle](https://expandingman.gitlab.io/ExpandingStyle/)

While this guide does, in fact, exist, it has some highly idiosyncratic and off-kilter guidelines. I don’t think it should be held up as a ‘standard example’, it’s more of a list of ‘conversation starters.’

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [April 28, 2022, 10:07pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/18 "2022-04-28T22:07:46Z")

</div>

What exactly do you mean by not using camelCase anymore? Most style guides suggest `struct` type names to be in camelCase. It is just not adopted for local identifiers.

---

<div class="post-metadata">

### Author: ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)
#### Post date: [April 28, 2022, 10:30pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/19 "2022-04-28T22:30:33Z")

</div>

> [@DNF](#):
>
> highly idiosyncratic

Well, I happen to think it’s very sensible. To each their own, I guess 😅

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [April 28, 2022, 10:39pm UTC](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195/20 "2022-04-28T22:39:32Z")

</div>

This is a great example of how it is impossible to agree on style guides, even between experienced programmers. I am, as made exceedingly clear above, against DNF’s position of “no underscores in identifiers”. However, I do agree with DNF that ExpandingStyle is not very sensible, and the own author admits suggesting that “single characters are ideal” “[…] is likely to be one of the more controversial aspects of this style guide […]”. It is maybe the more important point I disagree with it, but I disagree with ExpandingMan’s guide on many other less relevant things.

[Next page](https://discourse.julialang.org/t/is-there-a-julia-style-guide/80195.md?page=2)
