写作与思考2011ask.slashdot.org
“我目前的理论是,编程简直就是在写作。”
"My current theory is that programming is quite literally writing."
导读
这篇 Slashdot 讨论从“编程就是写作”这个说法出发,先列举代码糟糕的具体原因,再用教授批改纸面作业、法国文学硕士点披萨等例子,谈基本功、流利度和类比思维。对写作者来说,它把“写清楚”拆成可检查的细节:命名、结构、规范、读者意识,以及别被漂亮类比骗了。
可以直接用的写作要点
- 01
先把基本功练到“流利”:准确命名、理清结构、避免重复、遵循成熟规范,这些和写作的字词句篇是同一种能力。
- 02
每写一句都想着“下一个读它的人”:读者能否不靠猜就理解你的所指,是检验表达是否清楚的最低标准。
- 03
别用“能跑就行”的标准要求自己的文字;按时交付一个勉强能用的东西,长期会累积成烂作品。
- 04
类比能帮你想清楚,却不能替你说服人;看到漂亮的类比时,先问它到底在哪些方面成立。
HN 评论精选
代码差多因基本功和责任心不足;“能上线就行”是根源。
大多数代码很烂,因为写代码的人只有三岁小孩写小说的语言流利度。具体说:变量没按真正代表的东西命名、不理解变量状态和作用域、不懂迭代、不懂所需算法、重复写同样的代码、不了解语言里更好的写法、不懂并发、不懂数据库基础、拒绝遵循成熟标准、也没有标准可循、在糟糕的数据结构上搭代码、不了解底层、需求变化太大无法挽回、甚至不考虑“下一个程序员”。但最重要的是:只要够按时部署出“某个东西”(不管多烂)就行。
edw519查看英文原文
Most code sucks because we have the fluency equivalent of 3 year olds trying to write a novel. Let's get a little more specific... Most code sucks because the programmer: - didn't name his variables what the really were - didn't understand variable state - didn't understand variable scope - didn't understand the basic concepts of iteration - didn't understand any of the algorithms he needed - wrote the same lines of code multiple times - didn't know enough about the language to find a better construct - didn't understand concurrency - didn't understand fundamental data base concepts - refused to follow well worn standards - didn't have any well worn standards to follow - built code on top of hopelessly designed data structures - didn't understand deeply enough what was going on under the hood - built to requirements that changed too dramatically to recover from - didn't even consider the concerns of the "next" programmer But most of all: - was just good enough to get "something" (no matter how bad) deployed on time
纸面审阅迫使你逐行检查,训练发现错误的能力。
大学 CS2 课上,一位和其他老师很不一样的教授要求所有编程作业写在纸上交。发回来时,他会标出程序里所有可能的 bug,而且很少漏掉。那是我在大学里第一次想:“我真得学会这个!”我上的是州立学校,名校毕业的人可能不觉得稀奇,但这位教授和其他人的差距巨大。
larrik查看英文原文
I think he's right. In college, my CS 2 class was taught by a professor very different than the rest of the teachers there. He wanted all of your programming assignments on paper[1]. Then, you'd get it back with every possible bug marked in your program, and he very rarely missed any[2]. That was the first time in college I thought "I really need to learn how to do that!" I went to a state school, so maybe all you guys with your degrees from fancy schools wouldn't be that impressed, but the difference between this professor and the rest there was gigantic. (He retired that year in a round of state-wide budget cuts, so that's the last class I had him.) [1] A lot of the other teachers wanted you to hand in binaries so they can see it run. Sometimes with the code, sometimes not. [2] I actually don't know of any case where he did, but I'm not saying "never."
类比是大脑的模式识别,不等于本质相似,要警惕漂亮类比的误导。
学过两门有深度的学科后,你就会开始看到类比。Paul Graham 觉得编程很像绘画,这位觉得写代码像写英文,我一度还觉得用 Perl 编程像算截面。但这不代表这些领域真的更相似。大脑擅长找类比、找模式,甚至会看到不存在的模式;两门都熟,只是有更多材料可供挑选。
pfedor查看英文原文
When you've learned two subjects with some depth, you start seeing some analogies. Paul Graham thinks that hacking is very much like painting, and this guy thinks that writing code is like writing English, and at one point in my life I believed that coding in Perl has a lot in common with calculating cross sections. That doesn't really mean that these things are any more similar than two random areas of human activity. Our brains are just good at finding analogies, finding analogies is like spotting patterns, we see them even when there aren't any and when there actually are some their appeal is difficult to overcome. And if you know two subjects well you have more material to cherrypick analogous things from.
书本知识不等于场景中的流利运用,写作要练真实语境里的表达。
日本以培养出懂很多英语、却没法在麦当劳点饮料的学生而闻名。我一位朋友有法国文学硕士,住在安大略省渥太华,喜欢河对岸魁北克省赫尔的一家披萨店。一天她打电话订披萨,到了要送货时发现自己不会说,就问披萨店能不能把披萨放进车里、开到我家。接单员回答:“Oui, delivery. Nous pouvons le faire.”
RyanMcGreal查看英文原文
> Japan is somewhat famous for churning out students who know a lot about English, but can't order a drink at Mac Donald's. An old friend of mine had a master's degree in French literature. She used to live in Ottawa, Ontario and was fond of a pizza place just across the river in Hull, Quebec. One day she called to order a pizza, and when it came time to ask for it to be delivered she realized she didn't know how. She asked if the pizza place could put the pizza into a car and drive to her house with it. The order taker replied, "Oui, delivery. Nous pouvons le faire."
同类还值得读
不要想好再写,要写来思考
Don’t think to write, write to think
这篇短文主张不要把写作当成思考完成后的记录,而要把写作本身当作思考的工具:动笔的过程会逼出想不清楚的地方。
写作与思考2022 · 553 分 · 145 评4 条写作要点编辑精选写作即思考:学会自信地写作
Writing Is Thinking: Learning to Write with Confidence
这是一篇讲“写作即思考”的博客:作者认为写作不是把想好的东西誊写出来,而是借助写作本身把想法想清楚,因此写作者应当建立信心、敢于先写烂稿。
写作与思考2019 · 529 分 · 83 评4 条写作要点编辑精选如何用写作来思考
How to think in writing
这篇文章讨论的是「用写作来思考」:作者认为写作不只是把想清楚的东西表达出来,更是想清楚本身的工具——文字落在纸上,你才有机会看见自己思路里的跳跃、含混和漏洞。
写作与思考2024 · 424 分 · 120 评4 条写作要点编辑精选写作,帮你逃离默认的人生设置
Write to Escape Your Default Setting
文章的核心主张就写在标题里:写作是帮你逃离「默认设置」的手段——日常的思维和表达都有惯性默认的默认模式,而落笔能逼你跳出来,重新看清自己到底在想什么、要说什么。
写作与思考2025 · 407 分 · 93 评4 条写作要点编辑精选写作就是思考
Writing is thinking
文章以“写作即思考”为题,讨论写作不只是把已有想法记录下来,而是帮助澄清、组织和推进思考的过程。
写作与思考2025 · 330 分 · 128 评4 条写作要点编辑精选