TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How to Write Fast Code

143 点作者 techdog大约 16 年前

10 条评论

lallysingh大约 16 年前
I'm glad to see people talking about one of the four stages of optimization:<p>1. Do we have to optimize this? Time is never free, and opportunity cost in terms of engineering effort is usually very significant.<p>2. Can we do less work? (this article)<p>3. What's the bottleneck? CPU, FP, memory bandwidth, lock contention?<p>4. How do we squeeze out better performance? Assembly, loop unrolling, etc.<p>I usually cringe when I hear about people talking about #4, as very few of them have asked #1, #2, or #3 yet.<p>And usually, you just hear people talking about doing what the compiler's already doing (writing it in assembly? /The compiler already does that/), usually doing a pretty reasonable job at high optimization levels. They just exchange maintainability for the warm fuzzy feeling that they've been as macho as needed.
评论 #528535 未加载
评论 #528557 未加载
bsaunder大约 16 年前
I'm personally fascinated by the notion that efficiency and transformation seem to be intertwined. Hard problems can sometimes seem simple with a slight transformation in either the problem description or the data. Even the article is suggesting that to write fast code, transform your perspective of the problem. Do less. There seems to be something fundamental here.
评论 #528668 未加载
arien大约 16 年前
This is the kind of advice that points at something so obvious that you really never thought about it and feel silly once someone points it out :)
评论 #528405 未加载
iamwil大约 16 年前
Isn't the old adage: "the fastest code is the one you never run?"
评论 #528913 未加载
froo大约 16 年前
It's an unbelievably simple statement that is applicable to many different situations, not just computer related stuff.<p>For example, right now I'm detailing some design principles for a project I'm working on.<p>I realise there is a limited amount of time to be able to complete the project effectively and to make it look decent, so in the process I've come to make some hard choices.<p>I've found the trying to be creative with less is working out well so far and in the end it should pay off.
dualogy大约 16 年前
Off-topic maybe, but: "How to Write Code Fast", now can someone point me to literature for <i>that</i>? Highly appreciated!
评论 #529916 未加载
zandorg大约 16 年前
Or split your workload up so it can be run on 200 cores in an instant. Not to advertise, but I'm not affiliated with Nvidia - <a href="http://www.nvidia.co.uk/page/tesla_deskside.html" rel="nofollow">http://www.nvidia.co.uk/page/tesla_deskside.html</a>
yawniek大约 16 年前
"no code is faster than no code" (comes from yehuda katz afair)
10ren大约 16 年前
I get the feeling that "John" is a literary device for the alter-ego of the author.
ezmobius大约 16 年前
no code is faster then no code.