Failing To See the Big Picture – Mistakes we make when learning programming
作者: 刘未鹏 / 5699次阅读 时间: 2008年3月03日
来源: 刘未鹏 | MIND HACKS 标签: 学习方法
www.psychspace.com心理学空间网

Failing To See the Big Picture – Mistakes we make when learning programming

心理学空间 z8T2rz @q1EX

Let’s start with an obvious fact:

xO-bOT0K0
心理学空间$cw}0A P QV(Dxt

The Inconvenient Human Nature, #1
t t"ug(D@1}?0
People are inherently more easily attracted by “interesting” (as opposed to “mundane”) things. (We will define “interesting” in the later parts)

]?/gEIs0

o(@u*|3@\-o0What can we derive from this simple axiom?

)Z6p.Q#Z/H6|8x0心理学空间F+^8{e!S4lw

A lot of things. But since we’re talking about learning programming, we shall focus mainly on the implications it has for how we learn programming.心理学空间yy8{#v UjuI

心理学空间#[i4uH.i

Programming, the interesting and the mundane心理学空间QV3d#RPXfr

心理学空间@ eX2s2yb

The Interesting

yi9]d:LLR9^!_0

0{)ap9H eq6yG,~hT0What was the first thing that struck you when you first learned how to program? Wasn’t it the simple fact that you could order a computer to do stuff by simply typing a bunch of characters (thinking of the “hello world” program that we all have written)? But what happened then? You (hopefully) would learn the things that happened under the hood and drove your programs, which leads us to the first point:

o1Z"_:mcs6a0
心理学空间d5]^ sn8p-nA-e H

If it’s something under the hood, it’s interesting (therefore attracts people).

k6|9`T Hj0
心理学空间T`+Rk"NG*{&QX _x

People are always curious about the forces behind the phenomenons in nature since the dawn of human civilization. There’s a need for people to seek the reason why something happened. We call it the desire to understand.

L`:Nn9P&d3D.t^!C0

\gC2x:K A"i$O0After you’ve learned how to hack up a program, and the reason why your program works all the way down to the bit level. What, then, would be the next thing you do? You write programs, and in so doing discover more and more features of your programming language, which means you get more and more familiar with your language and you start to notice the sorts of things it can do conveniently and those it can’t. That when language tricks step into the picture. Language tricks are interesting in that they enable you to do something you usually can’t do. Human beings are born problem solvers, we like solving problems just as much as we like seek out the deep reasons why stuff works. But sadly we’re also adept problem creators.

+Q)Y a(QK3h0

wK5xa/z [7Y&z0In program language sense, the problems of which we seek for solutions are also the ones created by us. For example, there has recently been a remarked theory suggesting that design patterns are missing language features. First we create a language that – of course – has some drawbacks which we then use language tricks (such as design patterns) to overcome, but as time goes by, we would get to a point where all those kinds of patterns aren’t wealth anymore but instead turn into pure burdens, which is when we build them into the language. However, by solving the problems created by the previous language, we often create our own new problems. For example, there’s always this “DSL & GPL” (where GPL means general-purpose language) debate. On the one hand, building domain specific features into a language has the obvious advantage that it would be a lot more convenient for programmers to use when faced with domain-specific programming tasks, but on the other hand it would also limit the usage of the language, thus making the whole set of runtime system only accessable by itself (yeah, of course I know there’s inter-language operation, but that’s still another additional step don’t you think?). As to GPLs, the main advantage of them is to use a single runtime system to serve theoretically unlimited application areas. This isn’t without compromises, either. The main compromise is that when faced with domain-specific problems, a GPL only makes for a second-class language. That’s why Microsoft “invented” the CLR system; that’s also why Martin Fowler started advocating the so-calledLanguage-Oriented Programming.心理学空间~c9k*|]y

4u(c0N?bO"t0So, to sum up, we created all kinds of language abstractions to make programming easier. But, as it always has been, by solving one problem (programming convenience) we create other ones. Our language will no doubt have many drawbacks, that is, ones that make certain programming tasks harder to do. That’s where language tricks step in andsteal our focuses(I guess you all have a huge stack of language “techniques” books, right?). If you don’t understand what I’m saying, please take a look at any suggested “classic C++ books” list.

u;k"J5j)^0

"A7Uep-G%D(~0c0However, why on earth do we have to learn those tricks? We don’t, actually. But we tend to. Because:心理学空间 ryR9OILV4I

t9F_Ya$l-h_0We’re born problem solvers, we like solving problems; problems are interesting, even if they’re created by ourselves.

6S_i ZmD#J0

`]$PX3kF8~gph@0So, what happens after that? We learn new “techniques”. By “techniques”, I mean literally dozens of libraries, frameworks, APIs, and several new languages dubbed “the next big thing” (whether or not they say that explicitly). Again, why do we have to learn these? We don’t, really. We can learn them on an as-needed basis. One of the main reasons we’re attracted to them is because:

