# Keeping the syntax and the need to memorise syntax simple

**URL:** https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623
**Category:** Internals & Design
**Created:** [August 9, 2020, 3:58pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623 "2020-08-09T15:58:33Z")
**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: [August 10, 2020, 2:06pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/21 "2020-08-10T14:06:43Z")

</div>

I think most IDEs, and even simpler editors, take care of some of these already. To take your examples: In VS Code, Atom, Sublime etc. `<cmd+/>` toggles line comment, for any language supported by the editor. You should also have a `for` snippet that expands on tab by just typing `for`. And many more.

Check out snippets in your favourite editor. Some are already there, and you can add others. I particularly like snippets in LaTeX, which is so full of boilerplate.

BTW: What’s up with the flagging of some posts in here? It doesn’t seem like anything is in violation of guidelines, right?

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [August 10, 2020, 2:26pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/22 "2020-08-10T14:26:46Z")

</div>

> [@DNF](#):
>
> BTW: What’s up with the flagging of some posts in here? It doesn’t seem like anything is in violation of guidelines, right?

Yeah, the posts are just fine — the flags were erroneously applied by an overzealous spam-catcher bot and immediately dismissed.

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [August 10, 2020, 2:37pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/23 "2020-08-10T14:37:33Z")

</div>

> [@Nav](#):
>
> Each time I use a new language, I don’t want to have to figure out what characters are used for commenting out lines, what the syntax for a for loop is etc. It’d have been nice if there would be some universal template which could be decided for conventional programming paradigms at least.

Different languages target different use cases so it makes sense that their syntax is not the same. Also, with fixed templates, innovation is harder and one can not improve upon mistakes made in the past, catch up to changing times etc.

I think in most places, Julia does use syntax that is also used by at least a few other languages, but maybe not each individuals favourite language.

---

<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: [August 10, 2020, 3:06pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/24 "2020-08-10T15:06:21Z")

</div>

We keep excruciatingly detailed institutional history, in the form of the git commit log and issues: [https://github.com/JuliaLang/julia](https://github.com/JuliaLang/julia). There’s a lot of it, but that’s how much thought and effort has gone into the language you get. Explaining all the design decisions that have gone into Julia would take more time and energy than anyone has to spend. The manual does some of this explaining already.

---

<div class="post-metadata">

### Author: ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)
#### Post date: [August 10, 2020, 3:19pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/25 "2020-08-10T15:19:38Z")

</div>

I personally find the assignment operator `<-` in R to be far more offensive than any Julia syntax. Period.

---

<div class="post-metadata">

### Author: ![Nav](https://avatars.discourse-cdn.com/v4/letter/n/6a8cbe/32.png) [@Nav](https://discourse.julialang.org/u/Nav)
#### Post date: [August 10, 2020, 3:50pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/26 "2020-08-10T15:50:07Z")

</div>

@mthelm85: That operator is EXACTLY why I stopped using R. Python’s syntax was a relief, but Python is too slow. Matlab is expensive. So Julia was something I was really looking forward to…until I saw some of the syntax 🙂 I had been considering posting this topic for many months, and finally did so. Glad to see that many of y’all share the same opinion.

---

<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: [August 10, 2020, 4:04pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/27 "2020-08-10T16:04:12Z")

</div>

Maybe I’m misunderstanding your conclusion there, but Julia has nicest syntax of any language I’ve seen, with only a few minor blemishes (I never liked `where {T}`). For example, I prefer the current syntax to the ones proposed in the OP.

---

<div class="post-metadata">

### Author: ![jagot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jagot/32/12217_2.png) [@jagot](https://discourse.julialang.org/u/jagot)
#### Post date: [August 10, 2020, 7:17pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/28 "2020-08-10T19:17:03Z")

</div>

Julia definitely has the nicest syntax I have ever seen; it uses my favourite keyword `end` to terminate blocks, so you don’t have to use curly braces, and yet don’t have to rely on the abomination that is syntactic indentation. This is in common with Ruby, another language I really like.

It uses `->` to define function, which is _awesome_, because that is how you write functions in math (and with a font such as [Fira Code](https://github.com/tonsky/FiraCode) or the smoking hot [JuliaMono](https://juliamono.netlify.app/) `->` and other digrams are turned into ligatures that makes your code look even more like math).

Parametric functions (which is called generics in Java and templates in C++) are fantastically transparent and nice in Julia; since e.g. C++ templates are Turing complete, there is no end to how [awesome/horrifying](https://www.reddit.com/r/programming/comments/bj10p/c_template_metaprogramming_mindblown/) your code can get (and I actually like(d) C++). Compiler errors due to C++ templates are magnificent (in a horrible way). Julia compiler errors due to parametric types are verbose (less so in 1.5), but always logical.

(EDIT: I should note that _of course_, no programming language has better syntax than LISP, but that’s because LISP does not have a syntax 😛, since you program the abstract syntax tree directly.)

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [August 10, 2020, 9:46pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/29 "2020-08-10T21:46:32Z")

</div>

> [@mthelm85](#):
>
> I personally find the assignment operator `<-` in R to be far more offensive than any Julia syntax.

I actually like the `<-` assignment operator.

Consider the following Julia code:

```julia
julia> x, y = 1, 2;

julia> z = x == y
false

```

Which of the following do you think is easier to understand?

```julia-auto
z = x == y

```

or

```julia-auto
z <- x == y

```

?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [August 10, 2020, 9:50pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/30 "2020-08-10T21:50:44Z")

</div>

At some point I suggested allowing the use of `←` for assignment; this is common in computer science texts.

I agree that it is clearer, in that it avoids overloading the meaning of the “=” sign.

A nice alternative would be `:=`.

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [August 10, 2020, 9:57pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/31 "2020-08-10T21:57:28Z")

</div>

> [@dpsanders](#):
>
> it avoids overloading the meaning of the “=” sign.

Yes, that is definitely a nice feature of the arrow assignment. It clarifies the difference between equality and variable assignment. If you try to read the statement `x = x + 1` as a mathematical statement, it makes no sense.

Another nice thing is that in R you can also use `->` for assignment. This can be handy in a pipe:

```r
c(4, 7, 3) %>% sort %>% rev -> x

```

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [August 10, 2020, 10:08pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/32 "2020-08-10T22:08:33Z")

</div>

That is almost nice – except for the horrible `%>%`

---

<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: [August 10, 2020, 10:23pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/33 "2020-08-10T22:23:40Z")

</div>

I _really_ dislike `<-` for assignment, it just looks like the wrong kind of operator, like it does something completely different.

`:=` would be fantastic, it’s just right. Anyway, too late now, I’m just glad it’s not `<-`.

---

<div class="post-metadata">

### Author: ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)
#### Post date: [August 10, 2020, 11:14pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/34 "2020-08-10T23:14:32Z")

</div>

Perhaps an unintended side effect is that mutability is not the first thing engineered into methods. Often it’s nice to have stuff be immutable. Just a reason why `pop!` is good syntax.

---

<div class="post-metadata">

### Author: ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)
#### Post date: [August 10, 2020, 11:26pm UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/35 "2020-08-10T23:26:40Z")

</div>

> [@mthelm85](#):
>
> I personally find the assignment operator `<-` in R to be far more offensive than any Julia syntax. Period.

fortunately you can just use `=` and it works fine in basically all cases

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [August 11, 2020, 12:54am UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/36 "2020-08-11T00:54:03Z")

</div>

> [@Zach\_Christensen](#):
>
> Perhaps an unintended side effect is that mutability is not the first thing engineered into methods.

Sorry, can you clarify, an unintended side effect of what?

---

<div class="post-metadata">

### Author: ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)
#### Post date: [August 11, 2020, 1:02am UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/37 "2020-08-11T01:02:16Z")

</div>

The first one. `=` is the assignment operator in almost every lang, while `<-` is very esoteric and makes me feel there might be some magic going on. Also, the readable way to write that is `z = (x == y)`. Not following good style can make any syntax hard to read.

---

<div class="post-metadata">

### Author: ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)
#### Post date: [August 11, 2020, 1:08am UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/38 "2020-08-11T01:08:50Z")

</div>

Now that we are on hacking Julia to type less, is there a way to call a function without `()` or `@` (i.e., no macro call either)? A zero-arg operator kind of thing. It’s nice for impure functions that don’t need input, and don’t need to be passed around as an object themselves.

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [August 11, 2020, 1:15am UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/39 "2020-08-11T01:15:40Z")

</div>

> [@NightMachinary](#):
>
> while `<-` is very esoteric

I’m not sure what’s so esoteric about a left arrow, but oh well, I guess I can’t convince people to like arrow assignment.

> [@NightMachinary](#):
>
> Not following good style can make any syntax hard to read.

The point is that if you use the arrow for assignment, then you don’t need the parentheses to clarify the syntax.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [August 11, 2020, 1:24am UTC](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623/40 "2020-08-11T01:24:20Z")

</div>

> [@NightMachinary](#):
>
> is there a way to call a function without `()` or `@` (i.e., no macro call either)

No, that’s impossible – how would Julia know to distinguish between “the function f” and “the result of calling the function f”? There has to be some indication in the syntax.

[Previous page](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623.md?page=1)

[Next page](https://discourse.julialang.org/t/keeping-the-syntax-and-the-need-to-memorise-syntax-simple/44623.md?page=3)
