5 Ways You can Learn Programming Faster
5种方法提升程序设计学习效率
by Alex Allain
Learning to program isn't something you can do in an afternoon, but it doesn't
have to be a life's work,either.
There are lots of things you can do to make it easier on yourself when you are learning to program.
You already know about
The 5 Most Common Problems New Programmers Face--And How You Can Solve
Them.
程序设计不是通过一下午的学习就可以一蹴而就的,同样也不需要耗费你一生的时光。
当你学习程序设计的时候,你可以通过很多方法来使学习过程变得更简单。
相信你已经阅读过下面链接的文章: The 5 Most Common Problems New Programmers Face--And How You Can Solve Them.
Now, discover how to get the most out of your learning.
One common theme across many of these tips is:
现在,让我们来看看怎样让你的学习更有效。
在众多的方法之中最具代表性的观点是:
don't go too fast; get it right before moving on.
不要急功近利,在学习新的知识点前,要将遇到的疑问弄明白
When I was teaching C, there were always a few students who came into the class
knowing a bit about programming.
Inevitably, some of these students did great in the first few weeks only to fall further and further behind as the course went on.
Why? They went too fast through the introductory part of the course, thinking they knew it all--but they rarely did.
They knew some of the material, but not enough to have a strong grasp of the fundamentals.
在我教授C语言课程的时候,经常有些学生有编程的经验(他们懂得一点编程的知识)
可惜的是:一些学生在开始学习的时候兴趣高涨,但是随着学习的推进,慢慢的他们就失去了兴趣。
为什么呢? 因为他们“走”地太快,他们跳跃式的学习,以为自己已经知道所有该学习的内容——但是遗憾的是,他们不是。
他们学到了一些,但是他们没有充分的掌握基础知识。
At the same time, you must not stop making progress--you can go too slow as well as too fast.
Don't avoid a topic after you've mastered everything leading up to it.
By facing more challenging ideas, you'll help cement your grasp of the basics.
有时候,你不必停步——你应该慢嚼细咽,就像你阔步向前一样
不要忽略任何一个知识点(或者译:主题),即便你已经顺利的掌握了所有的知识
当面对具有挑战的主题时,你会从你掌握的基础知识中受益(这一句有点诡异,估计是俚语)
1. Look at the Example Code
1、学习源代码
Reading is usually about the words on the page, but learning to program is about code.
When you're first learning to program, you should make sure to look at, and try to understand, every example.
When I first learned to program, I would sometimes read the code examples before the text, and try to figure out what they did.
It doesn't always work, but it did force me to look
at the example very carefully, and it often helped make the writeups clearer.
If you want to see what sample code looks like, you can read this site's introductory
programming tutorial.
This tutorial spends a great deal of time talking about the sample code to help you work through exactly what the code does.
阅读通常是指阅读文章,但是对学习编程来说是指阅读源代码。
当你开始学习程序设计时,你应该能确保自己能看懂每一个源代码。
当我开始学习程序设计时,我习惯上在看文章内容之前阅读源代码,并且尝试理解代码的作用。
并不是每次我都能完全理解代码,但是这样做迫使我非常认真的阅读源代码,并且常常能使脉络清晰(译:writeups clearer 这个词估计是笔误)
如果你想看看源代码长的什么样,那么可以到这个链接看看:introductory programming tutorial.
这个指南花了大篇幅的笔墨来让你明白:如何理解代码的作用。
2. Don't Just Read Example Code--Run It
2、不要仅仅是阅读代码——编译并执行你的程序
But when you're reading a programming tutorial (or book), it's easy to look at
the sample code and say "I get it, I get it, that makes sense".
Of course, you might get it, but you might not get it, and you just don't know it.
There's
only one way to find out--do something with that code.
If you haven't already, get a compiler like Code::Blocks set up.
在阅读编程指南类的书籍时,当碰到简单的源代码时,学习者经常容易产生错觉: 我已经知道了,
当然,也许你真正的理解了,也许你没有理解,也许你并不知道他的本质。
这是只有一种方法来验证你是否理解了: 利用你看过的代码做点什么。(实践检验真理的唯一标准)
如果你还没有一个编译环境,那么还等什么,马上自己架构一个。
Then type the sample code into a compiler--if you type it, instead of
copying and pasting it,
you will really force yourself to go through everything that is there. Typing the code will force you to
pay attention to the details
of the syntax of the language--things like those funny semicolons that seem to go after every line.
Then compile it and run it. Make sure it does what you think it does.
当你有了自己的编译环境后,就可以尝试在你的编译环境输入源代码:如果你输入源代码,而不是简单的复制粘贴,
你将会真正的迫使你自己真正的理解所有的细节。输入代码可以使你注意编程语言的语法细节——这里有一个有趣的事情,似乎每一行后面都有一个分号
(译注:作者是C语言开发者)
输入完代码后那么就编译和运行它, 当然这个过程要确保你程序的输出就是你预想的结果。
Then change it. Software is the most easily
changed machinery on the planet.
You can experiment easily, try new things, see what happens;
the changes will happen almost immediately, and there is no risk of death or mayhem.
The easiest way to learn new language features is to take some code that works one way, and change it.
如果你的代码编译正确,并且可以得到正确的结果,那么尝试改变你的代码。软件(代码)是地球上最容易改变的事物了,
你能很容易的得到经验,尝试新的事物,并且很容易的看到将会发生什么;
代码的改变可以在输出结果中马上体现,并且这个过程没有任何导致死亡或者其他的伤害(译注:西方人比东方人幽默一点)
学习新的语言特性的最便捷的方法就是:输入代码,查看输出结果,改变代码,然后再查看改变代码后的输出结果。
3. Write your Own Code as Soon as Possible
3、 尽可能早的编写自己的代码
Once you understand something about the language--or even if you're still getting your head around it--
start writing sample programs that use it. Sometimes it's hard to find good ideas for what programs to write.
That's OK, you don't have to come up with every idea at the beginning.
You
can find some programming
challenges on this site.
You can also reimplement the examples from the book or tutorial you are
reading.
Try to do so without looking back at the sample code; it won't be as easy as it seems.
This technique can work especially well if you tweak the sample code.
If you can't think of a small program to write, but you have in mind a larger
program you want to implement, like a game,
you could start building small pieces that you can later use for a game.
Whether you use them later or not, you will get the same useful experience.
一旦你开始了解某种编程语言——甚至你还迷迷糊糊——那么就尽可能早的利用他来编写代码。有时候很难找到一种方法来说明怎么编写程序。
开始的时候,你没有必要等到掌握所有的东西后再编写代码。
你可以通过下面的链接获取一些代码示例: programming challenges
同样你也可以从你正在阅读的指南或者编程书籍上面获取一些代码示例。
尝试不参考代码示例编写一些代码,这并不像想象中的容易。
这种方法非常有效,特别是当你对示例代码纠结过一段时间(译注: 考来外国人,也懂的 “纠结” 这个词, tweak: 拧)。
如果你找不到小程序来写,但是你有实现大程序的想法(例如要实现一个游戏),你可以尝试写一些可以在你的大程序中可以使用的
小程序(译注:分治策略)。
无论以后你是否会使用者写小程序,你都会从编写这些程序代码的过程中积累经验。
4. Learn to Use a Debugger
4、学会使用一个调试工具
I already talked about the importance of debugging in
The 5 Most Common Problems New Programmers Face--And How You Can Solve Them.
But it
bears repeating; the sooner you learn good debugging techniques, easier it will
be to learn to program.
The first step in doing so is to learn how to use a
tool called a debugger,
which allows you to step through your code.
A debugger will allow you
to step line by line through a piece of code.
It will let you see the values of variables, and whether the code inside an if statement is executed.
我曾经下面的链接里面说过学会一个调试工具的重要性:The 5 Most Common Problems New Programmers Face--And How You Can Solve Them.
不断的重复让人难以忍受,但是掌握一种调试工具越快,学习编程就更容易。
首要要做的就是学会怎样使用调试器:Debugger,一种允许你逐步跟踪程序执行的工具。
调试器允许你一句一句的执行你的程序。
调试器允许你查看(监控):程序中定义变量的值,或者允许你查看一条IF子句里面的内容是否被执行过。
A debugger can help you quickly answer questions about what your code is doing.
int main() { int x; int y; if( x > 4 ) // <-- what is the value of x here? { y = 5; // <-- did this line of code execute? } }
调试器(译注:这里应该是泛指) 能使你快速的查看你的程序代码干了什么?
int main() { int x; int y; if( x > 4 ) // <-- what is the value of x here? 这个地方变量X的值是什么 { y = 5; // <-- did this line of code execute? 这条语句会执行吗? } }
A final word about debuggers: the first time you learn about a debugger,
it will take you longer to fix the problems with your code.
After the tenth or so bug, it will really start to pay off.
And believe me, you will have way more than ten bugs in your programming career.
对于调试器在多说一句:
当你第一次使用调试器的时候,它会使你花很长的时间来修正你的代码。
当你修正代码代码中十条bug或者更多的bug时,你会发现慢慢的你在Debugging的过程中获益。
相信我,在你的程序生涯中,你会遇到超过10条bug的。
I often saw students unwilling to use a debugger.
These students really made life hard on themselves, taking ages to find very simple bugs.
The sooner you learn to use a debugger, the sooner it will pay off.
我经常看到我的学生不愿意使用调试器,这些学生典型的给自己前进的道路设置障碍,他们花很长的时间找出代码中简单的错误。
越早学会用调试器,你会越早在调试的过程中提升自己的编程能力。
5. Seek out More Sources
5:学习更多的课程 (丰富自己的知识面)
If you don't understand something, there's a good possibility the way it was
explained just didn't click.
First, look for alternative explanations. The internet is filled with
information about programming,
and some explanations work better for different people; you might need pictures, someone else might not.
如果你不明白某些事,最有可能的情况就是有人已经在互联网上解释过了,但是你没有浏览到这个链接。
首先,寻求不同的解释。互联网上有很多的关于编程的信息,并且这些信息对不同的人提供的帮助不一样,你也许需要图片
来看的更清楚(译注: 传说中的 有图有真相), 也许其他人不需要多媒体信息就能理解。
There are also lots
of good books with detailed explanations.
But if that doesn't work, the easiest way to figure out where your
misunderstanding lies is to ask someone else.
有很多的书籍有详细的细节解释,但是如果所有的书籍都没有你想要的信息,那么最好的解决你心头疑问的方法就是找一个人问一下。
But try to go beyond saying, "I don't understand. Please explain." You're likely to get a link back to the same text you didn't understand.
Instead, rephrase your understanding of the text in your words. The more your question reveals about what you are thinking,
the easier it will be for a knowledgeable expert to answer it. Programmers sometimes have a reputation for being grumpy about answering questions,
but I think the reason is that they want to make progress in a conversation,and that requires both sides to put in effort.
If you ask a smart, detailed question that shows you are thinking, you will generally get good results.
但是在请教别人之前做点功课; 如果是简单的“我不懂,请给我解释一下”, 你最后可能得到的结果是: 别人给你一个你曾经看过的没有完全理解的链接,
最好的方法是: 在向人提问之前,先说说自己对链接的看法,你把自己对问题的认识描述的越清楚,就越容易使高手来回答你的问题。
程序员有时候会为了声望来回答你的问题,但是我想他们会答问题的原因是他们想在回答问题的过程中来提升自己。
这就要求问答的双方都付出自己的努力来解决问题。如果你的提问非常有水准、同时提供了足够多的细节,那么就证明你在思考,
当然就越可能获得满意的答案。
There are plenty of places you can go to ask questions.
You can always email me, or post on our message board, or ask an expert.
In the coming days, I'll be writing more about how to learn to program
effectively
有很多的地方可以提问:可以给我发邮件,或者在你的BBS发帖,或者询问专家
在接下来的时间里我会写更多的关于如何更有效学习编程的文章。
原文如下:
5 Ways You can Learn Programming Faster
by Alex Allain
Learning to program isn't something you can do in an afternoon, but it doesn't
have to be a life's work, either. There are
lots of things you can do to make it easier on yourself when you are learning
to program. You already know about
The 5 Most Common Problems New Programmers Face--And How You Can Solve
Them. Now, discover how to get the most out of your learning.
One common theme across many of these tips is:
don't go too
fast; get it right before moving on.
When I was teaching C, there were always a few students who came into the class
knowing a bit about programming. Inevitably, some of these students did great
in the first few weeks only to fall further and further behind as the course
went on. Why? They went too fast through the introductory part of the course,
thinking they knew it all--but they rarely did. They knew some of the
material, but not enough to have a strong grasp of the fundamentals.
At the same time, you must not stop making progress--you can go too slow as well as too fast. Don't avoid a topic after you've mastered everything leading up to it. By facing more challenging ideas, you'll help cement your grasp of the basics.
1. Look at the Example Code
Reading is usually about the words on the page, but learning to program is
about code. When you're first learning to program, you should make sure to
look at, and try to understand, every example. When I first learned to
program, I would sometimes read the code examples before the text, and try to
figure out what they did. It doesn't always work, but it did force me to look
at the example very carefully, and it often helped make the writeups clearer.
If you want to see what sample code looks like, you can read this site's introductory
programming tutorial. This tutorial spends a great deal of time
talking about the sample code to help you work through exactly what the code
does.
2. Don't Just Read Example Code--Run It
But when you're reading a programming tutorial (or book), it's easy to look at the
sample code and say "I get it, I get it, that makes sense". Of course, you
might get it, but you might not get it, and you just don't know it. There's
only one way to find out--do something with that code.
If you haven't already, get a compiler like Code::Blocks set up.
Then type the sample code into a compiler--if you type it, instead of
copying and pasting it, you will really force yourself to go through everything
that is there. Typing the code will force you to pay attention to the details
of the syntax of the language--things like those funny semicolons that seem to go after every line.
Then compile it and run it. Make sure it does what you think it does.
Then change it. Software is the most easily
changed machinery on the planet. You can experiment easily, try new things,
see what happens; the changes will happen almost immediately, and there is no
risk of death or mayhem. The easiest way to learn new language features is to
take some code that works one way, and change it.
3. Write your Own Code as Soon as Possible
Once you understand something about the language--or even if you're
still
getting your head around it--start writing sample programs that use it.
Sometimes it's hard to find good ideas for what programs to write.
That's OK, you don't have to come up with every idea at the beginning.
You
can find some programming
challenges on this site.
You can also reimplement the examples from the book or tutorial you are
reading. Try to do so without looking back at the sample code; it won't be as
easy as it seems. This technique can work especially well if you tweak the sample code.
If you can't think of a small program to write, but you have in mind a larger
program you want to implement, like a game, you could start building small
pieces that you can later use for a game. Whether you use them later or not,
you will get the same useful experience.
4. Learn to Use a Debugger
I already talked about the importance of debugging in The 5 Most
Common Problems New Programmers Face--And How You Can Solve Them. But it
bears repeating; the sooner you learn good debugging techniques, easier it will
be to learn to program.
The first step in doing so is to learn how to use a
tool called a debugger,
which allows you to step through your code.
A debugger will allow you
to step line by line through a piece of code. It will let you see the values
of variables, and whether the code inside an if statement is executed.
A debugger can help you quickly answer questions about what your code is doing.
int main() { int x; int y; if( x > 4 ) // <-- what is the value of x here? { y = 5; // <-- did this line of code execute? } }
A final word about debuggers: the first time you learn about a debugger, it
will take you longer to fix the problems with your code. After the tenth or so
bug, it will really start to pay off. And believe me, you will have way more
than ten bugs in your programming career.
I often saw students unwilling to use a debugger. These students really made
life hard on themselves, taking ages to find very simple bugs. The sooner you
learn to use a debugger, the sooner it will pay off.
5. Seek out More Sources
If you don't understand something, there's a good possibility the way it was
explained just didn't click.
First, look for alternative explanations. The internet is filled with
information about programming, and some explanations work better for different
people; you might need pictures, someone else might not. There are also lots
of good books with detailed explanations.
But if that doesn't work, the easiest way to figure out where your
misunderstanding lies is to ask someone else. But try to go beyond saying, "I
don't understand. Please explain." You're likely to get a link back to the
same text you didn't understand. Instead, rephrase your understanding of the
text in your words. The more your question reveals about what you are
thinking, the easier it will be for a knowledgeable expert to answer it.
Programmers sometimes have a reputation for being grumpy about answering
questions, but I think the reason is that they want to make progress in
a conversation, and that requires both sides to put in effort. If you ask a
smart, detailed question that shows you are thinking, you will generally get
good results.
There are plenty of places you can go to ask questions. You can always email me, or post on our message board, or ask an expert.
In the coming days, I'll be writing more about how to learn to program
effectively.
翻译文如下:
5种方法提升程序设计学习效率
程序设计不是通过一下午的学习就可以一蹴而就的,同样也不需要耗费你一生的时光。
当你学习程序设计的时候,你可以通过很多方法来使学习过程变得更简单。
相信你已经阅读过下面链接的文章: The 5 Most Common Problems New Programmers Face--And How You Can Solve Them.
现在,让我们来看看怎样让你的学习更有效。
在众多的方法之中最具代表性的观点是:
不要急功近利,在学习新的知识点前,要将遇到的疑问弄明白
在我教授C语言课程的时候,经常有些学生有编程的经验(他们懂得一点编程的知识)
可惜的是:一些学生在开始学习的时候兴趣高涨,但是随着学习的推进,慢慢的他们就失去了兴趣。
为什么呢? 因为他们“走”地太快,他们跳跃式的学习,以为自己已经知道所有该学习的内容——但是遗憾的是,他们不是。
他们学到了一些,但是他们没有充分的掌握基础知识。
有时候,你不必停步——你应该慢嚼细咽,就像你阔步向前一样
不要忽略任何一个知识点(或者译:主题),即便你已经顺利的掌握了所有的知识
当面对具有挑战的主题时,你会从你掌握的基础知识中受益(这一句有点诡异,估计是俚语)
1、阅读源代码
阅读通常是指阅读文章,但是对学习编程来说是指阅读源代码。
当你开始学习程序设计时,你应该能确保自己能看懂每一个源代码。
当我开始学习程序设计时,我习惯上在看文章内容之前阅读源代码,并且尝试理解代码的作用。
并不是每次我都能完全理解代码,但是这样做迫使我非常认真的阅读源代码,并且常常能使脉络清晰(译:writeups clearer 这个词估计是笔误)
如果你想看看源代码长的什么样,那么可以到这个链接看看:introductory programming tutorial.
这个指南花了大篇幅的笔墨来让你明白:如何理解代码的作用。
2、不要仅仅是阅读代码——编译并执行你的程序
在阅读编程指南类的书籍时,当碰到简单的源代码时,学习者经常容易产生错觉: 我已经知道了,
当然,也许你真正的理解了,也许你没有理解,也许你并不知道他的本质。
这是只有一种方法来验证你是否理解了: 利用你看过的代码做点什么。(实践检验真理的唯一标准)
如果你还没有一个编译环境,那么还等什么,马上自己架构一个。
当你有了自己的编译环境后,就可以尝试在你的编译环境输入源代码:如果你输入源代码,而不是简单的复制粘贴,
你将会真正的迫使你自己真正的理解所有的细节。输入代码可以使你注意编程语言的语法细节——这里有一个有趣的事情,似乎每一行后面都有一个分号
(译注:作者是C语言开发者)
输入完代码后那么就编译和运行它, 当然这个过程要确保你程序的输出就是你预想的结果。
如果你的代码编译正确,并且可以得到正确的结果,那么尝试改变你的代码。软件(代码)是地球上最容易改变的事物了,
你能很容易的得到经验,尝试新的事物,并且很容易的看到将会发生什么;
代码的改变可以在输出结果中马上体现,并且这个过程没有任何导致死亡或者其他的伤害(译注:西方人比东方人幽默一点)
学习新的语言特性的最便捷的方法就是:输入代码,查看输出结果,改变代码,然后再查看改变代码后的输出结果。
3、尽可能早的编写自己的代码
一旦你开始了解某种编程语言——甚至你还迷迷糊糊——那么就尽可能早的利用他来编写代码。有时候很难找到一种方法来说明怎么编写程序。
开始的时候,你没有必要等到掌握所有的东西后再编写代码。
你可以通过下面的链接获取一些代码示例: programming challenges
同样你也可以从你正在阅读的指南或者编程书籍上面获取一些代码示例。
尝试不参考代码示例编写一些代码,这并不像想象中的容易。
这种方法非常有效,特别是当你对示例代码纠结过一段时间(译注: 考来外国人,也懂的 “纠结” 这个词, tweak: 拧)。
如果你找不到小程序来写,但是你有实现大程序的想法(例如要实现一个游戏),你可以尝试写一些可以在你的大程序中可以使用的
小程序(译注:分治策略)。
无论以后你是否会使用者写小程序,你都会从编写这些程序代码的过程中积累经验。
4、学会使用一个调试工具
我曾经下面的链接里面说过学会一个调试工具的重要性:The 5 Most Common Problems New Programmers Face--And How You Can Solve Them.
不断的重复让人难以忍受,但是掌握一种调试工具越快,学习编程就更容易。
首要要做的就是学会怎样使用调试器:Debugger,一种允许你逐步跟踪程序执行的工具。
调试器允许你一句一句的执行你的程序。
调试器允许你查看(监控):程序中定义变量的值,或者允许你查看一条IF子句里面的内容是否被执行过。
调试器(译注:这里应该是泛指) 能使你快速的查看你的程序代码干了什么?
int main() { int x; int y; if( x > 4 ) // <-- what is the value of x here? 这个地方变量X的值是什么 { y = 5; // <-- did this line of code execute? 这条语句会执行吗? } }
对于调试器在多说一句:
当你第一次使用调试器的时候,它会使你花很长的时间来修正你的代码。
当你修正代码代码中十条bug或者更多的bug时,你会发现慢慢的你在Debugging的过程中获益。
相信我,在你的程序生涯中,你会遇到超过10条bug的。
我经常看到我的学生不愿意使用调试器,这些学生典型的给自己前进的道路设置障碍,他们花很长的时间找出代码中简单的错误。
越早学会用调试器,你会越早在调试的过程中提升自己的编程能力。
5:学习更多的课程 (丰富自己的知识面)
如果你不明白某些事,最有可能的情况就是有人已经在互联网上解释过了,但是你没有浏览到这个链接。
首先,寻求不同的解释。互联网上有很多的关于编程的信息,并且这些信息对不同的人提供的帮助不一样,你也许需要图片
来看的更清楚(译注: 传说中的 有图有真相), 也许其他人不需要多媒体信息就能理解。
有很多的书籍有详细的细节解释,但是如果所有的书籍都没有你想要的信息,那么最好的解决你心头疑问的方法就是找一个人问一下。
但是在请教别人之前做点功课; 如果是简单的“我不懂,请给我解释一下”, 你最后可能得到的结果是: 别人给你一个你曾经看过的没有完全理解的链接,
最好的方法是: 在向人提问之前,先说说自己对链接的看法,你把自己对问题的认识描述的越清楚,就越容易使高手来回答你的问题。
程序员有时候会为了声望来回答你的问题,但是我想他们会答问题的原因是他们想在回答问题的过程中来提升自己。
这就要求问答的双方都付出自己的努力来解决问题。如果你的提问非常有水准、同时提供了足够多的细节,那么就证明你在思考,
当然就越可能获得满意的答案。
有很多的地方可以提问:可以给我发邮件,或者在你的BBS发帖,或者询问专家
在接下来的时间里我会写更多的关于如何更有效学习编程的文章。
哈哈,这篇文章是从一个网站看到的,
第一次翻译文章,很多语句都不知道怎么遣词造句, 只能直译。
文章原创归原作者,我仅翻译一下,虽然我认同某些观点,但不代表我个人观点.
翻译的句子有不对的地方,欢迎各位斧正...........................
现在老后悔为什么当初学英语的时候没有在努力点。
哎,有点晚了,也有点累了, 明天还要上班,不废话,睡觉了...............