Avg, mean, and average

One of the annoying things about learning a new programming language / library is to remember all the small nuances that come with it. For example, why should it be that in some places you have to use avg() to calculate the average of a list of data points whereas other demand you use mean() and then some average()? Why should we have to do cast in some languages while to in other and as_type in others? Why should we groupBy in one data processing library while Group By in other and group_by in others?

Before you say, but they are different languages, there are supposed to be differences!? Breathe a deep chestful of air and consider what would happen if every other language / library started using different operators as well. Would you tolerate if 2+2 in Rust became 2-2 in python? And this is not just a hyperbole because we do know that different operators are indeed used by different languages for less popular operations (** vs ^ for exponentials). There has to be certain things that are agreed upon by everyone to maintain sanity in a world that already has a flood of options, and I believe function names should be one of them. The differences in languages should come from their paradigm and way of doing things, not names, alphabets, or operators. I’d be willing to go even further and say that indexing should be the same everywhere as well. It’s annoying to keep switching between 0-based vs 1-based indexing and inclusive vs exclusive ranges. At the very least, I believe we should have some global switches that would allow us to choose this behavior.

Of course, if all you do is work with the same language/library for tens of years, then you wouldn’t be able to see where I’m coming from, but for those of us who have to keep switching between this or that language and libraries for reasons that’s beyond us, this is a pain point. A good IDE with its autocompletion would obviously help a bit (for statically typed languages anyways) but somewhere down the line, we should seriously consider creating a standard. Meanwhile, someone with an interest and some free time on their hands may want to explore to see if LLMs could fit in here somehow.

Leave a comment

Your email address will not be published. Required fields are marked *