Small, practical programming tips to write cleaner, faster, and more maintainable code.
Each tip focuses on micro-optimizations, readability improvements, or subtle language behaviors.
| Folder | Description |
|---|---|
general/ |
Tips that apply across all programming languages (naming, readability, design). |
php/ |
Language-specific micro-optimizations, syntax tricks, and best practices. |
In most languages (C, C++, Java, PHP, JavaScript, etc.), ++i increments the variable and returns the new value directly,
while i++ returns a copy of the old value, then increments β creating an unnecessary temporary object.
// β
Faster β increments directly
++i;
// β Slightly slower β returns old value before incrementing
i++;Negligible in high-level code, but measurable in tight loops or performance-critical sections (e.g. millions of iterations in C/Java).
Use ++i when you donβt need the previous value. Use i++ only if you explicitly need the value before incrementing.
Collect small but valuable insights that make code:
- More efficient β‘
- More readable π
- More maintainable π§