# Hope Julia can use some shorter key words!

**URL:** <https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247>\
**Category:** Internals & Design\
**Tags:** proposal\
**Created:** [November 19, 2019, 1:34am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247 "2019-11-19T01:34:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![LarkyJulia](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LarkyJulia](https://discourse.julialang.org/u/LarkyJulia)\
**Post date:** [November 19, 2019, 1:34am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/1 "2019-11-19T01:34:27Z")

</div>

I guess most programmers don’t want to type many words while fewer can make things clear.

So I highly suggest Julia directing board to use some shorter key words, for example the function(), could we just use fn() or even func()?  
Could we not use the end key word for each block? The Fortran already abused me for a long time before, do I need to be abused again and forever with this new language?

I am not saying the syntax of the language should be too short to influence the clearity of the presentation, but those are really not necessary!!!

I hope Julia can do some changes, 1.2 version is not still too late to do these kinds of changes.

Hope my suggestion can be saw and seriously considered by the directing board!!

If you agree with my points, please say something here, lets’ make sure this suggestion can be seen by them! Thanks.

---

<div class="post-metadata">

**Author:** ![christopher-dG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher-dg/32/7387_2.png) [@christopher-dG](https://discourse.julialang.org/u/christopher-dG)\
**Post date:** [November 19, 2019, 1:49am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/2 "2019-11-19T01:49:25Z")

</div>

Here are my takes:

About `function`: You can use short-form function syntax `f(x) = 2x` if you want, and you can even do `f(x) = begin #= 10000 lines... =# end` or `const f = x -> 2x` (but please don’t do those things). Short keywords are cool but you’re talking about breaking literally all user code here.

About `end`: The alternative is whitespace-sensitivity? No thank you 🙃

---

<div class="post-metadata">

**Author:** ![LarkyJulia](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LarkyJulia](https://discourse.julialang.org/u/LarkyJulia)\
**Post date:** [November 19, 2019, 1:56am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/3 "2019-11-19T01:56:44Z")

</div>

well, white space sensitivity is not good, I agree, How about just use {}?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [November 19, 2019, 2:08am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/4 "2019-11-19T02:08:24Z")

</div>

why prefer to conflate the iconography of type information  
`f(x::Vector{Int}, y::Union{Maybe, Int})` and blocks?

Julia software an unusually effective medium for collaboration and transferring understanding of and the proper use of domain specific solution methods. To compress the tokens would vitiate an easy clarity.

---

<div class="post-metadata">

**Author:** ![Amin\_Yahyaabadi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amin_yahyaabadi/32/9826_2.png) [@Amin\_Yahyaabadi](https://discourse.julialang.org/u/Amin_Yahyaabadi)\
**Post date:** [November 19, 2019, 2:16am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/5 "2019-11-19T02:16:19Z")

</div>

I totally disagree with this. Julia is just using English keywords, which are very easy to understand even for kids.  
You can use TAB in your IDE (like Juno) or REPL to auto-complete the keywords.

You can create your own code snippet’s keywords in Juno. See this snippets that I added to my juno-toolbar-plus package for example:  
[https://github.com/aminya/juno-toolbar-plus/blob/538c9dc47085f15d34cdd12db5d6fc6384e1c4d2/snippets/julia\_snippets.cson#L61](https://github.com/aminya/juno-toolbar-plus/blob/538c9dc47085f15d34cdd12db5d6fc6384e1c4d2/snippets/julia_snippets.cson#L61)

I used `doce` to quickly write a lot of code. You can do the same for anything.

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [November 19, 2019, 2:19am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/6 "2019-11-19T02:19:05Z")

</div>

At the beginning of my undergrad I found Python’s indentation rules and no ‘end’ keyword as something very elegant. Now I just find it clearer to use the end keyword. I also vote against.

Additionally, 1.2 is definitely too late to bring this kind of changes. If it were done, It could only be for a 2.0 release as this is definitely a breaking change.

edit: typo

---

<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:** [November 19, 2019, 6:54am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/7 "2019-11-19T06:54:20Z")

</div>

> [@LarkyJulia](#):
>
> Hope my suggestion can be saw and seriously considered by the directing board!!

Note that the bar is really, really high for changes in surface syntax at this point: because this would break _all_ existing Julia code, the improvement would have to be huge. This is doubtful in this case, so a suggestion like this is most likely to be ignored.

---

<div class="post-metadata">

**Author:** ![LarkyJulia](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LarkyJulia](https://discourse.julialang.org/u/LarkyJulia)\
**Post date:** [November 19, 2019, 8:01am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/8 "2019-11-19T08:01:52Z")

</div>

Yeah, I agree!

---

<div class="post-metadata">

**Author:** ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)\
**Post date:** [November 19, 2019, 9:22am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/9 "2019-11-19T09:22:42Z")

</div>

Hi @LarkyJulia, I suggest spending a good bit of time working with the language before worrying too much about which parts need changing. I think that with experience you will find Julia has a lot of syntactic sugar which allows you to write very concise code. The short-form function syntax mentioned already is one such example but there are many others including uniform broadcasting syntax, multidimensional array comprehensions, custom string literals, fancy indexing, block-like closures (`do` syntax) etc etc.

---

<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:** [November 19, 2019, 10:23am UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/10 "2019-11-19T10:23:32Z")

</div>

Or, just have a look into this thread. It proves something of Julia which is quite adorable…

> [@Love in 245 Characters (code golf)](https://discourse.julialang.org/t/love-in-245-characters-code-golf/20771):
>
> I’ve found that in addition to everything else Julia excels at, it’s also a great language for [code golf](https://en.wikipedia.org/wiki/Code_golf), and came up with the below as practice. Thought I’d share it in case anyone finds it amusing, or share the same hobby. (It is of quite limited practical use.) 0:2e-3:2π .|\>d-\>(P= fill(5\<\<11,64 ,25);z=8cis( d)sin(.46d);P[64,:].=10;for r=0:98,c=0 :5^3 x,y=@.mod(2- $reim((.016c-r/49im-1-im)z), 4)-2;4-x^2\>√2(y+.5-√√x^2)^ 2&&(P[c÷2+1,r÷4+1]|=Int( ")\*,h08H¨"[4&4c+1+r& 3])-40)…

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [November 19, 2019, 12:13pm UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/11 "2019-11-19T12:13:59Z")

</div>

This has to be the most warm and welcoming programming community. I really look upward all of you who had the patience to answer the new commer’s suggestion this constructively. Thank you. You are good human beings.

---

<div class="post-metadata">

**Author:** ![LarkyJulia](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@LarkyJulia](https://discourse.julialang.org/u/LarkyJulia)\
**Post date:** [November 19, 2019, 12:22pm UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/12 "2019-11-19T12:22:08Z")

</div>

😀Yes, Thank you everyone!!!

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 19, 2019, 9:43pm UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/13 "2019-11-19T21:43:36Z")

</div>

Technically, one does not actually ever need to use the `function` or `end` keywords in julia. For instance, here’s random chunk of julia code I had laying around which uses a wide range of language constructs:

```julia

function f(p=0,q=1) # define the function
    if rand() < 0.5 # flip a coin. 
        if p < (q - 1) # if the coin gives heads, check if p < (q - 1)
            while gcd(p+=1, q) != 1 # increment p while the greatest common divisor or p+1 and q is not equal to 1
            end             
            return f(p, q) # recursively call f(p, q) (where p has been incremented)
        else
            return f(1, q+1) # if p is not greater than q - 1, we recursively call f(1, q+1)
        end
    else
        return p//q # If the coin flip gives tails, we return the Rational number p//q
    end
end

let
    data = [f() for _ in 1:10_000_000]
    for frac in [(0//1), (1//2), (1//3), (2//3), (1//4), (3//4), (1//5), (2//5), (3//5), (4//5), (1//6), (5//6)]
        freq = count(x -> x == frac, data)/length(data)
        println("P($(frac)) ≈ $freq")
    end  
end 

```

Now here is me rewriting it without using `function` or `end` and I’ll let you be the judge of whether this is preferable:

```julia
eval(Expr(:macro, Expr(:call, :while, :cond, :body), :(nothing; esc(Expr(:while, cond, body)))))
eval(Expr(:macro, Expr(:call, :while, :cond ), :(nothing; esc(Expr(:while, cond, nothing)))))
eval(Expr(:macro, Expr(:call, :for, :iter, :body), :(nothing; esc(Expr(:for, iter, body)))))

eval(Expr(:macro, Expr(:call, :let, :body), :(nothing; esc(Expr(:let, Expr(:block), body)))))

f(p=0,q=1) = 
    (rand() < 0.5 ? # flip a coin. 
     (p < (q - 1) ? # if the coin gives heads, check if p < (q - 1)
      (@while(gcd(p+=1, q) != 1); # increment p while the greatest common divisor or p+1 and q is not equal to 1          
       f(p, q)) # recursively call f(p, q) (where p has been incremented)
      : f(1, q+1)) # if p is not greater than q - 1, we recursively call f(1, q+1)
     : p//q) # If the coin flip gives tails, we return the Rational number p//q

@let((data = (_ -> f()).(1:10_000_000);
      @for(frac = [(0//1), (1//2), (1//3), (2//3), (1//4), (3//4), (1//5), (2//5), (3//5), (4//5), (1//6), (5//6)],
           (freq = count(x -> x == frac, data)/length(data);
            println("P($(frac)) ≈ $freq")))))

```

The `eval` expressions at the beginning were for creating the macros `@while`, `@for` and `@let` which allowed me to create `while`, `for` and `let` blocks without using the `end` keyword.

If you don’t like the keywords `while`, `for` and `let`, you could call them `@w`, `@f`, and `@l`.

It should go without saying that writing this sort of code is not a good idea if you want to share it with or get help from anyone who doesn’t share your sensibilities, but I just wanted to demonstrate that this is actually not too hard to do in julia.

---

<div class="post-metadata">

**Author:** ![lostella](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lostella/32/356_2.png) [@lostella](https://discourse.julialang.org/u/lostella)\
**Post date:** [November 19, 2019, 10:17pm UTC](https://discourse.julialang.org/t/hope-julia-can-use-some-shorter-key-words/31247/14 "2019-11-19T22:17:16Z")

</div>

I like the fact that `function` is the keyword for introducing a function, and that `end` is the keyword for ending a block. Straightforward, explicit, simple 🙂
