Programming Pearls 编程珠玑

5星(超过95%的资源)
所需积分/C币:9 2016-01-11 15:37:08 15.22MB PDF
17
收藏 收藏
举报

Programming Pearls 编程珠玑
To Daniel Timothy Bentley Library of Congress Cataloging-in-Publication Data Bentley, Jon louis More programming pearls Includes index Electronic digital computers--Programming I Title QA7663452198800587-37447 ISBN0201-118890 AT Copyright o 1988 by Bell Telephone Laboratories, Incorporated All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopy ing, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Published simultaneously in Canada. This book was typeset in Times Roman and Courier by the author, using an autologic APS.5 phototypesetter driven by a dEC VAX 8550 running the 9th Edition of the UnIX operating system DEC, PDP and VAX are trademarks of Digital Equipment Corporation. UNIX is a registered trademark of AT&t CDEFGHIJ-HA-89 PREFACE Computer programming is fun. Sometimes programming is elegant science. It's also building and using new software tools. Programming is about people, too: What problem does my customer really want to solve? How can I make it easy for users to communicate with my program? Programming has led me to learn about topics ranging from organic chemistry to Napoleon's campaigns This book describes all these aspects of programming, and many more. This book is a collection of essays. Each one can be read in isolation, but there is a logical grouping to the complete set. Columns 1 through 4 describe techniques for manipulating programs. Columns 5 through 8 present some tricks of the programmer's trade; they are the least technical in the book. Columns 9 through 12 turn to the design of input and output. Columns 13 through 15 describe three useful subroutines. More details on these themes can be found in the introduction to each part Most of the columns are based upon my"Programming Pearls"columns in Communications of the Association for Computing Machinery. The publica tion history is described in the introductions to the various parts. Given that early versions already appeared in print, why did i bother writing this book? The columns have changed substantially since they first appeared. There have been literally thousands of little improvements: there are new problems and solutions, little bugs have been fixed, and I' ve incorporated comments from many readers. Some old sections have been removed to reduce overlap, many new sections have been added and one of the columns is brand new The biggest reason for writing this book, though, is that I wanted to present the various columns as a cohesive whole; i wanted to display the string of pearls My 1986 book Programming Pearls is a similar collection of thirteen columns, built around the central theme of performance which played a prominent role in the first two years of the CACM column. The topic of efficiency rears its head in a few of these columns, but this book surveys a much larger piece of the programming landscape. As you read the columns, don't go too fast. Read them well, one per sitting Try the problems as they are posed some of them arent as easy as they look. The further reading at the end of some columns isn' t intended as a scholarly V1 MORE PROGRAMMING PEARLS reference list: I've recommended a few books that are an important part of my personal dI library i am happy to be able to acknowledge the substantial contributions of many people. Al Aho, Peter Denning, Brian Kernighan and Doug Mcllroy made detailed comments on each column. I am also grateful for the helpful com- ments of Bill Cleveland, Mike Garey, Eric Grosse, Gerard Holzmann, Lynn Jel- inski, David Johnson, Arno Penzias, Ravi Sethi, Bjarne Stroustrup, Howard Trickey, and Vic Vyssotsky. I appreciate receiving permission from several peo- ple to quote their letters, particularly Peter Denning, Bob Floyd, Frank Starmer, Vic Vyssotsky, and Bruce Weide. I am especially indebted to the ACM for encouraging publication of the columns in this form, and to the many Commun ications readers who made this expanded version necessary and possible by their comments on the original columns. Bell Labs, and especially the Computing Science Research Center, has provided a wonderfully supportive environment as I've written the columns. Thanks all Murray Hill, New Jersey J B 基础的重要性(程序员之路) 学习编程有几年了,感觉走了不少弯路,而不少的学弟学妹又在重蹈我当初的覆辙,不免有些痛心。最近在网 上也看了许多前辈们的经验建议,再结合自己的学习经历在这里谈谈基础的重要性,希望帮助大家少走些弯 路。 什么是基础呢?就是要把我们大学所学的离散数学算法与数据结构,操作系统,计算机体系结构,编译原理 等课程学好对计算机的体系,CPU本身操作系统内核系统平台,向对象编程程序的性能等要有深层次的掌握. 初学者可能体会不到这些基础的重要性,学习jsp, donet mfoνvb的朋友甚至会对这些嗤之以鼻但是一开始没学 好基础就去学jsp或 donet会产生很坏的影响而且陷入其中不能自拔。 我上大二的时候还对编程没什么概念就上了门C++也不知道能干什么,老师说MFC也不知道是什么东西, 看别的同学在学 asp. net就跟着学了然后就了解到netj2 ee, php是什么了,就觉得软件开发就是用这些了,而上 的那些专业课又与我们学的 sqlserver啊CS啊,ajax啊毫无关系,就感慨啊,还不如回家自学去就为一个文凭吗? 还不如去培训浪费这么多钱于是天天基本上没去上什么课天天就在做网站几个学期就做了三个网站。感觉做 这些网站就是学到些技巧,没什么进步这些技巧就好比别人的名字告诉你你就知道了,网上也都可以搜到。那 候就觉得把net学好就行了,搞j2ee的比较难,搞apⅰ编程就别想了,操作系统更是望尘莫及了。后来随着学习 的深入和看了网上许多前辈们的建议才对这些基础的重要性有所体会。 虽然net或java的开发并不直接用到汇编操作系统这些但是不掌握这些基础是有很大问题的,因为你只知 其然不知其所有然,在mf和net里面控件一拖什么都做好了,很方便,但是出了问题可能就解决不了,有些在 网上搜都搜不到。这就是基础没打好不知道它的原理就不知道出错的原因。在学.net的时候常会讨论那些控件 该不该用别人说尽量别用也不知道为什么?不让用是因为你在高层开发你不知道它的原理出错了你可能解决不 了,但其实是应该用的,不然人家开发它干嘛,但要在了解它的原理后去用就会很方便 要编写出优秀的代码同样要扎实的基础,如果数据结构和算法学的不好,怎么对程序的性能进行优化怎样 从类库中选择合适的数据结构。如果不了解操作系统,怎样能了解这些开发工具的原理它们都是基于操作系统 的。不了解汇编,编译原理,怎么知道程序运行时要多长时间要多少內存,就不能编岀高效的代码。 如果没有学好基础一开始就去学net,java这些越往后就会觉得越吃力,它们涉及的技术太多了,而且不但 在更新,对于三层啊,mvc,orm这些架构,你只会用也不明白为什么用,就感觉心里虚,感觉没学好。而你把 面向对象,软件工程,设计模式这些基础学好了再去看这些就可以一不变应万变。 大家不要被新名词、新技术所迷惑NET、ⅩML等等技术固然诱人,可是如果自己的基础不扎实,就像是在 云里雱里行走一样,只能看到眼前,不能看到更远的地方。这些新鲜的技术掩盖了许多底层的原理,要想真正 的学习技术还是走下云端,扎扎实实的把基础知识学好,有了这些基础,要掌握那些新技术也就很容易了。 开始编程应该先学CC+≮,系统apⅰ编程,因为它们更接近底层,学习他们更能搞清楚原理。学好了c/C++ 编程和基础,再去学习mηfic,net这些就会比较轻松,而且很踏实。假设学习VB编程需要4个月,学习基础课程和 C的程序设计需要1年。那么如果你先学VB,再来学习后者,时间不会减少,还是1年,而反过来,如果先学习 后者,再来学νB,也许你只需要1个星期就能学得非常熟练。 编程就好比练功,如果学习. net, mfcyb等具体的语言和工具是外功(招式),对基础的学习就是内功,只注重 招式而内功不扎实是不可能成为高手的。很多人会认为《射雕英雄传》中马玉道长什么都没有教郭靖,马道长 教的表面看来是马步冲权实则都是内功心法,郭靖拜师洪七之后开始练习降龙十八掌凭借的就是这深厚的内 功,吞食蝮蛇宝血又加上练习了周博通传授的九阴真经和外加功夫双手互博技之后,终于练就行走江湖的武 功,由此可见马玉道长传授给了郭靖的是最基础的,也是最重要的观念编程也好比盖髙楼,根基没打好早晩有 天会挎掉的,而且盖得越高,损失也越惨重。这些底层知识和课本不是没有用也不是高深的不能学,而是我 们必须掌握的基础 这些是个人的愚见,说的不是很清楚,大家可以看看这些前辈们的经验,相信看完后大家一定会有所体会 的。为了方便大家阅读,我把这些前辈们的建议的文章整理成了pdf大家在下面下载吧!希望对大家有帮助。pdf +ttle:htTp://bbs.theithome.com/read-htm-tid-123.html 说了这么多无非是想告诫大家要打好扎实的基础,不要只顾迫求时髦的技术,打好基础再去学那些技术或是 参加些培训,对自身的发展会更好的。 基础这么重要怎样学好它呢?我觉得学好它们应该对照这些基础课程所涉及的方面,多看一些经典书籍像算 法导论编程珠玑代码大全(体介绍在本论坛毎本书的版块里)等,这些经典书籍不仅能帮助我们打好基础,而且 对我们的程序人生也能产生莫大的影响,相信认真研究看完这些书籍后,我们的程序之路会十分顺畅。然而这 些书籍并不好读有些甚至相当难读,国内的大学用这些书当教材的也不多这些书又偏向理论,自己读起来难免会 有些枯燥无味。于是就想到建一个论坛,大家共同讨论学习这些书籍,就会学的更踏实更牢固更有趣这样就能 为以后的学习打下扎实的基础。 本论坛特色: bbs. theithome com 1.为计算机初学者或基础不太扎实的朋友指明方向,要注重内功 2.为学习者推荐经典书籍,指明应看哪些书籍,怎样练內功 3为学习者提供一个交流的地方,更容易学好,不会那么枯燥 4.对每本书分章分别讨论,更专,会学的更踏实更牢固 5讨论的都是经典书籍,每一本都会让我们受益匪浅对每本书分别讨论是很有意义的。 CONTENTS Part I: PROGRAMMING TECHNIQUES Column 1: Profilers Computing Primes Using Profilers A Specialized Profiler Building Profilers· Principles· Problems· Further Reading Column 2: Associative Arrays 15 Associative Arrays in Awk A Finite State Machine Simulator Topological Sorting· Principles· Problems· Further Reading Column 3: Confessions of a Coder 27 Binary search· Selection· A Subroutine Library· Principles· Problems Column 4: Self- Describing Data 37 Name- Value pairs· Provenances in Programming· A Sorting Lab· Principles· Problems Part II: TRICKS OF THE TRADE 45 Column 5: Cutting the Gordian Knot 47 A Quiz· Some solutions· Hints· Principles· Problems Further Reading Debugging Column 6: Bumper-Sticker Computer Science 57 Coding· User Interfaces· Debugging· Performance· Documen tation· Managing Software· Miscellaneous rules· Principles· Problems Further Reading Column 7: The Envelope is Back 69 A Warm-Up for Cool Brains Performance Rules of Thumb Littles law· Principles· Problems· Further Reading· Quick Calculations in Everyday Life V1】 VI11 MORE PROGRAMMING PEARLS Column 8: The furbelow memorandum 77 The memo· Principles· Further Reading Part III: I/0 FIT FOR HUMANS 81 Column 9: Little Languages 83 The Pic Language· Perspective· Pic Preprocessors· Little Languages for Implementing Pic· Principles· Problems· Further Reading Column 10: Document Design 101 Tables· Three Design Principles· Figures·Text· The Right Medium· Principles· Problems· Further Reading· A Catalog of Pet Peeves Column 11: Graphic Output 115 A Case Study· A Sampler of Displays· Principles· Problems· Further Reading Napoleon's March to Moscow Column 12: A Survey of Surveys 127 The Problems of polling● The languages· The pictures· Principles· Problems Part IV: ALGORITHMS 137 Column 13: A Sample of brilliance 139 A Sampling of Sampling Algorithms Floyd's Algorithm Random Permutations· Principles· Problems· Further Reading Column 14: Birth of a Cruncher 147 The Problen● Newton Iteration· a Great Place to start●The Code· Principles· Problems· Further Reading· a Big success Story Column 15: Selection 159 The Problem· The Program· Analysis of Run Time· Principles· Problems Further Reading Appendix 1: The C and Awk Languages 171 Appendix 2: A Subroutine Library 175 Solutions to selected Problems 183 Index 203

...展开详情
立即下载 身份认证后 购VIP低至7折
一个资源只可评论一次,评论内容不能少于5个字
Colinnnnnnnnnn 很不错,推荐看看
2018-03-05
回复
gynet 书是好书,有空研究一下
2017-07-09
回复
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
  • 签到新秀

  • 分享王者

关注 私信
上传资源赚钱or赚积分
最新推荐
Programming Pearls 编程珠玑 9积分/C币 立即下载
1/0