Hello! I’m a complete julia novice, but I’ve been hearing about it from years from friends and colleagues. I’ve approached it for a project that I want to start but need some advice on what direction to take.
I’m looking to start a relatively long-term project of converting a large codebase (at the moment written in Fortran) to a more modern language. Part of this is in order to make it more accessible to a wide community, and part is due to the nature of the application, which could greatly benefit from more modularity.
I’ve tried to work out an example. Imagine an application that goes through the life of an animal. The data would be what the animal is like (weight, size, number of limbs…) while the methods would be the actions it performs (eat, sleep, move…). The data will look different depending on the animal, as some will have not only various dimensions and number of legs, but also completely unique characteristics. Similarly, the “eat” function would look very different for a domesticated dog, which is given food at home, and a wild dog, that has to hunt down its prey.
This seemed well-suited to an object-oriented implementation, having a main class with the basic version of the data and process, and then different classes with the appropriate data and updated methods; what class to use can be decided depending on the choices made by the user when starting the program. For this reason I approached python, using numba to achieve similar efficiency to the fortran code. The problem I encountered is that support for classes doesn’t go all the way yet, or at least the functionality I was looking for required some counterintuitive hoops. This is why I’ve decided to finally try julia instead.
Now, I’ve quickly come to understand that julia doesn’t really support classes in the way that python does, and relies on multiple dispatch instead. In my understanding, this means that instead of having class Dog, class Cat, etc, each with their version of eat, sleep, etc, in julia I would define different data types Dog, Cat, etc, and then I would define a eat(Dog), sleep(Dog), etc, eat(Cat), sleep(Cat), etc…
I see how this could be done, but it doesn’t strike me as much different or better than having a single eat function with a bunch of if(Dog) …, if(Cat)…, or a switch(animal). In fact, considering that I would give up on using classes either way, I’m not so sure what the advantage would be over going back to python/numba, which is more familiar to me. My worry is mainly that switching to julia will not particularly improve readability or efficiency.
I have essentially two questions: first, do I have the right idea of what julia could do in this case or have I misunderstood something crucial? Second, are there other and better ways to approach this sort of situation?
Thank you!