# 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:** 2

<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 23, 2018, 9:17pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/21 "2018-01-23T21:17:36Z")

</div>

> [@gabrielgellner](#):
>
> if the names is find\_shortest\_path instead of findshortestpath are you saying that because the latter is far harder to read it leads to better names? Do people make API choices simply because they are scared of spaces and need to be cruel to end users?

There’s nothing automatic about this, of course, but _I_ at least take this convention as a way of forcing myself to think once or twice more, about how I can avoid long ugly compound names, without resorting to underscores.

> [@gabrielgellner](#):
>
> Generally I do find that the core devs are careful with the names they pick, but as a rule the current naming conventions and taste for removing all underscores leads to a real adhoc mix of really nice short names, as well as mashed together names of varying readability, and ones with underscores.

Perhaps many of those just don’t have the best possible names yet?

I guess you can never have _just_ short, beautiful expressive names, there will always be warts. But by choosing this convention, the devs are at least consciously pushing the language in a particular direction, and I think that the balance of advantage will ultimately prove to be on the positive side.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 23, 2018, 9:20pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/22 "2018-01-23T21:20:55Z")

</div>

> [@ufechner7](#):
>
> Nothing improves if you remove this degree of freedom.

To clarify, we don’t no insist that everyone write Julia code without underscores. It is a discipline [beautifully explained by DNF](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/12) to which Base Julia strives to adhere in its public API. In internal functions and in my own code I use underscores all over the place because the factoring of the code doesn’t matter so much. Not all code needs to be reduced to its most atomic elements of design, but that’s what we aim for in the Base language.

---

<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 23, 2018, 9:29pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/23 "2018-01-23T21:29:51Z")

</div>

Okay my last post as these kinds of things are always a pit. It has been very helpful for me to understand how people see this, even if I fully disagree. I don’t want to just end with the impression that I have not found this discussion interesting!

The thing I really can not understand is how removing underscores is seen as somehow making the variables more “atomic” / “minimal” or pure. I see it simply syntactically, I see no “purity” change between `is_dense` `isdense` or `isDense` they are simply different ways of separating words in a variable name.

If you move from `is_dense` to `isdense` you have not found a more atomic expression of your code, you simply removed an underscore. If you need to use an underscore, don’t cheat, use it. If you somehow find a more atomic name great! You have found real beauty. Base has done this latter kind of reduction many times, but I think we are getting into a state were we are cheating instead, separate words should have underscores, removing them does not magically get rid of the need (because you are combining distinct words).

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 23, 2018, 9:30pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/24 "2018-01-23T21:30:24Z")

</div>

You can do things like multiplying, adding and dividing matrices and vectors without using `LinearAlgebra`. The things that are exported from `LinearAlgebra` and not available in `Base` are things like special matrix types, factorization types, and specialized linear algebra operations like `axpy!`. Really basic linear algebra operations still don’t require any imports.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 23, 2018, 9:52pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/25 "2018-01-23T21:52:06Z")

</div>

A while ago, I made this list of lowercase exports split into words where they potentially could be:

