What do you think makes code "Julian" in style?

There has definitely been past mention of code being “Julian” or not in analogy to Python’s “Pythonic”, but I’ve recently realized that I don’t actually know what “Julian” means to other people.

So I’ve come to ask people here: What makes code “Julian” to you?

For me, I’ve recently been considering trends I’ve observed in what Julia packages pick up steam, and I’ve come to my own conclusion that interfaces are Julian when they leverage multiple dispatch in such a way that their compatibility with arbitrary unknown packages is maximized. In contrast to Pythonic code emphasizing a single “most Pythonic” way to perform a specific intended action, Julian code emphasizes the possible coexistence of an arbitrary quantity of ways to yield a valid result.

That is, I see “Julian”-ness as a property of a function’s interface instead of as a property of coding style.

Off of the top of my head, Tables.jl is a good example of a library that I would consider to be “Julian”.

5 Likes

I think that one of the most critical aspects of Julian code is that it accepts the broadest types with which it will function. Also, type stability (where possible) is really important for code to feel Julian.

4 Likes

Method dispatch instead of if else blocks are the most iconic julian thing. Julian code normally has this kind of block of methods everywhere:

mymethod(arg::Sometype) = ...
mymethod(arg::Anothertype) = ...

So you can add methods for other types pretty much anywhere.

6 Likes

hahaahh yes, is there an stablished name for that pattern?

I think Pythonic means use vector style code like

reduce(map(operation, something))

instead of

for item in items:
  do_something_with(item)

Also, Mathematica style was thinks to be function chain like

Plot[Limit[Integrate[Solve[D[equation, x] == 0], {y, 0 ,10}], z->0], {a,0,5}]

These difference is depends on their language design. In julia, there are some special design which are

  1. Use begin instead of 1
iter_size = size(array)[begin]
  1. Use multi-dispatch instead of type check
  2. Escape underline(_) in separation
somemethod(arg::Type1) = ...
somemethod(arg::Type2) = ...

instead of

some_method(arg) = begin
  if typeof(arg) == Type1
    do_something(arg)
  ...
end
  1. [IMPORTANT] Vector operation will NOT get better performance in julia. Dare to use loop.
    Sorry I can not make up a good sample.
  2. Dot broadcast
@. result = array |> op1 |> op2 |> op3 |> opchain |> (balabala \circ bababa)
  1. number multiply
length = 1000mm

instead of

length = 1000 * mm
1 Like