The above may only be an issue of BigFloat, to be fair, since Float64 compiled in an instant (never measured, and the time never bothered me).
So Julia has solved a lot of problems for me, and I see great potential for it in the future.
$ time julia -e 'print(1)'
1
real 0m0.438s
user 0m0.300s
sys 0m0.118s
$ time python -c 'print(1)'
1
real 0m0.040s
user 0m0.036s
sys 0m0.003s
it is slower..That said, instanciating julia every step of a bash loop.. I think it requires a jvm mindset, warmup once and iterate inside rather than outside.
I do not have this mindset then. I prefer tools who are mindset oblivious. They are really useful!
For example, imagine I have a collection of a few hundred images with their projection matrices (in text files). I want to crop them and apply a simple imagemagick operation (which is not available from inside julia). The elementary solution is to run a shell loop to apply the crop, and call julia to perform a simple adaptation of each projection matrix. This is impossible today: most of the running time of such loop is spent on julia initialization. Half a second to do nothing is simply unacceptable in a serious scripting language.
Yet you picked a specialized tool "imagemagick" (made for working with images), and want to drive it by another specialized tool (the shell, made for file and process management).
Since you want "mindset oblivious" tools why not write everything from scratch, in C?
Because imagemagick, julia and other specialized programs already provide the advanced algorithms that I need. Unfortunately, julia is not a good team player.
What it excels at is rapidly solving the same problem many times within one REPL/interpreter (since after the first time the code will be compiled), or for longer computations where the overhead of the initial compilation does not matter.
It would be great if it could also get fast at the use case you are interested in, but this isn’t currently what it excels at.
Or, you know, Julia is not specialized for your use case.
The slow startup time may be a minor inconvenience, I agree. But nonetheless it seems to be a case of sloppy engineering, as other scripting languages do not have this egregious problem. It sets a bad tone, and makes me wonder if there are other hidden monsters inside the interpreter, that may be solved by "you are holding it wrong" like this one.
Out of curiosity I timed ocaml
$ time echo 'let x = "1" in print_endline(x)' | ocaml -stdin -
1
real 0m0.045s
user 0m0.039s
sys 0m0.007s
I thought julia init time was due to type checking phase but ocaml seems to have no issue, even with non zero code: $ time echo 'let l = [1;2;3;4] in let m = List.map (fun x -> x*x) l in print_int(List.length(m))' | ocaml -stdin -
4
real 0m0.050s
user 0m0.040s
sys 0m0.011s
Sad, I liked a lot of Julia features..ps: this hints at the init time being constant recompilation of its core https://www.reddit.com/r/Julia/comments/4c09m1/julia_045_sta... and they were thinking (2 years ago) of caching..
[1]It's just because i find the science python stack a bit absurd.
Julia is not a scripting language, it's a language for mathematical analysis.
Also going back to your example the solution would be to use ImageMagick.jl from Julia, and extend the library (4 extra lines with ccall) if it's not available, and send a pull request to help the community.
Ok, this clarifies the matter a lot. So julia is not intended to be a general-purpose programming language. Are you involved in julia development?
(Besides, I strongly dislike the design tradeoff of not being a good unix citizen.)
https://docs.julialang.org/en/latest/manual/running-external...
The only trade-off here is the restricted resources the Julia devs can afford. Focusing on the scientific computation niche, the Julia compiler was built to compile code just ahead of time, since this way it can create code as fast as compiled languages while still being dynamic like any interpreted language (such as Matlab and Python). But there is nothing in the language that prevents it from being fully interpreted (and therefore having minimal compile time overhead, but generating poorly optimized code for long running processes), or alternatively pre-compiling and caching to have both (which is being worked on: https://github.com/JuliaLang/PackageCompiler.jl )
Also the language itself supports extending code (multiple dispatch really helps it to stay clean).
REPL:
julia> @time print(1)
1 0.000031 seconds (7 allocations: 272 bytes)
Bash: $ time ./julia -e 'print(1)'
1
real 0m0.184s
user 0m0.156s
sys 0m0.168s
So yes, that’s a slow launch time. If you use Julia in a shell script and it’s starting up Julia on each calculation it will be brutally slow. Five orders of magnitude slower, in this case.It's a bit annoying it's true, a well featured language with dynamic/repl appeal that is not in the ms launch time. But alas..
16 seconds. Sixteen seconds. For real. This is not usable.
That certainly depends on your use case. For instance, the launch time is ridiculously slow, so that you cannot realistically run a small matrix computation in julia from within a shell loop. It is better to use octave for that, where the startup time is almost negligible (just a bit slower than starting a subshell).