Daily Productive Sharing 1059 - Optimizations

One helpful tip per day:)

What is code optimization, and how do you optimize it? Paul W. Homer explains it clearly in just a few words:

  1. Abstractly, code can be divided into three categories: ordinary code, redundant code, and optimized code. The second type is actually a variant of the first, but slower and more bloated; the third type is an optimized version of the first, more concise and faster.
  2. In many cases, so-called code optimization is about turning the second type of code back into the first type.
  3. Turning the first type of code into the third type requires a deeper understanding of computational logic to find faster ways of processing.
  4. Most importantly, code is just a set of instructions for performing calculations. We should aim to write code correctly the first time, at least as the first type, but ideally as the third type.

If you enjoy today's sharing, why not subscribe

Need a superb CV, please try our CV Consultation


什么是代码优化?如何优化?Paul W. Homer 用三言两语把这些讲得清清楚楚:

  1. 抽象来讲,可以把代码分为三类,一种是普通代码,一种是冗余代码,最后一种是优化后的代码。第二种其实是第一种的变体,变得更慢,更臃肿;第三种是第一种的优化版本,更简洁,运行得更快;
  2. 很多情况下,所谓的代码优化是吧第二种代码变成第一种;
  3. 要把第一种代码变成第三种,意味着要更熟悉计算逻辑,从而找到更快的运算方式;
  4. 最重要的是,代码只是用来执行计算的指令。我们要尽可能地在第一次写代码时就把代码写好,至少是第一种代码,最好是第三种代码。

如果你喜欢的话,不妨分享给身边的朋友 ⬇️