Erik Engheim
2 min readMar 11, 2021

--

Yes, we are beholden to whatever existing systems are built in. I sucked it up and worked with C++ for years even if I strongly dislike C++, because the project was interesting.

At times I can forget how much I dislike C++ until some oddball memory corruption happens or the compiler barfs template error messages at me.

Sounds like to me that you use object-orientation pretty much the same way I do in Julia.

The only aspect of object-oriented programming which is awkward to do in Julia is implementation inheritance. You can do it, but it is kludgy.

But this idea of attaching method to objects seems counter productive to me. I notice this when using Python in the REPL which is object-oriented. You need to add a method and then you have to bring up the whole class definition and add it.

With Julia you just add a function. No big clunky class definition to edit. I think what people really want from object-oriented programming is the ability to run specific code depending on the type of one or more of the arguments.

But Julia already gives you that. And I think for numerical code object-oriented programming doesn't really make any sense.

Imagine defining something as simple as max(A, B) as a method? It doesn't work. You would typically want max(A, B) to work on identical types. You don't want A or B to have a special significance. They are both equally important. Most math is l ike that. There are no single argument which has special prominence.

If I do intersect(circle, rectangle), then the cirlce should not descide what code gets run any more than the rectangle.

I know many people use classes as sort of namespaces. But you can use modules for that not care about namespaces. You can have lots of functions with the same name in Julia as long as they work on different inputs. There is no conflict.

I know back when I was a big fan of OOP I really liked command completion on objects, but that is a lot about habit. Today I really have having to have an object before I am allowed to do command completion. In my mind, I already know what I want to do, why do I need an object first to find the correct function? Just let me complete on the function name directly.

Anyways... sorry for the ramblings. It is an interesting topic. I am also a UX guy so I am intrigued by how people work and use their tool. I often wished I could easily sit in and observe more how they work, to better understand what their needs are.

I tried to document in a series of videos of I work in a REPL environment in Julia, although I guess I don't address your concerns about object-oriented programming: https://www.youtube.com/watch?v=CRiD12Y75wM

--

--

Erik Engheim
Erik Engheim

Written by Erik Engheim

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

No responses yet