[https://gist.github.com/StefanKarpinski/05a9bb83c257b2c3d51d5f78c7153cd3](https://gist.github.com/StefanKarpinski/05a9bb83c257b2c3d51d5f78c7153cd3)

The thought was maybe we could standardize on “using underscores consistently”. The trouble with this turns out to be that there are many very well established function names – especially in math– that do not have underscores. This leaves three options:

1. Use underscores consistently to separate words policy, but be the only language around that spells `abspath` as `abs_path`, `dirname` as `dir_name`, `basename` as `base_name`, `lcfirst` as `lc_first`, `linspace` as `lin_space`, `logdet` as `log_det`, `logabsdet` as `log_abs_det`, `nullspace` as `null_space`, `ordshur` as `ord_shur`, `pinv` as `p_inv`, `randn` as `rand_n`, `readline` as `read_line`, `repmat` as `rep_mat`, `sortrows` as `sort_rows`, etc. What about `acosd`? Should that be spelled `a_cos_d`? If not, then why not? What exactly constitutes a word?

2. Use underscores except when there’s a strong legacy reason for not doing so. However, this is a pretty subjective judgment call, and leaves the language with a wildly inconsistent experience where – much like English spelling – you have to know the provenance of a name in order to guess how to spell it.

3. Avoid underscores and try to factor APIs as much as possible so they aren’t missed. This is what we do.

I think it’s easy to focus on a few ugly examples of the “no underscores” approach that are not great (e.g. `nbytesavailable`), but it’s much harder to actually come up with a consistent policy that doesn’t lead to even more absurd cases (criticism is easier than design). Mathematica takes the approach of spelling out absolutely everything, which is very predictable and very characteristic. The Mathematica-esque names of some of the above names would be something like `DirectoryName`, `FileBaseName`, `LinearSpace`, `RepeatMatrix`, `SortRows` and so on. That’s a consistent policy, and a respectable choice, but being equally explicit and verbose (with underscores or camelcase) would lead to a very different feeling language than Julia.

---

<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 23, 2018, 10:04pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/26 "2018-01-23T22:04:10Z")

</div>

> [@ExpandingMan](#):
>
> I agree that particularly verbose function names, when necessary, should have underscores.

Me too! A number of people tried to come up with best practice suggestions / recommendations for naming, indentation, etc. in Julia, at [Julia Praxis · GitHub](https://github.com/JuliaPraxis).

I do think the whole “let’s get rid of underscores” movement for v1.0 has gone a bit far.  
If something _cannot_ be refactored using multiple dispatch and composition, then readability is still important, and shouldn’t be sacrificed in this manner.

---

<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 23, 2018, 10:14pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/27 "2018-01-23T22:14:12Z")

</div>

> [@gabrielgellner](#):
>
> If you move from is\_dense to isdense you have not found a more atomic expression of your code, you simply removed an underscore.

Even if it doesn’t lead to improved names in a particular instance, one can hope that as a policy it leads to better names in the big picture.

---

<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 23, 2018, 10:18pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/28 "2018-01-23T22:18:39Z")

</div>

> [@StefanKarpinski](#):
>
> Use underscores except when there’s a strong legacy reason for not doing so. However, this is a pretty subjective judgment call, and leaves the language with a wildly inconsistent experience where – much like English spelling – you have to know the provenance of a name in order to guess how to spell it.

Another option would be to:

1. First see if the functionality can be put in an easy to use API with using multiple dispatch and/or keyword arguments, _without_ performance penalty. (The changes in master seem to be shaping up nicely to help out with that)
2. Otherwise use underscores to provide longer, readable names (`sparse_ones` instead of `spones`, for example). (Hopefully, in most cases No. 1 could make this rarely necessary).
3. Create packages that provide legacy names (Matlabisms such as `cumsum`, `cumprod` etc. come to mind), so that legacy names don’t pollute the Base namespace. That would help resolve the problem you identified about the language feeling inconsistent. (It already feels inconsistent, this could improve things).

---

<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 23, 2018, 10:23pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/29 "2018-01-23T22:23:46Z")

</div>

> [@gabrielgellner](#):
>
> If you move from is\_dense to isdense you have not found a more atomic expression of your code, you simply removed an underscore.

Yes!  
Because of that, there are names that look ambiguous - `isqrt`, is that supposed to be a test if something is `qrt`? (it’s the only one that starts with `is` that _doesn’t_ mean `is` something).  
Instead, Integer `sqrt` could be `sqrt(Integer, val)`, for example.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 23, 2018, 10:48pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/30 "2018-01-23T22:48:06Z")

</div>

> [@StefanKarpinski](#):
>
> Which of these do you feel is really essential to have available without doing any import at all?

Is it far fetched to have Julia installed with a .juliarc file that imports all the packages in the standard library by default? This will be convenient for completely new users, perhaps even learning programming for the first time in a scientific context, plus the file can be modified by more experienced programmers to suit their own interests if they don’t like all these modules to be automatically imported. I think this will make everyone happy.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 23, 2018, 11:13pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/31 "2018-01-23T23:13:31Z")

</div>

Yes, it’s entirely possible but it won’t be the default.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 23, 2018, 11:23pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/32 "2018-01-23T23:23:09Z")

