文档章节

转摘<<On becoming an expert C programmer>>

凌晨4点半
 凌晨4点半
发布于 2014/10/27 22:32
字数 1470
阅读 39
收藏 1

The following is from an EMail message that I sent to to an individual on 12-Apr-2001. You may find this EMail message useful.

The Writer asked:

``I just recently visited your website ... Just wanted to say greetings and ask a simple question: Do you think I stand a chance in the C programming field if I keep it up? Tell me what I should do in order to keep strong feelings towards C.'' 

Here is my reply:

Thank you for your kind words.

You asked:

``... Do you think I stand a chance in the C programming field if I keep it up?'' 

YES!! Persistence and determination are important keys to success.

You asked:

``Tell me what I should do in order to keep strong feelings towards C.'' 

Permit me to babble out a few random thoughts ...

Write programs for other people.

Where possible, openly publish your code, perhaps on your web site. Open source repository sites such as the Source Forge site is a good place to announce new code. Another good site to consider publishing at is http://freecode.com/.

Very important: Support the code that you publish.

Start small and work your way up ... Some of my more popular code is actually small code fragments that are used by others over and over again.

Don't be discouraged if nobody (or if only a few people) uses some of your early programs. What is important is to practice writing quality, well commented code ... to maintain and fix that code.

It is somewhat easy to write a program that works. It requires practice and effort to write code that you can maintain and support. The programs that win the IOCCC (see www.ioccc.org, a contest that I founded back in 1984) are NOT good programs. While they work, and some work very well, they cannot be maintained or improved ... often they cannot be maintained or improved even by their original author.

Parts of a well written program can be reused or borrowed by other programs. Reuse your code when possible. In fact, write your code well (with comments, etc.) the first time ... even if you are just writing a quick 'hello world' program.

If a program is not worth writing well (perhaps because you think it is just a quick test code fragment ...) then it is not worth writing in the first place.

Always, always, always write code as if it will last 30 years ... some of your code can live that long. Write code as if you expect to some back years later and work on it ... long after you forgot the details of the code. Don't write clever obscure twisted hacks. Those write clever obscure twisted hacks are hard to maintain and reuse later.

NOTE: This especially applies to short, simple test programs ala ``Hello, world!''. Comment even the smallest quicky programs. If nothing else, it is good practice and maintains a good habit. Consider keeping such code fragments. 

Keep a collection of programs and samples. The first time you write something, like a set of functions to manage a linked list, safe that code in your samples directory. The NEXT time you need to deal with linked list, go back into your samples directory and reuse it. If you find a bug, or a better way to do something then update the code in your samples directory.

Remember that I suggested you should always write code as if it will last for 30 years? Well if you keep your collection of sample code around ... some of it will.

Your speed will pick up with practice. Your speed will increase as you build up a portfolio / collection of sample programs and code fragments. If you write something well once, you can reuse it again and again later on with little extended effort.

Code like you are an artist ... even if you feel your initial programs are not very good. Make the effort to improve. All artists start out not drawing very well. But their will to express themselves and PRACTICE helps them improve and improve ...

BTW: Some of the better programmers are musicians. Learn to play an instrument / read music / play music for someone else. Art seems to stimulate the mind in ways that are very helpful to programming. Someone can plunk a tune on an instrument if they memorize the notes just as someone can write a program that appears to work. But it takes practice and the will to want perform it well to turn those notes into something interest to listen too ... just as it takes practice and the will to want to code well to write good programs that last.

Just as a beginning musicians just start out with simple tunes, a beginning program must start out with simple programs. You don't expect to write a and conduct a symphony at age 14 (unless you happen to be Mozart :-)) ... you shouldn't expect to write the next 'killer app' at age 14 either. HOWEVER ... practice and have the will to improve ... in time you will exceed the j-random programmer and become very good.

A good program or code fragment will want to be improved. You know you have done something well when others (or you) want you to add this feature or improve it. It is OK if someone complains about bugs ... you will never be perfect anyway. But if someone complains about a bug, it is because they WANT your program to work because that LIKE the idea that your program is trying to express. At least they are paying attention to your code!

Writing games are sometimes a good way to get people to use your code.

Writing a tools is a good habit to get into. If you find that you are doing something over and over again ... write a tool to do it or to make that step faster. Act "smart and lazy". Write a tool to deal with repetitive tasks.

Don't be afraid to step out of the C box. For example, learn Ruby:

http://www.ruby-lang.org 

and learn Perl:

http://www.perl.com 

There are some things that C does well ... there are some things that Ruby does well and some things that Perl does well. Being a multilingual programmer helps make you a better programmer. Don't just program in C.

Interact with other programmers. Learn from them. Download their code and look at it. Learn from what they do well ... avoid what they do poorly. Talk with others about how they do their code.

Pay particular attention to open source code. Some of it is OK, most of it could be written better. Because it is open source, you can borrow code and code fragments and drop them into your sample code directory.

