Next: 1.13 Debugging Up: 1. Onyx Language Tutorial Previous: 1.11.2 General threading concerns Contents Index

# 1.12 Optimization

There are many fine points to optimizing Onyx code, but they can primarily be distilled down to the following simple rules:

- Avoid allocating composite objects, in order to reduce pressure on the garbage collector. This means being very careful about string manipulation in the fast path. The cat operator is convenient, but not friendly to the garbage collector.
- Write code with as few objects as possible, to reduce the number of times through the interpreter loop. This means getting very familiar with the stack manipulation operators.
- Use the operand stack rather than named variables.
- Use the bind operator for procedure definitions whenever possible, in order to reduce dstack lookups.
- Avoid the exit , stop , escape , and quit operators when possible, since they are implemented via longjmp().