# Naming: Remove all underscores to matter what?

**URL:** <https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549>\
**Category:** General Usage\
**Created:** [January 23, 2018, 5:52pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549 "2018-01-23T17:52:55Z")\
**Posts on this page:** 20\
**Page:** 5

<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:** [January 24, 2018, 11:04pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/81 "2018-01-24T23:04:31Z")

</div>

Am I missing something? I don’t think the standard library has any horrible, illegible names? And for your own code you can use whatever you want (even those questionable Unicode characters). What are we talking about here?

---

<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:** [January 24, 2018, 11:56pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/82 "2018-01-24T23:56:29Z")

</div>

> [@PetrKryslUCSD](#):
>
> What are we talking about here?

Speaking only for myself, it was a proposal to use unicode characters to obviate the need for `has_` and `is_` in function names, in order to more closely align with Base’s decision to avoid underscores wherever possible.

---

<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:** [January 24, 2018, 11:57pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/83 "2018-01-24T23:57:32Z")

</div>

Right. I understand your point, but then my concern about the Unicode being possibly misunderstood as an operator is I think valid.

---

<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:** [January 24, 2018, 11:59pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/84 "2018-01-24T23:59:30Z")

</div>

> [@PetrKryslUCSD](#):
>
> my concern about the Unicode being possibly misunderstood as an operator is I think valid.

Agreed, which is why [we’ve decided to table the idea for now.](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/56)

---

<div class="post-metadata">

**Author:** ![NaOH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naoh/32/5632_2.png) [@NaOH](https://discourse.julialang.org/u/NaOH)\
**Post date:** [January 25, 2018, 12:29am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/85 "2018-01-25T00:29:37Z")

</div>

How about using prefixes with underscore and then mashed words when sensible? i.e.: `has_selfloops`, `is_foobar`, etc.

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [January 25, 2018, 3:41am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/86 "2018-01-25T03:41:13Z")

</div>

While I do think that this topic has probably seen enough discussion, something that I haven’t seen mentioned yet is the fact that we have easily accessible documentation via the REPL. So, even if a function name looks somewhat confusing at a quick glance, we can easily search it in the REPL and open the documentation, which would hopefully clear up any confusion. I think this should not be overlooked.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [January 25, 2018, 6:47am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/87 "2018-01-25T06:47:58Z")

</div>

> [@tbeason](#):
>
> So, even if a function name looks somewhat confusing at a quick glance, we can easily search it in the REPL and open the documentation, which would hopefully clear up any confusion. I think this should not be overlooked.

It’s not overlooked, but it’s another drag on productivity (just like taking longer to read something if names are mashed together instead of having words separated via underscores).  
Julia can be a very productive language, but some of that is lost if you have to be copy/pasting stuff into the terminal to find out what it means.

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [January 25, 2018, 8:26am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/88 "2018-01-25T08:26:45Z")

</div>

For what it’s worth: I really like the principle of trying to find a good policy and then stick to that policy even in fringe cases where it might be sub-optimal. It significantly reduces the number of things that I have to memorize.  
For example, knowing that Julia never puts underscores in function names is just one thing to remember.  
On the other hand: putting underscores “where necessary” would require me to memorize a list of maybe a hundred functions where the developer deemed underscores “necessary”.

I’ll happily sacrifice some readability for less memorization.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 25, 2018, 9:27am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/89 "2018-01-25T09:27:50Z")

</div>

> [@Per](#):
>
> putting underscores “where necessary” would require me to memorize a list of maybe a hundred functions where the developer deemed underscores “necessary”

I suspect that one of the things that is not made explicit in these discussions is how much people rely on their IDE when writing code. In a reasonably good IDE, you would never need to memorize anything, and function names are be completed from fragments.

I agree that the fewer special cases one needs to memorize, the easier programming is. But function names just scratch the surface: it is nice to have them consistent, but that’s just the first step. @Evizero above mentioned a particularly important point about API design using multiple dispatch, which allows a small, composable vocabulary. I think that this is the an ideal we should strive for when feasible.

At the same time, designing a good API is an organic process that takes multiple iterations, which are sometimes tedious, frustrating, and occasionally require backtracking. My impression is that [#20402](https://github.com/JuliaLang/julia/issues/20402) is not meant to be the final word, just a single pass to fix some warts and inconsistencies. No doubt there will be further ones, with results that are impossible to predict (if developers could predict the final API, they would write it first).

---

<div class="post-metadata">

**Author:** ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)\
**Post date:** [January 25, 2018, 9:52am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/90 "2018-01-25T09:52:58Z")

</div>

> [@Tamas\_Papp](#):
>
> @Evizero above mentioned a particularly important point about API design using multiple dispatch, which allows a small, composable vocabulary.

Evizero is reasonably confident that he didn’t even read this thread, let alone comment on it

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 25, 2018, 9:56am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/91 "2018-01-25T09:56:23Z")

</div>

Of course, it was @ExpandingMan. I hit the wrong completion (but then why was it offered? a mystery). Sorry for the noise.

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [January 25, 2018, 10:03am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/92 "2018-01-25T10:03:55Z")

</div>

> [@Tamas\_Papp](#):
>
> I suspect that one of the things that is not made explicit in these discussions is how much people rely on their IDE when writing code.

That is definitely true for languages like Java, where you frequently write things like `GodObject.SubObject.SubSubObject`. However, it is not so common for languages like English, where words are much shorter, but the first few letters of a word are not easy to guess unless you know the entire word.

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [January 25, 2018, 12:04pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/93 "2018-01-25T12:04:10Z")

</div>

> [@Tamas\_Papp](#):
>
> Of course, it was @ExpandingMan. I hit the wrong completion (but then why was it offered? a mystery). Sorry for the noise.

I agree with your point, but you have to admit that this is a bit funny given the quote below 🙂

> [@Tamas\_Papp](#):
>
> In a reasonably good IDE, you would never need to memorize anything, and function names are be completed from fragments.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 25, 2018, 12:15pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/94 "2018-01-25T12:15:19Z")

</div>

Touché 😄 Discourse would probably not be a good IDE 😉

---

<div class="post-metadata">

**Author:** ![gabrielgellner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielgellner/32/75_2.png) [@gabrielgellner](https://discourse.julialang.org/u/gabrielgellner)\
**Post date:** [January 25, 2018, 6:16pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/95 "2018-01-25T18:16:01Z")

</div>

I would much prefer the `is_` `has_` versions. The issue is exactly as you say, because we chose a convention for separating words that uses an extra character (`_`) people conflate this with being “verbose”. Nobody in javascript or C# would ever have `hasloops` instead of `hasLoops` because the convention doesn’t get mixed up with some strange feeling about being “shorter”. What is happening in julia is that we hate underscores, so we are left with ad hoc rules for when to use them and when not. Because of Base you really should name things like `hasfoo` and `isfoo` but if you have all other versions in your code with `pre_foo` then you now have a subtle convention that is not consistent. People are bringing up math abbreviations, but I really don’t find this convincing. Even Mathematica which is the shinning light of consistency uses the abbreviations, I think very justifiable deviations from convention is easy to understand.

Optim.jl is a beautiful example of nice consistent `_` use, but it does feel like it clashes with Base. And even when I want to use the pseudo conventions from base if I do `hasself_loops` I feel gross but `has_self_loops` is less idiomatic. I know jokes about Hasselhoff seem to make this seem cute, but it is just adding a lot of special cases to the conventions used which make the language harder to remember in a pinch.

My eyes are open that this is not going to change, julia is going to be more like English, which lots of strange special cases and alternate spellings. I guess all I take from it in the end is that `_` conventions are inferior to camelCase, people are just irrationally against 1-3 extra characters and will build whole sets of individual decisions instead of adding this insignificant overhead.

---

<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:** [January 25, 2018, 6:42pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/96 "2018-01-25T18:42:16Z")

</div>

Again, I am not understanding this conversation. Are you guys complaining about the stdlib names or about some (imaginary) restrictions on the names you yourselves can use in your code? I say imaginary, because as far as I know there are no restrictions! Do you wish to stick to Julia conventions? Go for it! Do you wish to hang loose? Nothing prevents you…

---

<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:** [January 25, 2018, 6:49pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/97 "2018-01-25T18:49:57Z")

</div>

> [@gabrielgellner](#):
>
> The issue is exactly as you say, because we chose a convention for separating words that uses an extra character (\_) people conflate this with being “verbose”.

I think it is you who are conflating things. Removing underscores does not make identifiers shorter. But discouraging underscores _encourages_ you to make shorter identifiers.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [January 25, 2018, 6:50pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/98 "2018-01-25T18:50:58Z")

</div>

> [@gabrielgellner](#):
>
> I would much prefer the is\_ has\_ versions. The issue is exactly as you say, because we chose a convention for separating words that uses an extra character (\_) people conflate this with being “verbose”.

More characters, more verbose (particularly if they are as inconvenient to type and, more importantly, visually conspicuous as `_`). That’s my definition of verbose. (I rather like camelCase, that’s a separate issue.)

> [@gabrielgellner](#):
>
> Even Mathematica which is the shinning light of consistency uses the abbreviations, I think very justifiable deviations from convention is easy to understand.

Ok, but there are certainly cases in which I’d prefer mathematica to be more concise. As I’ve pointed out a number of times, multiple dispatch makes this somewhat easier in Julia.

> [@gabrielgellner](#):
>
> People are bringing up math abbreviations, but I really don’t find this convincing.

Why not? This is the golden standard for comparison. Mathematical notations are largely designed to be easy to understand when you look at them. Seeing \nabla\_{\mu}F^{\mu\nu} = J^{\nu} as \sum\_{\mu=1}^{4}\nabla\_{\mu}F^{\mu\nu} = J^{\nu} ~~ \forall \nu makes me want to kill myself. `is_bits` isn’t nearly as bad bit it’s still annoying.

Good notations have given rise to many [wonderful](https://arxiv.org/abs/1306.2164) [tools](https://arxiv.org/abs/0812.1594) and are an important boon in helping to understand things. Some [subjects](https://en.wikipedia.org/wiki/Einstein%E2%80%93Cartan_theory) are difficult to study largely because they are notationally difficult. If we held consistency and explicit specification as the highest standard a lot of math would be completely unreadable. I very much want my code to look as much like mathematical notation as possible. Sometimes that’s impossible or impractical, a lot of times it leads to mildly inconsistent names such as `isthing` or `hasthing`.

---

<div class="post-metadata">

**Author:** ![gabrielgellner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielgellner/32/75_2.png) [@gabrielgellner](https://discourse.julialang.org/u/gabrielgellner)\
**Post date:** [January 25, 2018, 6:54pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/99 "2018-01-25T18:54:06Z")

</div>

What are the Julia conventions for underscores? I get that when I am by myself I can use whatever I want, but this feels like a shallow response. I work in teams, I share my code, code conventions exist to remove barriers to reading other peoples code. I am happy to submit to whatever the prevailing convention is in a language I use. Julia is tricky as one of the main conventions for naming is ad hoc, how to I separate words? It seems to be mash together when you can, use underscores if you must – but feel bad about it, and wonder if maybe there is some magical mashed version that is better. But recently with some of the audits in Base this is moving to, mash together always.

If when 1.0 comes out and Base has not a single user facing `_` name. The true de facto convention will seem to be lowercase names are purely mashed together. And more likely each project will make a personal choice on what it uses, so when using Base + Optim + LightGraphs etc, you will have potentially 3 different `_` patterns to remember, and worse, see in your code. Maybe I choose my own convention as well, because freedom! So I will use camelCase as I want word separation, but don’t want those dastardly underscores. This is the conversation I was trying to have. What I feel has come back is that it is not an issue. Which I guess is a question for the future as the ecosystem stabilizes, maybe some true convention will emerge, or we will just have a stochastic pattern of underscores in Julia code.

---

<div class="post-metadata">

**Author:** ![gabrielgellner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gabrielgellner/32/75_2.png) [@gabrielgellner](https://discourse.julialang.org/u/gabrielgellner)\
**Post date:** [January 25, 2018, 7:00pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/100 "2018-01-25T19:00:13Z")

</div>

we are talking about 1 character in the vast majority and 3 at the almost absolute worst. I just don’t buy that this is the same as real progress in notation, which is a vastly more difficult issue. `3+3` vs `3 + 3` I would argue is no change is semantic / notational beauty, but it is a perfectly good convention for separating operators in programming languages even if it has 2 extra characters. I see underscores between words (again with no arguments on what the words are, or if they are minimal) as being a typographic convention for programming, it is not a semantic change in notation.

[Previous page](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549.md?page=4)

[Next page](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549.md?page=6)
