» Complexity is the enemy
I'm almost through my seventh year working at Google(!). I have learned many things there, more than I could ever write down. I thought I would at least share with you something that's only come to me with more experience.
我已经在google待了7年了。我在那儿学到了很多比我以前用纸记录下来的更多的东西。我认为我能够与你分享一点我的经验,这些经历使我变得更有经验
Complexity is the death of software. It's hard to quantify the cost of, and it tends to creep in slowly, so it's a slow boil of getting worse that's hard to see until it's too late. On the other side, frequently it's easy to see a benefit of increasing complexity: a new layer of indirection allows new feature X, or splitting a process that ran on one machine into two allows you to surmount your current scaling hurdle. But now you must keep another layer of indirection in your head, or implement an RPC layer and manage two machines.
复杂的软件往往导致一个产品死亡。事实上往往很难衡量它的成本,而且复杂化的过程是很缓慢的,这个过程中存在的问题是很难被发现,直到量变达到质变的程度,那时已经为时已晚。但是从另外的一个角度看,增加了一个功能增加了复杂度,往往会带来好处,例如:增加一个新的间接层,会有产生新特性X的可能,或者将在一台机器上的的处理流程一分为二(就像我们口碑现在搞的hsf服务化改造),使得你能够超越你现有的处理能力,但是实际上,当你解决了一个问题之后会产生出另外的问题。这个时候你必须要额外增加另外的一个中间层的维护开销,或者需要实现一个RPC(远程调用层)并且管理两台机器。
The above is hopefully just as obvious to a new programmer as it is to a veteran. What I think I've learned through my few years in the industry is a better understanding of how the balance works out; when complexity is warranted and when it should be rejected. I frequently think back to a friend's comment on the Go compiler written by Ken Thompson: it's fast because it just doesn't do much, the code is very straightforward.
这些对于有经验的程序员来说是显而易见的,我希望新程序员也能有同样的感受(这句是而杨总翻译的),我认为我在大学中学习到的是更好地理解执行中的平衡。当过度复杂已经被证明,这个时候你应该学会拒绝。我经常回想起一个朋友对《Go compile》这本书的评论:因为没有额外做很多事所以实现可以很快,而且代码会非常直接明了。
It turns out that, much like it's easier to write a long blog post than it is to make the same point succinctly, it's difficult to write software that is straightforward. This is easiest to see in programming langauge design; new languages by novices tend to have lots of features, while few have the crisp clarity of C. In today's programs it's frequently related to how many objects are involved; in distributed systems it's about how many moving parts there are.
结果是,你会发现写一个长的博客来表达一个主题是容易的,相对于用非常简洁的语句来表达。用非常直接的方式来写一个程序是非常困难的。这种现象在编程语言的设计过程中是最容易发现的。一个新的语言会有很对特性,然而很少有C语言那样清晰明了的。眼下的程序经常需要考虑要与有多少对象有关;在分布式系统中,需要考虑有多少移动的部分运行其中。
Another word for this problem is cleverness: to quote another one of the C hackers, "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
What helps? I wonder if it maybe just comes down to experience -- getting bitten by one too many projects where someone thought metaprogramming was cool. But I've found having specific design goals to evaluate new code by can help. It's easier to reject new code if you can say "this does not help solve the initial goals of the project". Within Google the template document for describing the design of a new project has a section right at the top to list non-goals: reasonable extensions of the project that you intend to reject.
有什么帮助吗?我怀疑这要归结为我们的经验了------在不止一个项目中痛苦纠结之后发现元数据编程是一件非常cool的事。但是,我发现有开发的时候,有明确的目标的话可以对评估新代码有所帮助。拒绝新的代码是非常容易的如果你能说“这对解决项目初始目标是没有帮助的”,在google中,在项目初始阶段,在设计项目项目的时候,需要使用模板文档,在这个模板文档上有一些非项目目标的条目需要写:你打算拒绝的合理的项目扩展点(很难理解为啥要把这个写下来,现在口碑项目需求往往是不合理的项目需求都接下来了,更不用说合理的了,我得想想这个中间有什么玄机)
Ironically, I've found that using weaker tools can help with complexity. It's hard to write a complicated C program because it can't do very much. C programs tend to use lots of arrays because that's all you get, but it turns out that arrays are great -- compact memory representation, O(1) access, good data locality. I'd never advocate intentionally using a weak tool, though. Instead, my lesson has been: write Python code like it was C.
具有讽刺意味的是,我发现使用弱工具(weaker tools)能够解决复杂性的问题。使用C语言写一个复杂的程序是困难的,因为它所能做的事是有限的。C语言会使用很多数组因为那就是你所能使用的,但是结果是数组是很有用的虽然很简单,---紧凑的内存使用等。我从未特意的提倡使用弱工具,但是,当我写Python 代码的时候会把程序的风格写得像C一样。
分享到:
相关推荐
领域驱动设计(Domain-Driven Design,简称DDD)是一种软件开发的方法论,它由Eric Evans在其2004年的同名书籍《领域驱动设计:软件核心复杂性应对之道》中提出。DDD的核心思想是,软件系统的复杂性不仅仅是由技术...
Domain-Driven Design - Tackling Complexity in the Heart of Software
The software development community widely acknowledges that domain modeling is central to software design. Through domain modeling, software developers are able to express rich functionality and ...
Addison_Wesley_-_Domain-Driven_Design_Tackling_Complexity_In_The_Heart_Of_Software_-_2003.chm
Programming.Scala_Tackle.Multi-Core.Complexity.on.the.Java.Virtual.Machine[2009][EN][PDF] Programming Scala: Tackle Multi-Core Complexity on the Java Virtual Machine by Venkat Subramaniam Scala is ...
《布尔函数的复杂性》是Ingo Wegener教授在1987年出版的一部专著,该书深入探讨了布尔函数的计算复杂性理论,是计算机科学领域中的一本经典著作。本书由John Wiley & Sons Ltd.和B.G. Teubner出版社联合发行,并在多...
共3部分,这是part3 Combinatorial optimization algorithms and Complexity(组合最优化算法和复杂性) Author: Christos H.Papadimitriou Kenneth Steiglitz
《Think Complexity》是一本介绍复杂性思维的书,对于那些对复杂系统、数据结构、算法以及它们在现实世界中的应用感兴趣的人士来说,这是一本不可多得的参考资料。通过这本书,读者不仅能够学习到如何使用Python编程...
An invaluable resource for researchers as well as an important guide for graduate and advanced undergraduate students, Theory of Computational Complexity is destined to become the standard reference ...
复杂性理论是一门研究问题复杂性的学科,它从理论和实际应用的角度,分析解决特定问题所需的计算资源量。现代复杂性理论关注的主要问题是,对于各种计算模型,哪些问题可以在合理的资源限制下被解决,哪些问题则无法...
### 复杂性理论简介 #### 一、什么是复杂性理论? 复杂性理论是否仅仅是对现实世界毫不关心的理论家们的领域,还是现代计算机科学的核心主题?本篇介绍旨在将复杂性理论展示为一个活跃的研究领域,其研究成果对...
《复杂性思考》是Allen B. Downey撰写的一本关于算法和复杂性理论的书籍,主要探讨了如何理解和处理计算问题的复杂性。这本书通过Python编程语言来阐述这些概念,使得学习者能够更加直观地理解复杂的算法和数据结构...
Domain-Driven Design Tackling Complexity in the Heart of Software-
Domain-Driven Design Tackling Complexity in the Heart of Software
共3部分,这是part2 Combinatorial optimization algorithms and Complexity(组合最优化算法和复杂性) Author: Christos H.Papadimitriou Kenneth Steiglitz
《连通流与多次访问TSP问题的参数化复杂性》 连通流与多次访问旅行商问题(Connected Flow and Many Visits TSP Problem)是运筹学与图论领域中的一个重要研究对象,它在实际应用中有着广泛的影响,如物流、交通...
Think Complexity: Complexity science is an interdisciplinary field—at the intersection of mathematics, computer science and natural science—that focuses on complex systems, which are systems with ...
总之,Norman的《Living with Complexity》提供了一个全面的视角来审视和理解我们生活中不可避免的复杂性,它向读者展示了如何通过设计和管理来拥抱和利用这种复杂性,以提高我们的生活质量。这本书为设计师、工程师...
这些注释旨在使学生了解复杂性理论领域的基本成果和研究方向。 重点放在概念和想法上,避免了复杂的技术证明。