Rob Pike's 5 Rules of Programming

Rule 1: You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is.

Rule 1: 你无法说出程序运行所花费的时间。 意外之处出现瓶颈,因此不要去尝试猜测和加快速度直到你已证明这就是瓶颈所在。

Rule 2: Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest.

Rule 2: 测量。 不要调整速度直到你已进行测量,即使这样也不能,除非代码的一部分能够覆盖其余部分。

Rule 3: Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)

Rule 3: 当n小时,花哨的算法很慢,n通常很小。花哨的算法有很大的常量。不要幻想除非你确切知道n在频繁的变的很大。(即使n确实变大,首先使用Rule 2)

Rule 4: Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures.

Rule 4: 花式算法比简单算法笨拙,并且他们实现更加困难。 使用简单的算法以及简单的数据结构。

Rule 5: Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.

Rule 5: 数据占主导地位。 如果你已选择正确的数据结构且正确组织他们,那么算法几乎总是不言而喻的。数据结构而非算法,是编程的核心。

Brief Notes
Pike's rules 1 and 2 restate Tony Hoare's famous maxim "Premature optimization is the root of all evil."

Ken Thompson rephrased Pike's rules 3 and 4 as "When in doubt, use brute force.". Rules 3 and 4 are instances of the design philosophy KISS.

Rule 5 was previously stated by Fred Brooks in The Mythical Man-Month. Rule 5 is often shortened to "write stupid code that uses smart objects".

Who is Rob Pike?
Rob Pike, is now a Distinguished Engineer at Google co-authoring Go programming language, apart from other things. Prior to this stint, he worked at Bell Labs as a core member of the Unix Team.
Author of popular books like The Practice of Programming and Unix Programming Environment

  • Rob Pike,一个卓越的工程师,除其他工作外,在Google合作开发Go编程语言。在此之前,在贝尔实验室作为Unix团队核心成员。

  • The Practice of Programming and Unix Programming Environment等畅销书作者。

References
Content is shamelessly copy-pasted from http://users.ece.utexas.edu/~adnan/pike.html
Posted by Karthik Sirasanagandla at Sunday, September 17, 2017
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: clean code, Performance, programming, ProTips

http://blog.codonomics.com/2017/09/rob-pikes-5-rules-of-programming.html

---恢复内容结束---

Rob Pike's 5 Rules of Programming

Rule 1: You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is.

Rule 1: 你无法说出程序运行所花费的时间。 意外之处出现瓶颈,因此不要去尝试猜测和加快速度直到你已证明这就是瓶颈所在。

Rule 2: Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest.

Rule 2: 测量。 不要调整速度直到你已进行测量,即使这样也不能,除非代码的一部分能够覆盖其余部分。

Rule 3: Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)

Rule 3: 当n小时,花哨的算法很慢,n通常很小。花哨的算法有很大的常量。不要幻想除非你确切知道n在频繁的变的很大。(即使n确实变大,首先使用Rule 2)

Rule 4: Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures.

Rule 4: 花式算法比简单算法笨拙,并且他们实现更加困难。 使用简单的算法以及简单的数据结构。

Rule 5: Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming.

Rule 5: 数据占主导地位。 如果你已选择正确的数据结构且正确组织他们,那么算法几乎总是不言而喻的。数据结构而非算法,是编程的核心。

Brief Notes
Pike's rules 1 and 2 restate Tony Hoare's famous maxim "Premature optimization is the root of all evil."

Ken Thompson rephrased Pike's rules 3 and 4 as "When in doubt, use brute force.". Rules 3 and 4 are instances of the design philosophy KISS.

Rule 5 was previously stated by Fred Brooks in The Mythical Man-Month. Rule 5 is often shortened to "write stupid code that uses smart objects".

Who is Rob Pike?
Rob Pike, is now a Distinguished Engineer at Google co-authoring Go programming language, apart from other things. Prior to this stint, he worked at Bell Labs as a core member of the Unix Team.
Author of popular books like The Practice of Programming and Unix Programming Environment

  • Rob Pike,一个卓越的工程师,除其他工作外,在Google合作开发Go编程语言。在此之前,在贝尔实验室作为Unix团队核心成员。

  • The Practice of Programming and Unix Programming Environment等畅销书作者。

References
Content is shamelessly copy-pasted from http://users.ece.utexas.edu/~adnan/pike.html
Posted by Karthik Sirasanagandla at Sunday, September 17, 2017
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest
Labels: clean code, Performance, programming, ProTips

http://blog.codonomics.com/2017/09/rob-pikes-5-rules-of-programming.html

