Background
I am aware of IJulia’s decision on magics. From their docs:
One difference from IPython is that the IJulia kernel does not use “magics”, which are special commands prefixed with
%
or%%
to execute code in a different language. Instead, other syntaxes to accomplish the same goals are more natural in Julia, work in environments outside of IJulia code cells, and are often more powerful
I do agree we do not need jupyter magics in julia. However, I do think they provide a nicer syntax, and as a result, they are easier to read. I am trying to develop a better calc process for many who do not know how to program and do not want to learn how either.
In my experience, as soon as these sorts of people see indented code, they tend to disengage.
Example - Python vs Julia
You can see the python version of the notebook on the left is “easier” or “less codey” compared to the julia version on the right. In fact, if you exclude the import cells, to someone who doesn’t know how to code, the cells don’t even really look like code.
That is unfortunately not the case for the julia version, and I fear that it could hinder adoption.
Proposal
My request would be to include a magics syntax for the %%
magic. This would be a cell based magic and would be more of a syntactic sugar. The %%name
magic (I am fine with another symbol but it would be nice for those python users who are comfortable with this syntax) would essentially be a @macro_name begin ... end
. See below:
Example 1
# imagine this as a jupyter cell with julia magic
%%handcalcs
a = 2
b = 5
c = 2
would be equivalent to:
# imagine this as a jupyter cell without julia magic
@handcalcs begin
a = 2
b = 5
c = 2
end
Example 2
# imagine this as a jupyter cell with julia magic
%%handcalcs cols=3
a = 2
b = 5
c = 2
would be equivalent to:
# imagine this as a jupyter cell without julia magic
@handcalcs begin
a = 2
b = 5
c = 2
end cols=3
This example may be a little harder to do since it is out of order compared to macro order. It may also be a sort of unique to me issue since not all macros are like this.
Conclusion
I just wanted to put this out there and see what people think. I know it could be more niche to certain use cases, but I can see it being somewhat nice for the @chain
macro as well so I thought I would put this out there.
I know this would bring more complexity too for jupyter to .jl conversions and may not be worth the extra complexity. I am mainly just trying to get more adoption in the company, and I would rather them choose julia over python.