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

<div class="post-metadata">

**Author:** ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)\
**Post date:** [January 24, 2018, 4:47pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/61 "2018-01-24T16:47:36Z")

</div>

> [@foobar\_lv2](#):
>
> In my dream world, julia would forbid all non-ascii tokens

So in your dream world, people only speak English?

---

<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, 4:59pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/62 "2018-01-24T16:59:20Z")

</div>

> [@foobar\_lv2](#):
>
> The important thing is that you can write everything in ASCII if you need to.
> 
> How?

I meant: use the ASCII version. Eg `sqrt`, or `xor`.

---

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [January 24, 2018, 5:04pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/63 "2018-01-24T17:04:59Z")

</div>

> [@jeff.bezanson](#):
>
> So in your dream world, people only speak English?

Julia speaks julia. English is not my native language, actually, and working with German characters is always a pain. Nevertheless, all current programming languages are designed for US layout keyboards; e.g. writing latex on a German keyboard layout will damage your hands (backslash is too hard to reach). Already keywords in most languages are English, and I think stuff like Microsoft translating visual basic keywords/library function names is silly (I cannot copy-paste code from a US-Excel into a German Excel sheet; it does not run). Oh, or the silly silly German opcodes Siemens uses in the assembly for some of their PLCs (I only know this because of stuxnet, I do not work with these machines).

Since the computer language itself is English-based (all library functions), and modern computers in general are English-based (x86 assembly names, llvm assembly names, everything), I see no harm in forcing people to adopt English-compatible function/type/variable names. I am not proposing to restrict source-code comments or string literals. Some people like mathy symbols; fine. We are only talking here about the preferred way of handling julia source in contexts that are not julia-aware (editors without julia mode, git, grep, etc), and I am claiming that unicode is a huge pain in these contexts.

I am aware that this is a minority opinion, and I don’t want to start a huge flamewar. Sorry if I sounded too aggressive.

---

<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, 5:13pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/64 "2018-01-24T17:13:44Z")

</div>

> [@jeff.bezanson](#):
>
> I see that some people feel the removal of underscores has “gone too far”, but I don’t see many concrete suggestions.

I hope you saw this suggestion:

> [@Naming: Remove all underscores to matter what?](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/28):
>
> Another option would be to: 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) 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). Create packages that provide legacy names (Matlabisms such as cumsum, cum…

My objection with getting rid of underscores is when it is done just to get rid of them, which does hurt readability (such as a recent PR wanting to change an uppercase constant to remove the `_`).  
Changes like `module_name(mod)` → `Symbol(mod)` both gets rid of the underscore, and makes things more generic, which is a win-win.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 24, 2018, 5:42pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/65 "2018-01-24T17:42:25Z")

</div>

I agree that Unicode should stay out of exported package and Base APIs because there are cases where it’s just not easy. For example, some clusters I’ve used have a terminal which doesn’t display unicode even if I’m using a Unicode-compatible terminal to view on my end.

Using Unicode in your own personal scripts is a perfect fine if not awesome thing to do though. Making your variables `\alpha` to match a paper makes things super legible compared to `alpha*beta+gamma`. So as always, it’s a tool and when used appropriately it’s great, but when abused it causes problems.

---

<div class="post-metadata">

