# Whitespace sensitivity

**URL:** <https://discourse.julialang.org/t/whitespace-sensitivity/76211>\
**Category:** Internals & Design\
**Created:** [February 11, 2022, 9:05am UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211 "2022-02-11T09:05:29Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 11, 2022, 9:40pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/21 "2022-02-11T21:40:24Z")

</div>

> [@Seif\_Shebl](#):
>
> but being able to write `f ( x )` in any language (at least those I know of)

I have _never_ seen this done. Maybe I could go check each of the languages I know, but as far as I’m concerned this could just as well be disallowed in all of them.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [February 11, 2022, 9:42pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/22 "2022-02-11T21:42:44Z")

</div>

> [@jling](#):
>
> If you’re writing Lisp, sure. I mean in that case, (f (2, 3))means f((2, 3)) right? Postfix, I would add space in Lisp too because otherwise I would think I’m calling the function with two arguments

What has Lisp got to do with this? Those coding standards are for C. There are a few good points in there but far from everything. I have co-maintained a GNU project and we happily ignored the recommendation about space between function name and open-parenthesis. In fact nobody ever suggested even to consider it.

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [February 11, 2022, 9:46pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/23 "2022-02-11T21:46:31Z")

</div>

Then, one has to unlearn all languages they learned before Julia including English 🙂.

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [February 11, 2022, 10:03pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/24 "2022-02-11T22:03:59Z")

</div>

Styles and guidelines can be useless at times if they are built off of a personal taste. But the problem is when the language puts restrictions that didn’t exist in the first place just to remedy the side-effects of a newly-added feature. I’d fix the source created that side-effect rather than change a well-established concept. The freedom to wisely use white space for clarity is highly appreciated, especially when code becomes close to human languages.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 11, 2022, 10:07pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/25 "2022-02-11T22:07:47Z")

</div>

Okay, good to know then, because I don’t think anybody does this weird space thing. I was just saying the only reason I’d think of is if that’s for Lisp, i.e. postfix

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 11, 2022, 10:08pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/26 "2022-02-11T22:08:42Z")

</div>

Matlab, Python, C, Fortran, Java, Swedish, English and German - these are the languages I’m on first name basis with, and I’ve never seen or written `f ( x )` in any of them. It would probably confuse me if I saw it, and disallowing it is at worst harmless and more likely a good thing for legibility.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [February 11, 2022, 10:18pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/27 "2022-02-11T22:18:41Z")

</div>

> [@Seif\_Shebl](#):
>
> But the problem is when the language puts restrictions that didn’t exist in the first place just to remedy the side-effects of a newly-added feature.

In principle I agree with you but this particular restriction I really don’t have a problem with.

---

<div class="post-metadata">

**Author:** ![BioTurboNick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bioturbonick/32/6380_2.png) [@BioTurboNick](https://discourse.julialang.org/u/BioTurboNick)\
**Post date:** [February 12, 2022, 12:06am UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/28 "2022-02-12T00:06:51Z")

</div>

I’ve seen something like this once: In C# scripts used by the Unity game engine. I don’t know why.

> **[Learning C sharp in Unity for beginners](https://unity.com/how-to/learning-c-sharp-unity-beginners)**
>
> Want to learn how to code for your first game in Unity? Start here by learning Unity's basic scripting elements like variables, functions, & classes.

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [February 12, 2022, 2:18am UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/29 "2022-02-12T02:18:27Z")

</div>

Having the right to use whitespace at your own disposal is one thing and actually using it is another thing. Nothing stops you from using whitespace in these languages if it helps improve readability, and I encountered many examples in C ([see Linux Kernel](https://github.com/torvalds/libdc-for-dirk/blob/Subsurface-branch/examples/common.c)) and Fortran doing this. Writing f(x) in English is wrong, by the way. Check also languages like Haskell, OCaml, F#, Lisp, Closure, Forth, Elm, Standard ML, Ada, V, …etc., they do this all the time. And languages that use `{..}` always add space around and inside the braces; check Rust, C/C++, LaTeX, …etc. I mean, restricting something requires a strong reason because it feels bad to be punished just for adding a space after the function name. Of course `f ( x )` seems ugly because the function name and arguments are short, but it feels a bit weird to disallow it.

---

<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 12, 2022, 4:26am UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/30 "2022-02-12T04:26:52Z")

</div>

People often have very strong opinions about surface syntax like this, but in the end it just comes down to personal preference, there is really no objectively superior choice. In past experience, this tends to lead to long circular discussions with little productive outcome. [Julia’s syntax is finalized](https://discourse.julialang.org/t/psa-julia-is-not-at-that-stage-of-development-anymore/) at this point – Except for new non-breaking features and minor consistency improvements the syntax just won’t change. I know it’s a bit of a cliché, but I think at this point, we will just have to agree to disagree. 😉

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [February 12, 2022, 5:31am UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/31 "2022-02-12T05:31:07Z")

</div>

`f(x)` is not wrong in English because of the whitespace. It’s wrong in English because natural languages don’t have function calls.

LaTeX is another example where I have a lot of familiarity and you’re just wrong there. People do not leave a space between the macro name and the argument brackets “all the time”. If you write `\macro {something}` in LaTeX anyone who reads your code will assume that `macro` is a zero argument macro. It’s valid code, but it’s rare and bad.

---

<div class="post-metadata">

**Author:** ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)\
**Post date:** [February 12, 2022, 6:42am UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/32 "2022-02-12T06:42:11Z")

</div>

> [@simeonschaub](#):
>
> in the end it just comes down to personal preference

I find it’s just habit. After using one language continuously for a while, I tend to acquire the quirks of that language and when I switch to another language I tend to dislike the new quirks, but after a few months I adapt and change… conventions about underscores, capital letters, space inside arguments vs space inside expressions, omitting or reinserting curly brackets, etc. I have hated and liked them in equal measure. I guess I don’t have the personality to have a personal preference!

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 12, 2022, 8:09am UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/33 "2022-02-12T08:09:20Z")

</div>

Doesn’t prohibiting such white spaces in functional notation bring Julia closer to Prof. Edelman’s motto: “_with Julia, you don’t code the math, code is the math_”?

See his [TEDx talk](https://youtu.be/qGW0GT1rCvs?t=490).

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [February 12, 2022, 5:03pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/34 "2022-02-12T17:03:03Z")

</div>

I’m not complaining about syntax, and I know that Julia’s syntax is finalized. I’m talking about a restriction that can be another source of error in the code if one innocently added one space after the function name. I don’t like that space either, but disallowing it was a bit extreme and sounds to me like a step back in programming language design (Fortran adopted free form after Fortran 77). Syntax in not a problem because one adapts to it after some time as @ptoche said, but this is about a strange behavior not found in other languages and can introduce errors.

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [February 12, 2022, 5:07pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/35 "2022-02-12T17:07:22Z")

</div>

> [@gustaphe](#):
>
> People do not leave a space between the macro name and the argument brackets

That’s true, but look at the new LaTeX3 Layer and you’ll see a lot of spaces around and inside `{ }`s for clarity of arguments.

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [February 12, 2022, 5:37pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/36 "2022-02-12T17:37:14Z")

</div>

Yes, of course, if what you write is math, then `f(x)` should exactly be written like that. But Julia is also a general purpose programming language and one can encouter pretty long function names like below. Introducing one space sometimes doesn’t hurt.

[https://github.com/SciML/ModelingToolkit.jl/blob/ae0da21f6dec3da96b7b490d2bcc65ab519f2e40/src/utils.jl#L446](https://github.com/SciML/ModelingToolkit.jl/blob/ae0da21f6dec3da96b7b490d2bcc65ab519f2e40/src/utils.jl#L446)

`function get_substitutions_and_solved_states(sys; no_postprocess=false)`

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 12, 2022, 5:44pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/37 "2022-02-12T17:44:16Z")

</div>

```julia
sin (π/6)^2 === horrendous
true

```

---

<div class="post-metadata">

**Author:** ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)\
**Post date:** [February 12, 2022, 5:45pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/38 "2022-02-12T17:45:35Z")

</div>

Yes, horrendous, because it is far from math. This is exactly what I said above.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 12, 2022, 5:54pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/39 "2022-02-12T17:54:16Z")

</div>

![image](https://global.discourse-cdn.com/julialang/original/3X/d/4/d48ac0d7ccd5c6794ecfeadb48148d522ab4ce10.png)  
they still call functions without space no?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 12, 2022, 5:58pm UTC](https://discourse.julialang.org/t/whitespace-sensitivity/76211/40 "2022-02-12T17:58:39Z")

</div>

> [@Seif\_Shebl](#):
>
> Julia is also a general purpose programming language and one can encouter pretty long function names like below.

what does this even mean? everything is still function, math functions have short name because people can’t write verbosely on blackboard so they overload symbols all the time, do you prefer Unicode programming maybe? In any language you can have verbose (english, you may say) function names:

> <https://github.com/torvalds/linux/blob/871bfa02d08d9c0ed981c50082b7afd367d3700b/sound/soc/intel/skylake/skl-topology.c#L157-L160>

still, people don’t do it. It’s fine you have personal preference, just know it’s rarely adopted and Julia is NOT going to change its syntax, not sure if there’s anything to this discussion anymore

[Previous page](https://discourse.julialang.org/t/whitespace-sensitivity/76211.md?page=1)

[Next page](https://discourse.julialang.org/t/whitespace-sensitivity/76211.md?page=3)