Look at some of DBell's code:

http://www.tip.net.au/~dbell/
http://www.isthe.com/chongo/tech/comp/calc/index.html

Learn from it. DBell is one of the best programmers on the planet.

Find bugs in other people's code. If you find that a particular open source program fails / has some sort of bug, try to fix it. Report the bug to the author. If you fix it, send in a fix later. Apply bug fixes and patches when the author releases them.

Maintaining and fixing other people's code is EXTREMELY important skill to have. It is good practice for your own efforts. In the job world, most if what you will do is to fix and improve code that already exists ... so learning to do this early and well will make you a valuable employee later on ...

Back up and protect your sample code directory. Plan to keep that portfolio of code for many years ... don't let a disk crash, theft of a system or other disaster wipe out your work. Always plan to keep that code with you ... as you move from job to job. Don't keep your only copy at your job/school ... you will change schools/jobs and you don't want to lose it. Don't keep your only copy at your home / website / laptop. Those things crash or can get lost.

Spend some time looking at the C Programming Resources I have collected.

It takes time to improve. (See Peter Norvig's "Why is everyone in such a rush?" essay). It is NEVER too late to start.

You are never too good to improve. When I look at code I wrote just a few years ago, I still see code that can be improved. Even though that code had decades of experience behind it, I feel that I could do it better today ... and make the effort to do so.

Did I say code like an artist? :-)

I hope this helps. Best wishes on your path to being a better C programmer.

本文转载自:http://www.isthe.com/chongo/tech/comp/c/expert.html

凌晨4点半
粉丝 3
博文 19
码字总数 6852
作品 0
成都
系统管理员
私信 提问
15 Software Development Influencers You Should Follow in 2018

From software developers to software architects, the software world is full of influential people, many of whom have active social media presence. Therefore, I decided to write ......

Ekaterina Novoseltseva
2017/12/27
0
0
转贴:最佳编程语录

以前本站发布过《22条经典的编程引言》、《编程引言补充》、《Linus Torvalds 语录》还有《十条不错的编程观点》。今天向大家介绍“最佳编程语录”,条条都是很不错的语录,如同我们的太阳,...

鉴客
2010/08/05
783
7
梯子意识

一家公司招聘营销经理,最后A君、B君、C君进入了由公司老总亲自主持的最后一轮考核。 没想到,老总开车把三位年轻人拉到一座果园里,指着三棵高大的苹果树,说,你们每人一棵树,看谁摘的苹果...

长平狐
2013/06/17
74
0
[ 转 ] 一个平庸程序员的自白

Jacob Kaplan-Moss 是著名 Python 框架 Django 的 Co-Creater 和核心开发者,在 Heroku 担任安全部门的 Director, 他常年参加 Python 社区的年度聚会 PyCon ,并经常上台演讲。在这次 PyCon ...

小馍馍
2015/06/09
251
4
【CUBE】Oracle分组函数之CUBE魅力

Oracle的CUBE与ROLLUP功能很相似,也是在数据统计分析领域的一把好手。 关于ROLLUP的查询统计功能请参考文章《【ROLLUP】Oracle分组函数之ROLLUP魅力》(http://space.itpub.net/519536/vie...

GoYang
2012/12/22
160
0

没有更多内容

加载失败,请刷新页面

加载更多

最简单的获取相机拍照的图片

  import android.content.Intent;import android.graphics.Bitmap;import android.os.Bundle;import android.os.Environment;import android.provider.MediaStore;import andr......

MrLins
今天
6
0
说好不哭!数据可视化深度干货,前端开发下一个涨薪点在这里~

随着互联网在各行各业的影响不断深入,数据规模越来越大,各企业也越来越重视数据的价值。作为一家专业的数据智能公司,个推从消息推送服务起家,经过多年的持续耕耘,积累沉淀了海量数据,在...

个推
今天
10
0
第三方支付-返回与回调注意事项

不管是支付宝,微信,还是其它第三方支付,第四方支付,支付机构服务商只要涉及到钱的交易都要进行如下校验,全部成功了才视为成功订单 1.http请求是否成功 2.校验商户号 3.校验订单号及状态...

Shingfi
今天
5
0
简述Java内存分配和回收策略以及Minor GC 和 Major GC(Full GC)

内存分配: 1. 栈区:栈可分为Java虚拟机和本地方法栈 2. 堆区:堆被所有线程共享,在虚拟机启动时创建,是唯一的目的是存放对象实例,是gc的主要区域。通常可分为两个区块年轻代和年老代。更...

DustinChan
今天
7
0
Excel插入批注:可在批注插入文字、形状、图片

1.批注一直显示:审阅选项卡-------->勾选显示批注选项: 2.插入批注快捷键:Shift+F2 组合键 3.在批注中插入图片:鼠标右键点击批注框的小圆点【重点不可以在批注文本框内点击】----->调出批...

东方墨天
今天
7
1

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部