"Why Would You Want to Do That?"

本文讲述作者早年因想学习用Turbo Pascal编写Windows应用程序遭编程专家质疑。指出当被问‘为什么要那样做’,应回答‘想知道如何运作’。还对比不同编程语言,强调汇编语言能让人最接近机器,创作本书旨在培养对机器的好奇心和探索能力,本质是教人学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Introduction: "Why Would You Want to Do That?"
It was 1985, and I was in a chartered bus in New York City, heading for a press reception with a bunch
of other restless media egomaniacs. I was only beginning my media career (as technical editor for PC
Tech Journal) and my first book was still months in the future. I happened to be sitting next to an
established programming writer/guru, with whom I was impressed and to whom I was babbling about
one thing or another. I won't name him, as he's done a lot for the field, and will do a lot more before
he's through if he doesn't kill himself smoking first.
But I happened to let slip that I was a Turbo Pascal fanatic, and what I really wanted to do was learn
how to write Turbo Pascal programs that made use of the brand new Microsoft Windows user interface.
He wrinkled his nose and grimaced wryly, before speaking the Infamous Question:
"Why would you want to do that?"
I had never heard the question before (though I would hear it many times thereafter), and it took me
aback. Why? Because, well, because…I wanted to know how it worked.
"Heh. That's what C's for."
Further discussion got me nowhere in a Pascal direction. But some probing led me to understand that
you couldn't write Windows apps in Turbo Pascal. It was impossible. Or...the programming writer/guru
didn't know how. Maybe both. I never learned the truth. But I did learn the meaning of the Infamous
Question.
Note well: When somebody asks you, "Why would you want to do that?" what it really means is this:
"You've asked me how to do something that is either impossible using tools that I favor or completely
outside my experience, but I don't want to lose face by admitting it. So,...how 'bout those Blackhawks?"
I heard it again and again over the years:
Q: How can I set up a C string so that I can read its length without scanning it?
A: Why would you want to do that?
Q: How can I write an assembly language subroutine callable from Turbo Pascal?
A: Why would you want to do that?
Q: How can I write Windows apps in assembly language?
A: Why would you want to do that?
You get the idea. The answer to the Infamous Question is always the same, and if the weasels ever
ask it of you, snap back as quickly as possible: Because I want to know how it works.
That is a completely sufficient answer. It's the answer I've used every single time, except for one
occasion a considerable number of years ago, when I put forth that I wanted to write a book that taught
people how to program in assembly language as their first experience in programming.
Q: Good grief, why would you want to do that?
A: Because it's the best way there is to build the skills required to understand how all the rest of the
programming universe works.
Being a programmer is one thing above all else: It is understanding how things work. Learning to be a
programmer, furthermore, is almost entirely a process of learning how things work. This can be done at
various levels, depending on the tools you're working with. If you're programming in Visual Basic, you
have to understand how certain things work, but those things are by and large confined to Visual Basic
itself. A great deal of machinery is hidden by the layer that Visual Basic places between the
programmer and the computer. (The same is true of Delphi, Java, Perl, and many other very high-level
programming environments.) If you're using a C compiler, you're a lot closer to the machine, and you
see a lot more of that machinery-and must, therefore, understand how it works to be able to use it.
However, quite a bit remains hidden, even from the hardened C programmer. (Many C programmers
fool themselves into thinking they know way more than they actually do-and have the bad karma to be
pretty damned arrogant about it.)
If, on the other hand, you're working in assembly language, you're as close to the machine as you can
get. Assembly language hides nothing, and withholds no power. The flip side, of course, is that no
magical layer between you and the machine will absolve any ignorance and take care of things for you.
If you don't understand how something works, you're dead in the water-unless you know enough to be
able to figure it out on your own.
That's a key point: My goal in creating this book is not entirely to teach you assembly language per se.
If this book has a prime directive at all, it is to impart a certain disciplined curiosity about the machine,
along with some basic context from which you can begin to explore the machine at its lowest levels.
That, and the confidence to give it your best shot. This is difficult stuff, but it's nothing you can't master
given some concentration, patience, and the time it requires-which, I caution, may be considerable.
In truth, what I'm really teaching you is how to learn.

这是Jeff Duntemannd 在《Assembly Language Step-by-Step: Programming with DOS and Linux, Second Edition》中的一章的内容。

呵呵,我好象也常常问这样的问题,看来我也是真的不好意思承认自己的无知、、、

只有几次例外,如一个同事用了多个消息循环,另一个却喜欢在程序中create table与drop table、、、呵呵

Student: Good morning, Teacher. Teacher: Good morning, Student. How can I help you today? Student: I was wondering if you would take a gap year if you could. Teacher: That's an interesting question. I think it really depends on the individual's circumstances. If I had the opportunity, I might consider taking a gap year. Student: Why or why not? Teacher: Well, a gap year can offer a lot of benefits. It can provide a much-needed break from the rigors of academic life and allow one to gain valuable life experience. On the other hand, it can also be a financial burden and may delay one's academic and career goals. Student: If you did take a gap year, where would you go and how long would you stay there? Teacher: If I did take a gap year, I would love to travel to different countries and immerse myself in new cultures. I would probably stay abroad for around 6-12 months. Student: What would you do during your gap year? Teacher: During my gap year, I would like to volunteer and work on community service projects. I think it would be a great opportunity to give back to others and make a positive impact in the world. Additionally, I would like to take some language classes and learn new skills. Student: What would you hope to learn during your gap year? Teacher: During my gap year, I would hope to gain a greater appreciation for other cultures and ways of life. I think this type of travel and immersion experience can broaden one's perspective and increase one's understanding of the world. Additionally, I would hope to learn new skills and gain a deeper sense of personal fulfillment and purpose.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值