# Loops, allocations and helping the coder

**URL:** <https://discourse.julialang.org/t/loops-allocations-and-helping-the-coder/104733>\
**Category:** Internals & Design\
**Created:** [October 8, 2023, 6:18pm UTC](https://discourse.julialang.org/t/loops-allocations-and-helping-the-coder/104733 "2023-10-08T18:18:05Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [October 9, 2023, 7:53pm UTC](https://discourse.julialang.org/t/loops-allocations-and-helping-the-coder/104733/17 "2023-10-09T19:53:15Z")

</div>

Just to give you another perspective. My background is engineering, not CS.

> [@Paul\_Soderlind](#):
>
> This can be handled by creating “workspaces” and then filling/overwriting the arrays inside the loop. Unfortunately, however, that often leads to code that looks clumsy and it’s certainly not straightforward for users with a non-CS background (scientists, say).

Not sure I agree. I think it is a matter of learning how to write performant code. The same lesson could apply in writing performant C (allocating an array once, passing the pointer around, then refilling as needed). In my experience, writing code this way is not particularly clumsy compared to any other style.

If you want to write performant code I think you should have to learn some of the basic best practices to writing good code, knowing a little bit about the software & hardware and why allocation is slow. [This](https://www.juliabloggers.com/what-scientists-must-know-about-hardware-to-write-fast-code/) post comes to mind.

---

_[View the full topic](https://discourse.julialang.org/t/loops-allocations-and-helping-the-coder/104733)._
