3 ms·
> writing a shell script in C and calling GCC on every invocation. You can't expect good performance from that Of course you can. Have you ever used the "-run
by enriquto 6y ago
> writing a shell script in C and calling GCC on every invocation. You can't expect good performance from that
Of course you can. Have you ever used the "-run" option of the TCC compiler? It's blazingly fast. With gcc it's a bit slower, but still orders of magnitude faster than julia. You can use pre-compiled libraries and the linking to your freshly compiled code is extremely fast. The fact is that compiling and linking C code is much faster that just launching the Julia environment with some packages. There's no fundamental reason for that enormous disparity in running time. I agree that it is a completely irrelevant nuisance for most people; but still, for some workflows not blessed by the Julia developers, it is the main point of friction.
EDIT: if you want to try it yourself, write the following text into a .c file, chmod +x it, and you can run it like a C script on most unix systems:
//usr/bin/gcc -O0 "$0" -lpng && exec ./a.out "$@"
#include <png.h>
int main(int c, char *v[])
{
// do stuff with png images
return 0;
}
- dTal 6y agoPoint taken, but I think you overreach a bit with: >There's no fundamental reason for that enormous disparity in running time I mean... Julia does full type inference, which it uses to present a dynamic type interface. It's not necessarily possible to statically compile a module ahead of time, because the module is designed to be generic and will generate different code if fed different types, which is how Julia attains its extraordinary composability. In other words, it's a much nicer language than C, and correspondingly much harder to compile. I'd call that a pretty fundamental reason. Perhaps C was a poor example for me to pick. C++, maybe? p.s. your "script" example clobbers any file named "a.out" in the current directory.
- enriquto 6y ago> In other words, it's a much nicer language than C, and correspondingly much harder to compile. Sounds like an anti-feature to me. What I want is "matlab with fast loops". I couldn't care less about "extraordinary composability", "full type inference" or "genericity". Well, I do care because these unneeded features make my stuff much slower. It's a hefty price to pay for uncalled-for features! Yes, my script was just a silly joke, to show that compiling and linking C code is really fast.
- dTal 6y agoDo you want a dynamic language with the speed of C? Then you want type inference.
- enriquto 6y agoThis is not necessary. There could be a single type, for example (e.g., the multidimensional array of floats).
- shakow 6y agoAnd how do you multiple dispatch on that? But if you just want a free MATLAB, use Octave.
- enriquto 6y agoyep, Octave is what I currently use when I can choose. I loved the concept of Julia as an "octave with fast loops". But it seems that there are some compromises with the Julia interpreter that go against my intersts. Maybe thee's still space for a modern language for numerical computation whose efficiency is not encumbered by the need to support strings, dictionaries, multiple dispatch and the like?
- shakow 6y ago> Maybe thee's still space for a modern language for numerical computation whose efficiency is not encumbered by the need to support strings, dictionaries, multiple dispatch and the like? I don't think so: I don't know of any scientific code that doesn't have to interact with its environment, if only to import/export data, and for that, strings at the very least are necessary. Multiple dispatch is the same thing for me; either it or another form of polymorphism will be very quickly asked for by the users of a scientific language, as no one wants to write dozens of time the same functions for different types, and the HPC community loves its programs to go fast, so they need/want to be able to chose their types.
- 6y ago
- StefanKarpinski 6y agoThis seems too obvious to even comment, but timing the compilation of a no-op program doesn’t show much. The meaningful comparison would be compiling a C program that does the same thing as some Julia code with `gcc -O2`. Btw, you can also run Julia in `-O0` or even better `-O1` mode — Julia even uses these same flags at the command line. These low optimization modes are extremely snappy — time to first plot is no issue. Of course, if you want to run some compute intensive code, it’s much slower, which is why `-O1` isn’t the default. This is not to dismiss the TTFP issue, just pointing out that your argument seems to be that gcc is faster than Julia, which is definitely not the case. Indeed, gcc is about the same speed as clang, which like Julia, uses LLVM. The way Julia uses LLVM is a bit different, but something would be very wrong if took Julia much longer to compile code with the same functionality as it takes gcc or clang. Julia spreads the compilation out over time, but when you do something complex, a lot of compilation happens all at once. However, a static compilation would not do this work any faster, static compilers just do the work in a separate phase rather than interleaved with execution.