1}Yp5E p_D9a0
心理学空间6xf:Z3s&`2hfB1HRE

We like new stuff. If it’s new, it’s interesting.

&RO2q } l7a;_0

n5g9|Wu\|#z0Another reason is that we like tojump on the bandwagon.心理学空间)V@*FJ~P

,K~#uJF0The Inconvenient Human Nature, #2
uq_ U.u@w$H gx0Jumping-on-the-bandwagon
: If everyone is doing it, so should I.
心理学空间w7^`.s2@GXZ3x

心理学空间5ueA_2Q;zEE!p9SD

Not only do corporations use this strategy to induce us, we do it ourselves, that is, we create our own bandwagon. When some new language or technique comes out, we often get so excited that we blind ourselves to the problems it has; we’re blinded by the halo created by its featured features. We often, as a result, regard it as a panacea. We start eagerly to learn it. Programmers are smart animals, probably too smart. They always yearn for new stuff (check out what’s been discussed on the major programming forums and you will know what I’m saying), just like beasts hungering for blood. You walk around on the programming forums, you see thousands and thousands of technical details; it’s an endless job learning all those, but programmers love that.

l"S%V b"y^o0

'@3guL*} C)AXf0The Mundane

:\:J6@~-}0

OHlwLx#B0On the other hand, what do (most) programmers not love? Principles, be it coding principles in the small (e.g. “always give variables meaningful names”) or development principles in the large (e.g. “write  tests before you write the actual code”). They’re just dull. They’re not tricky; they’re not weird; they’re not challenging. We can’t show the world how smart we are by complying with some silly rules. What we do love is writing some insanely tricky code orusing some dazzling patterns that nobody else has a clue what we’re doing (or everybody knows what we’re doing).心理学空间6M9G"j B0F'S0^

心理学空间3C,D-iS`Rj

Right?

:T*q,O7j?&D0心理学空间$\G \B#TJXz8B

The Self-handicapped Programmers心理学空间dL c1a3\ bWm

心理学空间O*c1Mv}4Z1c UQ M6e

On the one hand, programmers are learning too fast, and learning too much (see above). On the other hand, there’re always times when we need to learn new things.

[[(y{9vH x0心理学空间] p'\ ge+K#T/p

There actually are several kinds of human natures that can hinder one from learning new things. The  one related to what we’re getting at is:

'OvY8Xt0

6h4OM|X,a#m0The Inconvenient Human Nature, #3
gN]4h/qS!s0Self-serving bias
: We love what we’re doing, or who we’re; we dislike all the things that counter it.
心理学空间m5s-r.W R%j*gX_6v&`

LA~;r6kD{${0Admit it or not, we’ve all been through this. After we get familiar enough with some language orplatform, the self-serving bias will start to affect what we like (and learn) and what we dislike (and won’t learn). Language debates are all too common in programming community. By blinding ourselves to the disadvantages of our languages or platforms and to the advantages of other languages or platforms, we limit our access to new techniques and ideas. In a sense, we limit our potentials.心理学空间|w2tZ k H,XD@3s

心理学空间x4I]Slg&s

Conclusion心理学空间Xv%np\P6j6O

9zj"p(jTF bL6P0Most of the times, we’re learning just a little too much. We’re attracted to interesting stuff like amoth to a flame. Or oftentimes we just learn what everybody else around us is learning or what we’re  told to learn, not know why we should learn it. Fact is, however, after we’ve grasped the essential knowledge, other stuff can just be learned on an as-needed basis. Don’t fall into technical details unless they’re essential or needed right away. There’s just unlimited number of details to follow in this area; you can put your time to something more useful (learning the essentials, learning the ideas, or even just another language).

e8c#xRcOb9a0心理学空间j4RnVT lV+J/J

On the other hand, however, we’re learning too little. We blind ourselves to the really importantsubjects just because they look dull. Tests? That’s like wearing condoms before having sex. Refactoring? Why do we have to do something that’s not going to generate new functionalities and not  shinny at all? Defensive Programming? No thanks, I know what I’m doing here. API Design? Oh-Man, it’s just too darn hard to consider how somebody else would be using my code when I’m writing the splendid implementations. New Languages? What… R U saying that mine is not good enough? Did U NOT see how I can bend the language to do whatever the heck I want it to do?

H.GRQ8}Q'F5s&Hf0

wo7t5?%D*Vf'n h0

cz |)t1I't#pl0
www.psychspace.com心理学空间网
TAG: 学习方法
«数学之美番外篇:进化论中的概率论 刘未鹏
《刘未鹏》
阅读与思考»

 刘未鹏

兴趣: 人工智能、机器学习、认知科学、神经科学、心理学、数学
刘未鹏 | MIND HACKS 思维改变生活http://mindhacks.cn/