Rob Pike 编程五原则的更多相关文章

  1. 谷歌大牛 Rob Pike 的 5 个编程原则

    谷歌大牛 Rob Pike 的 5 个编程原则 简介: Rob Pike,目前谷歌公司最著名的软件工程师之一,曾是贝尔实验室Unix开发团队成员,Plan9操作系统开发的主要领导人,Inferno操作 ...

  2. Rob Pike:我得到的最佳编程建议

    Rob Pike:我得到的最佳编程建议 Rob Pike,目前谷歌公司最著名的软件工程师之一,曾是贝尔实验室Unix开发团队成员,Plan9操作系统开发的主要领导人,Inferno操作系统开发的主要领 ...

  3. Linux网络编程(五)

    /*Linux网络编程(五)——多路IO复用之select() 网络编程中,使用IO复用的典型场合: 1.当客户处理多个描述字时(交互式输入以及网络接口),必须使用IO复用. 2.一个客户同时处理多个 ...

  4. Talk 3: Rob Pike on Upspin (Gopherfest 2017)

    Talk 3: Rob Pike on Upspin Upspin is an experimental project to build a framework for naming and sha ...

  5. Concurrency Is Not Parallelism (Rob pike)

    Rob pike发表过一个有名的演讲<Concurrency is not parallelism>(https://blog.golang.org/concurrency-is-not- ...

  6. Rob Pike 的 5 个编程原则

    原则 1. 你没有办法预测每个程序的运行时间,瓶颈会出现在出乎意料的地方,所以在分析瓶颈原因之前,先不要盲目猜测. 原则 2. 测试(measure).在测试之前不要优化程序,即使在测试之后也要慎重, ...

  7. 【转】编程之道 之 Rob Pike

    1.你无法断定程序会在什么地方耗费运行时间.瓶颈经常出现在想不到的地方,所以别急于胡乱找个地方改代码,除非你已经证实那儿就是瓶颈所在. 2.估量.在你没对代码进行估量,特别是没找到最耗时的那部分之前, ...

  8. Rob Pike

    罗布·派克_百度百科 https://baike.baidu.com/item/罗布·派克   1. 你无法断定程序会在什么地方耗费运行时间.瓶颈经常出现在想不到的地方,所以别急于胡乱找个地方改代码, ...

  9. socket编程五种模型

    客户端:创建套接字,连接服务器,然后不停的发送和接收数据. 比较容易想到的一种服务器模型就是采用一个主线程,负责监听客户端的连接请求,当接收到某个客户端的连接请求后,创建一个专门用于和该客户端通信的套 ...

随机推荐

  1. ESP WIFI

    esp_err_tesp_wifi_init(constwifi_init_config_t *config) 这个WIFI初始化函数是使用所有的WIFI API之前必须调用的函数: 函数的参数是一个 ...

  2. Apache IOUtils的使用

    IOUtils 与 FileUtilsCommons IO 是 apache 的一个开源的工具包,封装了 IO操作的相关类,使用 Commons IO 可以很方便的读写文件 commons.jar 包 ...

  3. Omi-router实战 Sorrow.X的web简历

    其实这篇文章,真的没啥写的. 主要是为了学以致用,使用了omi-router写了个,个人简历. 路由demo实战源码:https://github.com/SorrowX/resume_demo de ...

  4. ASP.NET MVC学习笔记(一) 从路由开始创建mvc

    之前一篇写一半发现版本太老了,是基于mvc2的. 两本参考书编写的顺序各方面都不太一样.决定重新写一篇. 我这篇文章基于mvc5,vs2015 参考书:Will保哥的ASP.NET MVC4开发指南 ...

  5. CF418D Big Problems for Organizers 树的直径、ST表

    题目传送门:http://codeforces.com/problemset/problem/418/D 大意:给出一棵有$N$个节点的树,所有树边边权为$1$,给出$M$次询问,每个询问给出$x,y ...

  6. 清除EasyUi combotree下拉树的值

    由于测试自带的$(“node”).combotree("clear');问题始终解决不了 最终方法: Hdata是JSON数据源, 在它动态加在成功之后(节点全部显示出来,并且可以选择)再清 ...

  7. 一文详解如何用 TensorFlow 实现基于 LSTM 的文本分类(附源码)

    雷锋网按:本文作者陆池,原文载于作者个人博客,雷锋网已获授权. 引言 学习一段时间的tensor flow之后,想找个项目试试手,然后想起了之前在看Theano教程中的一个文本分类的实例,这个星期就用 ...

  8. Python高阶函数--map

    map()函数 map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把list 的每个元素依次作用在函数 f 上,得到一个新的 list 并返回. 例如,对于lis ...

  9. C语言----数据类型(基础篇一)

    C语言的入门程序模板 #include <stdio.h> /*使用或者包含系统里面的程序*/ main() /*程序入口点*/ { /*起点*/ +; /*叫计算机执行的指令*/ } / ...

  10. vue路由\导航刷新后:ative\localStorage\url截取参数

    <el-menu :default-active="$route.path" router mode="horizontal"> <el-me ...