First of all, it's important to know what kind of problem you have. Most of the time, things like memory constraints and execution time don't even matter, so you should focus on what you can type quickly and feel comfortable doing. Everything else is premature optimization and will kill your capacity and burn through your project's money.
If you, however, know that whatever you are writing might have a big impact, because it will iterate infinitely (or at least a lot of times), it's important to know your compiler/interpreter. Because if they don't do things like tail call optimization, you will run into a stack overflow easily. Many modern languages support this feature, but you should be careful and make sure anyway.