Collecting a list of features Julia accidentally has

Julia is a powerful language, so powerful it has many accidental features.

First, let’s use Tullio we can create a superset of shader onto basic Julia array. Hook it up to some rendering system and we basically accidentally can compete with GLSL or such.
Next, let’s turn to Black box optim.This tool seems innocuous, but hook it up to an experiment API and we basically have an automated experiment system. It’s unfortunate the search range was limited to being numbers, so we could only tune experiment parameters, but still…
So, if you keep digging, you may find more unexpected features Julia has to offer.

We’re greedy! We want more! We want it all!

2 Likes

You are conflating the language with the package ecosystem. From the perspective of the language proper, of course packages are “accidental”, but they were written with a purpose in mind, and are not “features” of Julia — they are packages/libraries.

6 Likes

Here is a feature that JULIA accidentally have

Just realized that zero-based, i.e., offset-based indexing, can easily be done in Julia already:

v[1] == v[begin + 0]

So you can use zero-based array for one dimensional array by sticking in the "begin + " in the array indexs.

julia> myarray = [exp(1),pi,666.0]
3-element Vector{Float64}:
   2.718281828459045
   3.141592653589793
 666.0

julia> for k = 0:length(myarray)-1
         println(myarray[begin + k])
       end
2.718281828459045
3.141592653589793
666.0
6 Likes

There’s a couple blog posts about this:

3 Likes

If I may provide a small suggestion for this discussion going forward, what might be worth considering is not so much accidental features, but rather, unexpected compositions of Julia with Julian packages.

I’d argue that your examples, similar to what @Tamas_Papp is suggesting, are superb examples of unexpected compositions within the Julia ecosystem. And how I define a Julian composition is the “process of combining specific packages or implementations together in order to solve another domain’s specific problems”. And unexpected compositions being those compositions which were not intended by the author but are a happy “side effect” of a package being used.

1 Like

Don’t do this in general, another thread has gone farther to consider a macro for using zero-based indexing on 1-based arrays via begin+, and it identified notable exceptions e.g. :, firstindex, and any arbitrary methods, so it’s impossible to make a macro that covers them all. Offset-based indexing is only safe if you have literal integers to work with.

But zero-based indexing is good if you want to copy an algorithms in C and implement it in Julia.

Implementing an algorithmn written for C in Julia is fraud in danger if you do not use zero-based indexing.

If you want proper zero-based indexing, OffsetArrays can wrap Arrays for that. You won’t be able to directly use methods that assume 1-based indexing like matrix multiplication, you’d have to do some unwrapping then rewrapping. But that won’t be a problem if the algorithm is implemented from scratch and doesn’t need other methods.

If you really need to stick to 1-based Arrays, it’s far safer to do the work and write the equivalent and idiomatic 1-based indexing, generic indexing (eachindex), inclusive endpoints, and for-loops than to add begin+ everywhere in very strange let-while-loops. Like I mentioned, inappropriate begin+ would cause off-by-1 errors, you’re not any safer by forcing C practices in Julia.

For the least effort with the most safety, you could try to get away with ccalling it and wrapping it in an appropriate Julia method signature, if you don’t need to add any capabilities via reimplementation.

2 Likes