Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

condition is an invariant. Unless using cranelift or gcc, it's going to get optimized away by LLVM unless rustc is giving it some non-invariant constraints to solve for. Most compilers, JITs, and interpreters can and do do invariant optimization.

Another way to look at the class of problem: if you're using too many conditionals too similarly in many places, you may have created a god type or god function with insufficient abstraction and too much shared state that should be separated.

---

Prime directive 0. Write working code.

Prime directive 1. Choose appropriate algorithms and data structures suitable for the task being mindful of the approximate big O CPU and memory impact.

Prime directive 2. Write maintainable, tested code. This includes being unsurprisingly straightforward.

Prime directive 3. Exceed nonfunctional requirements: Write code that is economically viable. If it's too slow, it's unusable. If it's somewhat too slow, it could be very expensive to run or will cost N people M time.

Prime directive 4. If it becomes too slow, profile and optimize based on comparing real benchmark data rather than guessing.

Prime directive 5. Violate any rule for pragmatic avoidance of absurdity.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: