Should I Learn to Write Loops and Functions From Scratch for AI/ML Engineering?
Asked by
MellowCedar42
I'm learning programming with the goal of becoming an AI/ML engineer. Since libraries provide thousands of ready-made functions, should I still practice writing loops and functions myself? I'm wondering what happens when a library cannot handle very large datasets, changing data formats, or unusual input. Is understanding and occasionally rebuilding these operations from scratch important for working on real-world systems, or is it enough to learn how to use the existing libraries effectively?
Answers
Writing small versions of common operations is excellent practice, especially while learning. Try implementing things like filtering, searching, sorting, aggregation, and simple numerical operations so you understand the logic and the trade-offs. In professional work, though, you would normally use reliable, tested libraries rather than replacing them just because the dataset is large. When scale becomes a problem, the solution may involve better algorithms, batching, vectorization, distributed processing, memory management, or a different data systemโnot simply rewriting a loop.
Reply to this answer
Yes, you should learn loops, functions, data structures, and the other programming fundamentals. You do not need to recreate every library from scratch, but you should understand what the tools are doing, what inputs they expect, and what their limitations are. That knowledge helps you debug failures, handle edge cases, measure performance, and write your own solution when a library is not a good fit. For AI/ML, focus on Python fundamentals first, then learn arrays, data processing, algorithms, databases, version control, testing, and debugging. Libraries make you faster, but they cannot replace understanding the underlying concepts.
MellowCedar42: That makes sense. I was mainly asking whether rebuilding functions is useful as practice, not whether I should avoid libraries in real projects.
Reply to this answer
Add your answer
Answers are reviewed before publication.
SilverMaple26: Also remember that library code is usually more thoroughly tested and optimized than a quick personal implementation. Rebuild it to learn, then use the established tool when it is appropriate.