I’m planning of doing a Julia Lang tutorial series around syntactical sugar in Julia (feel free to steal the idea). Before that I want to ask you the community what your favorite syntactical sugar in Julia is
I really looking forward for all your answers. Thanks!
The broadcast operator really does it for me. It makes code so much more succinct and readable. Has probably saved me days of my life writing code at this point.
If you are considering packages, JuMP.jl has a nice mechanism of choosing the best container for your variables/constrains depending on the range you pass to it (if it is a 1:N range it is a Vector, if it is X:N it is a non-array dense container, if it has holes it is yet another container). Most users never perceive that.
I was just using JuMP yesterday, and I was a little upset finding tutorials with deprecated syntax everywhere. Then I started realizing what changed and why - all I can say is “thank you”. I’ll second the clever and hard work that’s been done to make JuMP more Julian and easy to use.
Also, it is simply the right answer to the question every numerically oriented language faced at some point so far, ie which operations should “vectorize”. The Julian answer is none of them, because f. will “vectorize” every possible function andfuse loops.
Other than that, I think that compared to some languages, Julia has been quite parsimonious with syntactic sugar, and it (again) is the right decision (at this point, astute readers can tell that I happen to like the language). You need a bit of sugar for the important things, otherwise you just want composable zero-cost abstractions.
I think the getproperty / getfield methods for dot notation as well as getindex / setindex! for bracket notation are pretty cool and allow a lot of extensions
It would unpack based on the names rather than based on order, so it’d be equivalent to tmp=bar(); x=tmp.x; y=tmp.y. (currently you can use UnPack.jl’s @unpack x,y = bar() to do this, but I just think this functionality fits into base Julia really well).