Can you tell how many extra memory allocations we are making to solve this problem? And how many are really needed? We could solve this with a for loop by directly comparing the characters and skipping non-alphabetical ones. This would be simpler to read and more efficient.
We should be careful with what we call "best practices for beginners", as they can sometimes lead to unnecessary complexity and inefficiency.
The highly overused "best practices" marketing term should really be called "most-likely good practice for most but not all situations highly dependent on context".
I think the problem is people want to know "Hey what's the right way to do this?". Turns out IEEE does publish some actual standards[0][1] related to software, but being completely honest I've never actually read it. I'm assuming I'm not in the minority.
This is the problem with an experienced dev writing a "Best practices for beginners" article. The beginner will read it as literally the best practice and commit it to memory as dogma, not considering suitable applicability and variations.
I would say that beginners shouldn't be writing core algorithms as performance often matters. The post should be called beginner-friendly implementations of algorithms in Go, or something to that effect. The point being to learn about the algorithms rather than learning the right way to code algorithms.
> Can you tell how many extra memory allocations we are making to solve this problem?
What suggests that the "best practice" is sliced down the efficiency lane? The intent could be to "best" demonstrate how to structure a collection of algorithms and data structures into packages, for example.
Just an example. Why should complexity and over-engineering be considered best practices for a beginner? In the example I've given, it turns out that a for loop and an if conditional are the simplest and most efficient solutions.
Additionally, from a beginner's point of view, it's important to learn algorithms that are language-agnostic. In this case, Go handles the allocations, copies, and memory management for you. However, this code would be much harder to implement in C. In any language, the algorithm I've provided would still be the best solution.
As others have commented, the terms "best practices" and "beginner" are sometimes used as clickbait to attract interactions and GitHub stars.
> Why should complexity and over-engineering be considered best practices for a beginner?
I'm still not clear on where the idea that this is a "best practice" is coming from. Is there some context I am missing?
Aside from the editorialized title, all I can find is an assertion of "following best practices", which does not even imply that it is trying to establish best practices (of any sort, let alone around efficiency or complexity), merely that the author tried to follow
some best practices established elsewhere. It is understood that to follow opens the possibility of veering off course, so unless the beginner is also a beginner with spoken language, it would not be taken to mean that this demonstrates best practices.
https://github.com/TheAlgorithms/Go/blob/master/strings/pali...
Can you tell how many extra memory allocations we are making to solve this problem? And how many are really needed? We could solve this with a for loop by directly comparing the characters and skipping non-alphabetical ones. This would be simpler to read and more efficient.
We should be careful with what we call "best practices for beginners", as they can sometimes lead to unnecessary complexity and inefficiency.