Writing shorter code/algorithms, is more efficient (performance)?

后端 未结 11 1781
半阙折子戏
半阙折子戏 2021-02-19 15:19

After coming across the code golf trivia around the site it is obvious people try to find ways to write code and algorithms as short as the possibly can in terms of characters,

11条回答
  •  一个人的身影
    2021-02-19 16:03

    I hope this does not become a flame war. Good code has many attributes, including:

    1. Solving the use-case properly.
    2. Readability.
    3. Maintainability.
    4. Performance.
    5. Testability.
    6. Low memory signature.
    7. Good user interface.
    8. Reusability.

    The brevity of code is not that important in 21st century programming. It used to be more important when memory was really scarce. Please see this question, including my answer, for books referencing the attributes above.

提交回复
热议问题