# \`not\`, \`and\`, \`or\` as logical operator keyword

**URL:** <https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933>\
**Category:** Internals & Design\
**Created:** [February 7, 2022, 5:36am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933 "2022-02-07T05:36:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmsmsgood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rmsmsgood/32/20544_2.png) [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)\
**Post date:** [February 7, 2022, 5:36am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/1 "2022-02-07T05:36:57Z")

</div>

[https://github.com/JuliaLang/julia/issues/5238](https://github.com/JuliaLang/julia/issues/5238)

I guess many people want to use `not`, `and`, `or` as logical operator keyword. I prefer

```julia
if A and not B
    foo()
end

```

rather than

```julia
if A && !B
    foo()
end

```

because above one is more easy to read and similar to native english. Why julia chooses below **exclusively**?

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [February 7, 2022, 5:42am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/2 "2022-02-07T05:42:35Z")

</div>

There is an extensive discussion in that linked issue about the reasons why

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [February 7, 2022, 5:59am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/3 "2022-02-07T05:59:55Z")

</div>

> [@PSA: Julia is not at that stage of development anymore](https://discourse.julialang.org/t/psa-julia-is-not-at-that-stage-of-development-anymore/44872):
>
> You heard about this brand new exciting programming language called Julia and have some suggestions for how it should work. Wonderful! We’re happy to have you here and help you learn the language and listen to your ideas! However, please be aware that “new” is a relative term. Yes, Julia is newer than, say, C, which was first created in 1972 and standardized in 1989. It is not, however, new in the sense that it is still being freely designed and changed in arbitrary ways. Julia development start…

might also be relevant here.

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 7, 2022, 9:35am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/4 "2022-02-07T09:35:38Z")

</div>

> [@rmsmsgood](#):
>
> I guess many people want to use `not` , `and` , `or` as logical operator keyword. I prefer

I wouldn’t prefer it, as I like &&,||,! more than words (perhaps because of C,C++,… history of mine). But as an option I would not be against it.

(I am triggered whenever I read something which starts with “many people want” or “many of us would prefer”)

---

<div class="post-metadata">

**Author:** ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Post date:** [February 7, 2022, 9:47am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/5 "2022-02-07T09:47:25Z")

</div>

Heh, one could use Unicode to implement  
∧ ∨ ¬ ⊕ ⊻ ⊼ ⊽

although I don’t think that helps readability.

---

<div class="post-metadata">

**Author:** ![rmsmsgood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rmsmsgood/32/20544_2.png) [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)\
**Post date:** [February 7, 2022, 10:34am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/6 "2022-02-07T10:34:53Z")

</div>

Sure, there are people wouldn’t prefer words. But interesting, i don’t like those symbols by the same reason. In my history, C++ → R → python → fortran → julia (I’m in data/math/statistics). I was surprised about that even fortran implemented `.OR.`, `.AND.`, `.NOT.` and i feel comfortable with fortran more than C++. 😂 I’m used to write R code specifically, it’s OK, but i love that 3 words `and`, `or`, and `not`.

I admit that sometime `&&` and `||` are more suitable to julia, eg. broadcasting. If i have to write `.&&` or `.and`, then i’ll choose `.&&` of course. I think it’s just about preference. I want both, `and` && `&&`.

---

<div class="post-metadata">

**Author:** ![rmsmsgood](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rmsmsgood/32/20544_2.png) [@rmsmsgood](https://discourse.julialang.org/u/rmsmsgood)\
**Post date:** [February 7, 2022, 10:36am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/7 "2022-02-07T10:36:05Z")

</div>

But thank you! I have a question, do they short-circuit evaluate?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [February 7, 2022, 11:05am UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/8 "2022-02-07T11:05:16Z")

</div>

> [@rmsmsgood](#):
>
> Sure, there are people wouldn’t prefer words.

This things are more or less issues of taste.  
For programming language I prefer stringency instead of options. What I mean is, in most general terms, I would prefer a single possible way to do something instead of multiple (but equal) ways.  
This is again a matter of taste.

For me multiple options aren’t helping me to finish the task. It’s easier for me to remember a single way of doing it.

For Julia in particular I am currently a bit skeptical, but it’s not yet good justified so I didn’t open a discussion on it, because there are often so many options to do something (more complex than AND or OR, but not as complex as whole algorithms) but some of these options are less performant than others, which is not easy to see from the code. Yet the code is so trivial that it seems to be extrem to do performance measurements on these options. See for example this discussion: [Finding DataFrame rows with `missing` values in specific columns?](https://discourse.julialang.org/t/finding-dataframe-rows-with-missing-values-in-specific-columns/75811)

If this is going into a separate off topic discussion moderators can split here.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 7, 2022, 12:34pm UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/9 "2022-02-07T12:34:06Z")

</div>

> [@rmsmsgood](#):
>
> But thank you! I have a question, do they short-circuit evaluate?

[Yes.](https://docs.julialang.org/en/v1/manual/control-flow/#Short-Circuit-Evaluation)

---

<div class="post-metadata">

**Author:** ![KZiemian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kziemian/32/9020_2.png) [@KZiemian](https://discourse.julialang.org/u/KZiemian)\
**Post date:** [February 7, 2022, 12:36pm UTC](https://discourse.julialang.org/t/not-and-or-as-logical-operator-keyword/75933/10 "2022-02-07T12:36:15Z")

</div>

I like this idea.
