本文共 6889 字,大约阅读时间需要 22 分钟。
Imagine for a moment that learning programming is like climbing a mountain. The start of the climb is very steep, and most people end up falling back down. But a fair number of individuals get past this initial slope. They finish an online course or get half-way through an ebook or just generally mess around enough to get the basics down. And then they start to get bored. They don’t want to do another course. They didn’t start this journey just for the experience, despite what conventional wisdom might advise. They want to do something that’s actually useful or meaningful, something of their own creation. And so after ascending this initial learning curve they find not a second slope, but a chasm. This is the gap between what they had to do to learn the basics and what it takes to actually do something novel, to do their first programming project.
想象一下,学习编程就像爬山一样。 攀爬的开始非常陡峭,大多数人最终跌倒了。 但是,相当多的人超过了这个初始坡度。 他们完成了在线课程,或者完成了电子书的学习,或者只是为了使基础知识变得足够混乱。 然后他们开始变得无聊。 他们不想再做其他课程。 尽管传统的智慧可能会建议他们,但他们并不是仅仅出于体验而开始这一旅程。 他们想做一些实际上有用或有意义的事情,这是他们自己创造的。 因此,在提升了此初始学习曲线之后,他们发现的不是第二个斜率,而是一个鸿沟。 这是他们必须学习基础知识和实际做一些新颖的东西,完成他们的第一个编程项目所需要的差距。
Jumping from something like a Codecademy course to a full-on solo project can be extremely intimidating. I mean, how can you possibly go from formatting strings and iterating through dictionaries to developing games or programming conversational sex-bots? It almost defies intuition that this would be possible. But as it turns out, the chasm is often narrower than it seems. Let’s see why.
从Codecademy课程之类的课程过渡到一个完整的独奏项目可能会非常令人生畏。 我的意思是,从格式化字符串,遍历字典到开发游戏或编写对话性爱程序,您怎么可能呢? 直觉几乎无视这种可能性。 但事实证明,鸿沟通常比看起来狭窄。 让我们看看为什么。
Take my own first programming project as an example. I wanted to write a program that could compose music. At first glance, this seems pretty ambitious, and frankly I had a lot of doubts. “This sounds too complicated, I’m too busy for this, I’ve never done anything like this before, what do I know about composition anyways, do I really think I can make a computer do what only talented humans can, maybe I’ll just take another course, yeah that’s right I think I saw something on Coursera…”
以我自己的第一个编程项目为例。 我想写一个可以创作音乐的程序。 乍一看,这似乎很雄心勃勃,坦率地说,我有很多疑问。 “这听起来太复杂了,我太忙了,我以前从未做过类似的事情,无论如何我都对合成有什么了解,我真的认为我可以使一台计算机做到只有有才华的人才能做的事情,也许我“我会再选一门课程,是的,我想我在Coursera上看到了什么……”
Whoa, let’s stop right there. There were two big problems with this line of thinking. First, my sights were set way too high. I psyched myself out by thinking I had to make something impressive and world-class. Second, I assumed I had a good idea of how difficult the project was going to be, when the truth is that unless you’ve done similar projects in the past, you can’t really know how rough the going will get just from sitting in your armchair.
哇,让我们停在那儿。 这种思路有两个大问题。 首先,我的视野太高了。 我以为自己必须做出令人印象深刻且世界一流的东西而心烦意乱。 其次,我以为我对项目的难度有个好主意,事实是,除非您过去做过类似的项目,否则您真的不知道坐下来会遇到多大的麻烦在你的扶手椅上。
The solutions? First, I revised my expectations. “I don’t have to make something world-class, just something that makes unique, vaguely-musical noise on command.” Much better. My dreams of building a Chopin AI can wait. Second, instead of sitting there making more excuses, I identified what the first, easiest problem was that I could try to solve. The lowest-hanging fruit. So instead of worrying about the whole entire hairy project, I was able to focus on one specific, actionable thing: making my computer make noise. Here’s what I came up with (in Python 2 at the time):
解决办法? 首先,我修改了期望值。 “我不必制造出世界一流的产品,而只需要发出独特的,含糊不清的音乐声音就可以了。” 好多了。 创建肖邦AI的梦想可以等待。 其次,我没有坐在那里找更多借口,而是确定了我可以尝试解决的第一个最简单的问题。 挂得最少的水果。 因此,我不必担心整个繁琐的项目,而是可以专注于一件具体的,可行的事情:让计算机发出噪音。 这是我想出的(当时是在Python 2中):
import winsoundfreq = 440 # hertzdur = 500 # millisecondswinsound.Beep(freq,dur)
WOW! What an earth-shattering achievement (taken straight from StackOverflow), yes yes I know, no need to congratulate me. But honestly at the time it was a breakthrough. If I could make my computer make sounds with code, and if I could have success with the very first thing I tackled on this project, what’s to stop me from completing the rest? Don’t underestimate the importance of quick wins, especially at the outset.
哇! 真是了不起的成就(直接从StackOverflow取得),是的,我知道,不需要祝贺我。 但说实话,那是一个突破。 如果我可以用代码使计算机发声,并且如果我在该项目中解决的第一件事可以成功,那么是什么使我无法完成其余工作? 不要低估快速获胜的重要性,尤其是在一开始的时候。
So great, I could make beeps and boops at will, but it turned out that winsound wasn’t of much use for more complicated musical arrangements. Turning to Google and searching for something like “python music packages”, I soon found all kinds of promising packages. I probably tested out about 10 or 15 until I found one that seemed workable, but from there it was just a matter of methodically solving one specific problem after another until, lo and behold, I actually had a working program. Its compositions still have yet to go platinum (they sound like a mechanical nightmare), but it was still pretty cool to press a button and listen to a totally unique, never before-heard piece of music (even if it makes my ears bleed), especially with only a couple hundred lines of code!
太好了,我可以随意发出哔哔声,但是事实证明,对于复杂的音乐编排,温莎音并没有多大用处。 转向Google并搜索“ python音乐包”之类的东西,我很快发现了各种各样有前途的包。 我大概测试了10到15个,直到发现一个似乎可行的方法,但是从那开始,有条不紊地有条不紊地解决一个特定的问题,直到我发现实际上有一个工作程序为止。 它的音乐创作还没有达到白金级的效果(听起来像是一场机械噩梦),但是按下按钮并聆听完全独特,从未听过的音乐仍然很酷(即使它让我的耳朵流血了) ,尤其是只有几百行代码!
So in my experience, this is the general process for beginner-to-intermediate solo projects, not necessarily in this order:
因此,以我的经验,这是初学者到中级独奏项目的一般过程,不一定按此顺序进行:
Now this is certainly a simplified and generic list. But that’s basically all there is to it, particularly at the beginner stages. There’s no quantum-mechanical equations to derive. No impenetrable Matrix-like screens of flowing 0’s and 1’s to interpret. Just like if you were drawing a picture, composing a piece of music, or solving a mystery, you just need to keep putting one piece of the puzzle together after another until it’s finished.
现在,这肯定是一个简化的通用列表。 但这基本上就是全部,尤其是在初学者阶段。 没有要导出的量子力学方程。 没有难以解释的流动0和1的类似矩阵的屏幕。 就像您正在绘制图片,创作音乐或解决谜题一样,您只需要不断将一个难题拼凑在一起,直到完成为止。
翻译自:
转载地址:http://geqwd.baihongyu.com/