</div>

> [@StefanKarpinski](#):
>
> but it won’t be the default.

May I ask why?

---

<div class="post-metadata">

**Author:** ![bramtayl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bramtayl/32/3614_2.png) [@bramtayl](https://discourse.julialang.org/u/bramtayl)\
**Post date:** [January 24, 2018, 2:46am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/33 "2018-01-24T02:46:56Z")

</div>

Fought and lost. [https://github.com/JuliaLang/julia/issues/14340](https://github.com/JuliaLang/julia/issues/14340). Although [https://github.com/JuliaLang/julia/issues/20402](https://github.com/JuliaLang/julia/issues/20402) is more than enough compensation for me.

---

<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, 3:10am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/34 "2018-01-24T03:10:16Z")

</div>

Here’s a crazy idea we’re floating in LightGraphs: we have a bunch of functions that start with `is_` and `has_` (e.g., `is_connected`, `has_edge`) that return a boolean. We are considering removing the `is_` / `has_` and appending a unicode question mark-like glyph (`ʔ` or `⁇`, maybe) so that we have `connectedʔ` and/or `edge⁇` as functions.

The nice thing about this is that since the unicode is at the end, tab-completion would allow users to avoid having to type the characters.

(The reason we want to do this is because we have a few functions that are very long and can be misinterpreted: `has_self_loops` becomes `hasselfloops` which is very close to [this](http://cdn3-www.comingsoon.net/assets/uploads/2016/03/hasselhoffbaywatch.jpg).

Soliciting thoughts on this idea – please provide input.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [January 24, 2018, 3:15am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/35 "2018-01-24T03:15:17Z")

</div>

> [@mohamed82008](#):
>
> have Julia installed with a .juliarc file that imports all the packages in the standard library by default

No that’s a terrible default. You are encouraging people to write script that depend on subtle global setting and code that can’t run anywhere else.

---

<div class="post-metadata">

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

</div>

@anon94023334, I like the idea of ending with a questionmark, but it needs to be something with a \symbolname so that people can type it at the repl, ⍰ \APLboxquestion or what about U+00294 ʔ `\Elzglst Latin Letter Glottal Stop`?

---

<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 24, 2018, 3:36am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/37 "2018-01-24T03:36:10Z")

</div>

Too bad `¿` can’t be used (it’s not an identifier character - at least not currently)! 😀  
It’s an ANSI Latin 1 character (i.e. one of the first 256 codepoints of Unicode) (0xbf)  
I do prefer `is_` and `has_` though, quite frankly.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 24, 2018, 3:46am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/38 "2018-01-24T03:46:29Z")

</div>

> [@yuyichao](#):
>
> script that depend on subtle global setting and code that can’t run anywhere else.

May you elaborate? stdlib packages are packaged with Julia, so what’s the problem?

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [January 24, 2018, 5:08am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/39 "2018-01-24T05:08:11Z")

</div>

> [@mohamed82008](#):
>
> May you elaborate? stdlib packages are packaged with Julia, so what’s the problem?

I think what @yuyichao meant was that people will then write their Julia programs expecting the stdlibs to be loaded, which will then break when the global `.juliarc` file is changed.

---

<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 24, 2018, 6:29am UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/40 "2018-01-24T06:29:21Z")

</div>

> [@anon94023334](#):
>
> appending a unicode question mark-like glyph (ʔ or ⁇, maybe)

I like it very much, but can you type either of those with a `\`-completion at the REPL? How? I could not find them in the table.

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

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