Rob Pike 编程五原则
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 编程五原则的更多相关文章
- 谷歌大牛 Rob Pike 的 5 个编程原则
谷歌大牛 Rob Pike 的 5 个编程原则 简介: Rob Pike,目前谷歌公司最著名的软件工程师之一,曾是贝尔实验室Unix开发团队成员,Plan9操作系统开发的主要领导人,Inferno操作 ...
- Rob Pike:我得到的最佳编程建议
Rob Pike:我得到的最佳编程建议 Rob Pike,目前谷歌公司最著名的软件工程师之一,曾是贝尔实验室Unix开发团队成员,Plan9操作系统开发的主要领导人,Inferno操作系统开发的主要领 ...
- Linux网络编程(五)
/*Linux网络编程(五)——多路IO复用之select() 网络编程中,使用IO复用的典型场合: 1.当客户处理多个描述字时(交互式输入以及网络接口),必须使用IO复用. 2.一个客户同时处理多个 ...
- 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 ...
- Concurrency Is Not Parallelism (Rob pike)
Rob pike发表过一个有名的演讲<Concurrency is not parallelism>(https://blog.golang.org/concurrency-is-not- ...
- Rob Pike 的 5 个编程原则
原则 1. 你没有办法预测每个程序的运行时间,瓶颈会出现在出乎意料的地方,所以在分析瓶颈原因之前,先不要盲目猜测. 原则 2. 测试(measure).在测试之前不要优化程序,即使在测试之后也要慎重, ...
- 【转】编程之道 之 Rob Pike
1.你无法断定程序会在什么地方耗费运行时间.瓶颈经常出现在想不到的地方,所以别急于胡乱找个地方改代码,除非你已经证实那儿就是瓶颈所在. 2.估量.在你没对代码进行估量,特别是没找到最耗时的那部分之前, ...
- Rob Pike
罗布·派克_百度百科 https://baike.baidu.com/item/罗布·派克 1. 你无法断定程序会在什么地方耗费运行时间.瓶颈经常出现在想不到的地方,所以别急于胡乱找个地方改代码, ...
- socket编程五种模型
客户端:创建套接字,连接服务器,然后不停的发送和接收数据. 比较容易想到的一种服务器模型就是采用一个主线程,负责监听客户端的连接请求,当接收到某个客户端的连接请求后,创建一个专门用于和该客户端通信的套 ...
随机推荐
- 软概(lesson 2):课堂测试
一.测试题目 二.完成过程 1.设计思想 ①连接mysql数据库 ②设计user类,增加参数 ③设计add类,向数据库内增加内容 ④设计addInput页面,完成录入操作 ⑤设计add页面,接收录入的 ...
- 开源HTTP解析器---http-parser和fast-http
由于项目中遇到需要发送http请求,然后再解析接收到的响应.大概在网上搜索了一下,有两个比较不错,分别是http-parser和fast-http. http-parser是由C编写的工具:fast- ...
- linux编程头文件所在路径的问题
一.问题引入 1.头文件与库 当我们在PC主机linux环境下(如ubuntu),编写linux应用程序,然后利用gcc来编译.在源代码的开始位置会写入头文件,那是因为我们使用了系统提供的库函数,例如 ...
- JAVA实现用户的权限管理
一:写在前面 前两天有个同学问我,那个系统不同的用户登陆不同的页面不同,要写很多个页面啊!而每个用户的在系统中拥有不同的权限,可以访问不同的页面是怎么实现的??那低权限的在浏览器输入高权限的人的url ...
- Luogu3162 CQOI2012 组装 贪心
传送门 如果提供每一种零件的生产车间固定了,那么总时间\(t\)与组装车间的位置\(x\)的关系就是 \(t = \sum (x-a_i)^2 = nx^2-2\sum a_ix + \sum a_i ...
- React-Route的属性exact
exact是Route下的一条属性,一般而言,react路由会匹配所有匹配到的路由组价,exact能够使得路由的匹配更严格一些. exact的值为bool型,为true是表示严格匹配,为false时为 ...
- DataWorks使用小结(二)——功能面板使用指南
一.数据开发 1.任务开发 新建表 野路子可以直接新建一个任务,粘贴DDL,手动运行任务即可完成建表 正常应当是在“数据管理”->数据表管理中建表: 支持可视化建表和DDL建表(配合之前的宏,建 ...
- SqlServer 案例:已有汽车每日行驶里程数据,计算其每日增量
需求说明 某公司某项业务,需要获得用户每日行车里程数.已知能获得该车每日提交的总里程数,如何通过 T-SQL 来获得其每日增量里程? 解决方案 首选需要对数据进行编号,利用开窗函数 OVER() 实现 ...
- 总目录(Catalog)
总目录(Catalog) C#高级编程(C# advanced programming) 1.并发编程(Concurrent programming)(8) ...... 数据结构与算法(Data s ...
- Sql_join left right
1.内连接inner join 只返回两张表中所有满足连接条件的行,即使用比较运算符根据每个表中共有的列的值匹配两个表中的行.(inner关键字是可省略的) ①传统的连接写法: 在FROM子句中列出所 ...