**Author:** ![jeff.bezanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff.bezanson/32/48_2.png) [@jeff.bezanson](https://discourse.julialang.org/u/jeff.bezanson)\
**Post date:** [January 24, 2018, 5:54pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/66 "2018-01-24T17:54:02Z")

</div>

> [@foobar\_lv2](#):
>
> forcing people

That’s something I try to avoid.

> [@ScottPJones](#):
>
> I hope you saw this suggestion:

> [@ScottPJones](#):
>
> First see if the functionality can be put in an easy to use API with using multiple dispatch and/or keyword arguments

That’s not a suggestion, that’s quoting our own philosophy back at us. Of course we first try to do without compound names.

> [@ScottPJones](#):
>
> sparse\_ones instead of spones

`spones` has been deprecated.

> [@ScottPJones](#):
>
> such as a recent PR wanting to change an uppercase constant to remove the \_

Which PR is that? Was it merged?

---

<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, 6:03pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/67 "2018-01-24T18:03:48Z")

</div>

> [@jeff.bezanson](#):
>
> That’s not a suggestion, that’s quoting our own philosophy back at us.

I don’t think changing things to have longer meaningful names _with_ underscores and using aliases in packages for historical short forms, which is part of my suggestion, has been part of that philosophy, at least as far as I’ve seen.

> [@jeff.bezanson](#):
>
> spones has been deprecated.

💯

> [@jeff.bezanson](#):
>
> Which PR is that? Was it merged?

I don’t recall - and I think you were the voice of sanity in that case 🙂

---

<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 24, 2018, 6:12pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/68 "2018-01-24T18:12:51Z")

</div>

> [@ScottPJones](#):
>
> I don’t think changing things to have longer meaningful names with underscores and using aliases in packages for historical short forms, which is part of my suggestion, has been part of that philosophy

I really can’t help but feeling that people are responding to this issue as if the Julia devs are asking everyone to avoid using underscores in their code. That’s not what’s happening, and as I’ve pointed out a number of times now, at least the vast majority of the stuff in `Base` is pretty clear.

Does anyone really think that `getindex` should be `get_index` or `setindex!` should be `set_index!` or `ismissing` should be `is_missing` or anything like that? Because I really didn’t think anyone was arguing that and if they are, I really can’t understand why in the world you’d want to make those names more verbose, they are simultaneously about as descriptive and succinct as they can possibly be in their current form.

I’m quite sure that _nobody_ is advocating craziness like `besselfunctionofthesecondkind`, how much is there really in `Base` that is long enough that it seems unreadable? Examples?

---

<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, 6:19pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/69 "2018-01-24T18:19:52Z")

</div>

> [@ExpandingMan](#):
>
> Does anyone really think that getindex should be get\_index or setindex! should be set\_index! or ismissing should be is\_missing or anything like that?

I actually do find having things like that more readable with an underscore, i.e. with prefixes like:  
`is_`, `has_`, `get_`, `set_`. Otherwise you end up with some that are a bit confusable if you don’t already know what they are, such as `isqrt`. There are also examples where mashing two words together can end up with something that looks bad, `is_hit` looks a lot worse as `ishit`!

---

<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 24, 2018, 6:33pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/70 "2018-01-24T18:33:39Z")

</div>

> [@ScottPJones](#):
>
> I actually do find having things like that more readable with an underscore,

I guess this is purely a matter of opinion so that I can’t offer any further justification but I emphatically disagree with this. Let me at least provide some context to show why I feel that way.

Most of my real thinking occurs when I write things out algebraically. Like most people, when I do this, I use succinct, abstract names _all the time_. Nobody in their right mind would ever want to look at an equation that contains \mbox{hyperbolic\_sine}(y) rather than \sinh(y). So, if you wouldn’t want to look at this when actually reasoning about things in terms of their pure mathematical abstraction, _why_ would you want to look at `hyperbolic_sin(y)` in your code? Sure, `isbits` is not as universally understood as `sinh`, but the same thing applies, why make everything more verbose? In cases where symbols are already clear and understandable anyway, it just takes extra brain power to parse more verbose names.

---

<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, 6:54pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/71 "2018-01-24T18:54:00Z")

</div>

> [@ExpandingMan](#):
>
> Sure, isbits is not as universally understood as sinh

This depends upon which domain you are coming from - for mathematicians, `sinh` is well understood.  
Also though, I wouldn’t advocate renaming functions that have a well understood name in the literature of the domain.  
However, when it is a matter of a name that is short just because of legacy reasons (names had to be significant in the first 8 bytes in linkers back in the 80s, just like file names on Unix were 14 bytes, and 8.3 on CP/M and PC-DOS), such as the names that came from MATLAB, then I’d rather see a longer descriptive name (more like the ones in Mathematica), and a `MATLAB.jl` compatibility package for people who want to use the names they are familar with.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [January 24, 2018, 7:14pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/72 "2018-01-24T19:14:24Z")

</div>

> [@anon94023334](#):
>
> We are considering removing the is\_ / has\_ and appending a unicode question mark-like glyph

> [@foobar\_lv2](#):
>
> I am aware that this is a minority opinion,

I agree with you. I find that imposing unicode characters in functions is a terrible idea and ignores the fact that thee are so many people that do not know what unicode characters are. Not to mention the difficulty to write them in many text editors.

---

<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, 7:30pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/73 "2018-01-24T19:30:03Z")

</div>

the hyperbolic functions could be easily refactored with keyword arguments: hyperbolic = true, inverse = true, etc.

---

<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, 8:24pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/74 "2018-01-24T20:24:32Z")

</div>

> Does anyone really think that getindex should be get\_index or setindex! should be set\_index! or ismissing should be is\_missing or anything like that?

Yes. I think this, especially when I also have `get_something_that_is_a_bit_longer` defined, and want SOME sort of (internal) consistency in my code. In LightGraphs, for example, we have `has_vertex`, which could easily (and more properly) be shortened to `hasvertex`, but then we have `has_self_loops`. Should we be inconsistent in our treatment of functions that start with `has`?

---

<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 24, 2018, 8:41pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/75 "2018-01-24T20:41:00Z")

</div>

First of all: `hasselfloops` may not be a good name, but it _is_ a _great_ one! Very memorable.

`has_self_loops` on the other hand, is quite awkward. Please, keep in mind that I don’t know what a “self loop” is, but could you call it `isloopy`, `iscyclic`, `hascycles`, or anything like that? `has(x, Loop)`? Etc. etc.

---

<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, 8:45pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/76 "2018-01-24T20:45:39Z")

</div>

[This graph](https://upload.wikimedia.org/wikipedia/commons/d/d6/UndirectedDegrees_%28Loop%29.svg) has self-loops (specifically, vertex 5). Loops are different than cycles, unfortunately.

My intention is not to get into a renaming discussion with this particular function; rather, it’s to suggest that `is_` and `has_` have places in the language when the function names are longer or complex, and IMO it’s better to be consistent in your treatment of them than it is to try to shorten them and have inconsistencies.

This is why it’s a relevant discussion for this thread: since Base is moving towards `is` instead of `is_`, ideally, we’d maintain consistency with it. But we can’t.

---

<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 24, 2018, 8:47pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/77 "2018-01-24T20:47:23Z")

</div>

> [@anon94023334](#):
>
> My intention is not to get into a renaming discussion with this particular function

Sure, it’s not mine either. I’m just trying to illustrate, using that as an example.

But, if you don’t want `hasselfloops`, I hope someone else can use it…

---

<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 24, 2018, 8:52pm UTC](https://discourse.julialang.org/t/naming-remove-all-underscores-to-matter-what/8549/78 "2018-01-24T20:52:35Z")

</div>

> [@anon94023334](#):
>
> Should we be inconsistent in our treatment of functions that start with has?

In my opinion, in this case yes (though I don’t want to get into arguments about individual packages. I think package developers should make there own choices, `has_vertex` is certainly not unreasonable, so you shouldn’t misconstrue this as a complaint about it).

I think the fundamental disagreement is between people who think verbosity is more important for readable code and those who think succinctness is more important for readable code. I don’t think there’s any objective right or wrong here, so I’m not sure what more can be said about it. As for me, I want things to look as much like their mathematical abstraction as possible, to be as succinct as possible, the verbosity just makes it harder for me to read things. I don’t care how inconsistent `sinh` is with other code that says `hyperbolic_more_complex_function`, I just don’t want to look at `hyperbolic_sine`. Ever. To me that that supersedes everything except extreme cases where function names are really totally unreadable, even if this results in some modest inconsistency.

(by the way, just to show I’m not being difficult for the sake of being difficult, I would argue for `has_self_loops` over `hasselfloops`)

---

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

</div>

> [@ExpandingMan](#):
>
> I want things to look as much like their mathematical abstraction as possible

I don’t think people are disagreeing about that at all. If something has a well known name in the _literature_ (not just a common one in some computer languages), then it should keep that name, as people used to working in that domain, should be able to understand it.  
Even Mathematica, known for longer descriptive names, calls hyperbolic sine `sinh`.

I don’t think, however, that there are many (any?) math functions that are of the form `is*`, `has*`, `get*`, or `set*`, for example, so whether or not they use `_` to be more readable is a separate issue.

---

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

</div>

If one writes code with complex expressions that contain many identifiers, then long, descriptive names make those expressions harder to read.

I think this is particularly a concern for people who write a lot of mathematical/physical oriented code. Short, concise variable names actually help legibility for us, since we look at the entire expression, not just each individual identifier. It’s not just about well-known names from the literature.

**Edit** : Furthermore, the code is often highly abstract, so there isn’t necessarily any reason to make the names descriptive. `x`, `y`, `α`, and so on is descriptive enough. The preference for brief names may come from this, too. Introducing abominations such as `sin(x, hyperbolic=true, inverse=true)` (as someone suggested) would basically destroy any legibility what so ever.

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

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