什么成就了优雅编程?

  • 什么成就了优雅编程(What Makes a Program Elegant?)
    • 字典定义
    • ACM社区
      • minimality:最小(性)
      • accomplishment:完成性
      • modesty:质朴的、朴实的
      • revelation:启示、披露揭露
      • 参考

什么成就了优雅编程(What Makes a Program Elegant?)

字典定义

A program that is simple in design and uses the least amount of computer resources (memory, disk, etc.).

ACM社区

minimality:最小(性)


A program should be brief, but not a slave to brevity. An elegant design artifact is sleek and spare in its utility. An elegant program is minimally gratuitous.

一个程序应该是简短的,但不是简洁的奴隶。 优雅的设计工艺在其实用性方面是时尚和多余的。最小化不必要部分是 一个优雅的程序所必须具备的特质。

We have our first criterion for elegance, (1) minimality, encompassing both shortness and simplicity.

我们有了第一个优雅的标准:最小(性)(简单和短小)

避免程序的功能完全依赖于源代码的语法、编译器、I/O机制或者内存处理。最小化临时变量(直接用表达式表示更好)。这些都没能解决该级别的没学问题。更多的错误检查能提高代码的质量,但这并没有增强优雅型,甚至可能削弱它的优雅。

accomplishment:完成性

A factor that looms larger in computer science than in architecture or other disciplines is correctness. A building may be regarded as elegant even if marginal parts of it are uncomfortable, but no program that does not work is regarded as elegant. This gives us another criterion, (2) accomplishment—the program does what it is supposed to do. Though included in the list of desiderata here, failure on that criterion is fatal, rather than detrimental.

计算机科学比建筑学或其他学科更大的一个因素是正确性。 即使建筑物的边缘部分不舒服,建筑物也可能被认为是优雅的,但是没有任何不起作用的程序被认为是优雅的。 这给了我们另一个标准,(2)完成性 - 程序做它该做的事情。 虽然在列入了强制性列表,但不遵守该标准是致命的,而不是有害的。

modesty:质朴的、朴实的

Brevity, or minimality, is a salient feature of code, but a subtle feature of algorithms; what we want, of course, is minimality in terms of the solution, however that solution is expressed. Yet another more general concept of spareness is at play in elegance, something like restraint. This gives us a criterion of (3) modesty. 

简洁性或极小性是代码的一个显著特征,但它却是算法的一个巧妙的特征。当然,我们希望最小化解决方案。另一个更普遍的概念在优雅中发挥作用,比如约束力。

revelation:启示、披露揭露

What else counts? An elegant program confers a sense of satisfaction, of enlightenment. Let's call this criterion, especially characteristic of program artifacts, (4) revelation—the program shows us something new about its task, or brings to the fore something that we forgot. 

还有什么重要的?优雅的程序赋予了满足感和启蒙感。让我们称之为标准,特别是程序工件的特征,(4)启示 - 程序向我们展示了关于其任务新的信息,或者突出了我们忘记的东西。

参考

What Makes a Program Elegant?

你可能感兴趣的:(程序优化)