Consider two programs, one written in Julia and one in, say, C++. The Julia program is well written: no type instabilities, not too many allocations, bounds checks disabled, etc. The two programs are structurally similar, i.e. same algorithms, same datastructures.
We know that for relatively simple, low-abstraction code - e.g. loopy numerical stuff - the Julia program will run at pretty much the same speed as C/++. This is not that surprising: there isn’t much subjectivity on how to translate simple code to LLVM IR, and once it’s in LLVM’s hands (with all the relevant type information / other metadata), it should produce pretty identical machine code.
My question is this: for a richer / wider domain, are there any cases where Julia’s design or implementation could fundamentally limit its performance, assuming a roughly equivalent level of programming abstraction in the two languages? (Though examples without this assumption are also interesting.) Are there are any abstractions that would be low or zero cost in C++ but would necessarily be higher cost in Julia due to the language’s semantics or structure? Are there any compiler optimizations that could never be applied to Julia code, even if we wanted to? (N.B. some of these design decisions may be deliberate - some abstractions are worth the cost!).
By “domain”, I mean any set of programming abstractions, and computations of any nature. Examples off the top of my head: data structures with lots of references / indirection, web servers, string manipulation, networking, multi-threading, graphics, lambdas, closures…
One obvious difference is that Julia is garbage collected - let’s ignore that.
For context: I know a decent amount about the design of the two languages, have written a decent amount of code in both languages, know a fair bit about compilers etc. After thinking about the question for a little while, no example immediately comes to mind, but I haven’t tried doing everything in both languages, and there are people who are much much more familiar with both languages’ designs and internals than I am.
Looking forward to hearing your thoughts!