What Python Creator Guido van Rossum Thinks of Rust, Go, Julia, and TypeScript

Regarding this point, I have struggled myself not with the lack of OO in Julia, but by a lack of a good overview and description of alternatives that allow one to gradually move from an OO style to more “native Julia” style, while still maintaining performance and relative code simplicity. Since an OO approach is not very relevant when working in Julia you’re left a bit in the dark when moving from another OO language, like C++ or Python, to Julia as for the former there’s an enormous amount of material available online on OO techniques. The book “Design Patterns and Best Practices with Julia” that @Tamas_Papp recommended to me in a different thread does give a nice overview of approaches and is definitely recommended, but 1) you have to know about its existence and contents and 2) subsequently purchase it (I did). It also doesn’t really go into real-world performance issues, but stays fairly theoretical with toy examples (which arguably from a didactic standpoint makes sense).

The discussions on this forum on alternatives to OO in Julia show, at least to me, that they usually involve a much deeper understanding of Julia and use of more complex features to get good performance. The thread below is a really nice example and interesting discussion of OP and a second user later in the thread try to port some fairly simple and straightforward C++ code to Julia and initially running into issues with respect to performance (getting rid of allocations). But gradually the thread turns to discussing possible code structures on how to practically mimic things like dynamic dispatch, especially when the number of classes grows:

Things suggested in the thread are union splitting, macros for field inheritance, eval to generate a set of functors, GC.@preserve and FunctionWrappers.jl. And this is just for porting a simple C++ hierarchy. While in contrast doing this kind of OO in C++ is easy by writing your class hierarchy and (virtual) methods per class and you get good performance and a straightforward code structure, without having to use any advanced features. And you only need to worry about performance of dynamic dispatch in a few pathological cases in C++, otherwise it just works fine. You can argue that OO as a modeling tool is not as good or flexible as multiple-dispatch, but I’m not convinced yet that in Julia an alternative is available with the same performance when coupled with similar code simplicity. It seems you just need to work a lot harder in Julia, while leading to more complex code.

3 Likes