5 ms·
Punchline: rewrote the code to look almost identical to C++, hand-held the compiler by adding @-marks to disable safety checks, forced SIMD codegen and fastmath
by StilesCrisis 6mo ago
Punchline: rewrote the code to look almost identical to C++, hand-held the compiler by adding @-marks to disable safety checks, forced SIMD codegen and fastmath on.
End result: code that is uglier and still much slower than C++. Kind of a shame.
- brabel 6mo ago> code that is uglier and still much slower than C++. Oh such a shame indeed! They didn’t even manage to produce better looking code at least?? Julia was looking great in 2019 but it was very buggy still so I stopped looking. Had hopes that by now it would be a good choice over C++ and Rust with similar performance.
- cmrdporcupine 6mo agoThere's simply no way it'd ever have similar performance to those. It's not possible. I have always seen it as a potential alternative to Java, and definitely better than Python. My experience working in it professionally was that it was... fine. But the GC in it was not good under load and not competitive with Java's.
- 2ndorderthought 6mo agoHow hard was it to maintain a large Julia code base rather then say an OOP or Rust one? It has an interesting paradigm. I feel like it could get really messy
- andyferris 6mo agoPersonally I never struggled. You can employ interfaces and maintain them judiciously. But interfaces are informal. Not using a monorepo say makes it harder to be sure if your broke downstream or not (via downstream’s unit tests). But freedom from Rust’s orphan rule etc means you can decompose large code into fragments easily, while getting almost Zig-style specialisation yet the ease of use of python (for consumers). I would say this takes a fair bit of skill to wield safely/in a maintainable fashion though, and many packages (including my own) are not extremely mature.
- cmrdporcupine 6mo agoI personally think it requires discipline, I saw it go both ways. I was never an expert in the language, but worked along people who were and they generally made nice code. But there were a few places where I saw intensely confusing patterns from overloading with multimethods. Code that became hard to follow, and had poor encapsulation.
- csvance 6mo agoFrom the sound of your post I'm guessing you view Julia as a general purpose language. I'd consider it general purpose insofar as the application leans into fast numerical computing, everyone else secondary. It can do most of the things other languages do reasonably well, but that's not why you would pick Julia for a project over say Java. You pick it because you want to write fast numerical code and express it elegantly. All of the other typical "glue" things you need to ship a product are secondary to that, but good enough to get the job done. The key to performance with the GC in Julia is not allocating, but it has gotten substantially better since 2019.
- 2ndorderthought 6mo agoI don't get the appeal. It's like a. OSS Matlab but all contributions are used directly so the language developers can make money for a parent company? Most OSS languages aren't run that way. Seems kind of scammy
- andyferris 6mo agoMeh, I’ve never been associated with the company and AFAICT they provide value through platforms for enterprises. Not everyone gets OSS sponsorships to fund team (and using a social media presence to achieve this was a post-Julia phenomenon). It’s nothing like Google-the-ad-company influencing Chrome. The company consumes Julia for products to sell, rather. Maybe this affects the ordering of features landing, but… meh.
- postflopclarity 6mo agothe parent company is a consumer of Julia, and has no formal role in oversight or governance; they are of course invested in the success and performance of the language, but so are all other users!
- 2ndorderthought 6mo agoSeems kind of contradictory with the other comment which states that they decide what features are prioritized. I guess not because it could be an informal process. It's interesting. I like the more opaque approach rust takes. Rust has its own issues but it seems less corporately motivated. Maybe that's why it has more corporations using it? You aren't going to end up with the core maintainers to the language rug pulling packages or language features to slow down competition who are also using the tool. I say competition because it looks like they are making money through consultancies and very broad applications of the niche language. Weird stuff to have to think about. I just want to write code
- kelipso 6mo ago> I like the more opaque approach rust takes. Rust has its own issues but it seems less corporately motivated. Maybe that's why it has more corporations using it? I don’t if these are contradictory exactly but it seems to come from a very cluttered space.
- SatvikBeri 6mo agoThis is 7 years old. Julia is a totally different language by now. As a quick anecdote, in our take-home interview exercise, we usually receive answers in C++ or Julia, and the two fastest answers have been in Julia.
- d_tr 6mo ago> This is 7 years old. Yeah, I actually totally forgot to check the date...
- HarHarVeryFunny 6mo agoI'd have to guess that this is because of ease of use. C++ lets you get as close to the metal as you choose to, so there is no reason why a C++ solution shouldn't be at least as fast as one written in any other language, and yet ... Of course it also depends on what additional libaries you are using, especially when it comes to parallel/GPU programming in C++, but easy to believe that Julia out of the box makes it easy to write high performance parallel software.
- tialaramex 6mo ago> C++ lets you get as close to the metal as you choose to This only ends up being true (for any language, but it's too often cited for C++) in a pretty useless Turing Tarpit sort of sense. So it's not "no reason" it's just sometimes impractical to solve some problems as well in C++ as in a language that was better suited. Now people do do impractical things sometimes. It's not very practical to swim across the English channel, but people do it. It's not very practical to climb Mt Everest, but loads of people do that for some reason. Going to the moon wasn't practical but the Americans decided to do it anyway. But the reason even the Americans stopped going for a long time is that actually "that was too hard and I don't want to" is in fact a reason.
- sheepscreek 6mo agoDrawing from the analogies, what’s the Julia equivalent of them?
- neutrinobro 6mo agoHardly seems worth the effort, perhaps things have improved since 2019. It would be interesting to see an updated benchmark, but if your going to end up with code that looks like C++ to get proper performance, you might as well write it in C++. My biggest problem with Julia is that they decided to use column-major indexing for multi-dimensional arrays (i.e. FORTRAN/MATLAB style). This makes interoperability with C/C++ and python numpy a real pain, since you can't do zero-copy array sharing between the two without one side being forced into strided-access. For that reason alone I haven't adopted it in any of my work-flows.
- csvance 6mo agoJust reverse the axis on one side, typically the Julia side. This is the convention used in Lux.jl/Flux.jl. I share memory between the two with zero additional copying for my workflows on a daily basis. If you are really allergic to doing this, I’m sure it’s possible to use metaprogramming / the type system to write it the same way in both places with zero performance overhead.
- adrian_b 6mo agoActually the column-major order of Fortran is more efficient for some linear algebra operations than the order of C, which has been inherited by many modern languages that do not care about high performance in scientific computations. So I would say that the culprit for interoperability is C and its descendants, not Fortran or Julia. The designers of C and of the languages that have imitated C have not given any thought about which order for multi-dimensional arrays is better, so the users of such languages do not have any right to blame for interoperability other languages that have done the right thing. Even if the Fortran order had not been better, it had already been used for 20 years before C, so there was no reason to choose a different order. C has chosen to store arrays in the order in which they are typically read by humans when written on paper, but this is a choice like the choice between big-endian and little-endian, where big-endian was how Europeans wrote numbers, but little-endian is more efficient on computers. An example of why column-major order is preferable, is the matrix-vector product, i.e. the evaluation of a function that maps linear spaces. The matrix-vector product should not be done as it is typically taught in schools, by scalar products of rows of the matrix with the vector, because this is less efficient, by making more memory accesses. The right way to compute a matrix-vector product is by doing AXPY operations between columns of the matrix and the vector operand (segments of the output of the AXPY operations are held in registers until all partial AXPY operations are accumulated, avoiding memory accesses). In this case, you need to read columns of the input matrix for each AXPY operation, which is much more efficient when the elements of a column are stored compactly in memory, avoiding the need of strided accesses. The same thing happens for matrix-matrix products, which must not be done in the naive way taught in schools, by scalar products of rows of the first matrix with columns of the second matrix, but it must be done by tensor products of columns of the first matrix with rows of the second matrix.
- celrod 6mo agoI was once a bit of a Julia performance expert, but moved toward c++ for hobby projects even while still using Julia professionally. I wrote a blog post at the time with exactly that punchline (not explicitly stated, but just look at the code!): https://spmd.org/posts/multithreadedallocations/ https://spmd.org/posts/multithreadedallocations/ The example was similar to a real production-critical hot path from work. Maybe things changed since I left Julia, but that was December 2023, for years after this blog post.
- arbitrandomuser 6mo agohey , what happened to LoopModels ?
- celrod 6mo agoI'm still working on it. I'm currently working on a cache tile-size optimization algorithm that should (a) handle trees (a set of loops can be merged at some cache levels and split at others, e.g. in an MLP it may carry an output through the L3 cache, while doing sub-operations in the L2/L1/registers) (b) converge reasonably quickly so compile times are acceptable. This is the last step before I move to code generation and then generating a ton of test cases/debugging. My goal is some form of release by the end of the year.
- arbitrandomuser 6mo agooh , is it closed source now ? i couldnt find it on github anymore , github.com/LoopModels returns a 404.
- celrod 6mo agoYeah, for now. I'd like it to be open, but I also want to potentially be able to make money/a living off of it. My dream would be that it can be open while hardware vendors pay me to optimize for their hardware. For how, being closed gives me more options. It's a lot easier to open in the future than to close, so it's just keeping options open. I've thought a lot more about the engineering than any sort of marketing or businesses plan, so I just want to defer those.
- drnick1 6mo agoCame here to say that. It's just easier to write C++ in the first place, and LLMs now make this easier than ever.