免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3271 | 回复: 15
打印 上一主题 下一主题

想学点perl写写程序,但不知道学习编程有什么好的方法! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-04 16:53 |只看该作者 |倒序浏览
想学点perl写写程序,但不知道学习编程有什么好的方法!
      各位有经验的讲讲可以么?

论坛徽章:
0
2 [报告]
发表于 2010-02-04 16:59 |只看该作者
er,最近怎么都是这种帖子呀?
OK let's forward this one: Five Ways You can Learn Programming Faster

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 possiblity 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.

论坛徽章:
0
3 [报告]
发表于 2010-02-04 17:00 |只看该作者
呵呵,菜鸟想找一种学习方法!请各位指教啊

论坛徽章:
0
4 [报告]
发表于 2010-02-04 17:51 |只看该作者
仙子版主的建议很好,人很热心。
新手学习了。

论坛徽章:
0
5 [报告]
发表于 2010-02-04 17:54 |只看该作者
推荐一本 perl24小时编程,一个下午看完前8章,你就可以干活了。。。

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
6 [报告]
发表于 2010-02-04 18:09 |只看该作者
推荐一本 perl24小时编程,一个下午看完前8章,你就可以干活了。。。
StephenHuu 发表于 2010-02-04 17:54

把冰箱打开,把大象装进去,再把冰箱门关上。

论坛徽章:
0
7 [报告]
发表于 2010-02-04 18:13 |只看该作者
把冰箱打开,把大象装进去,再把冰箱门关上。
flw 发表于 2010-02-04 18:09


我保证这只不是大象。。。

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
8 [报告]
发表于 2010-02-04 18:16 |只看该作者
我保证这只不是大象。。。
StephenHuu 发表于 2010-02-04 18:13

那我倒有个建议:花四个礼拜,看完大骆驼前 15 章,
然后这辈子就不用再学 Perl 了。


以上乃是本人真实经历。

论坛徽章:
0
9 [报告]
发表于 2010-02-04 18:20 |只看该作者
那我倒有个建议:花四个礼拜,看完大骆驼前 15 章,
然后这辈子就不用再学 Perl 了。


以上乃是本人 ...
flw 发表于 2010-02-04 18:16


我不想抬杠,不过你真的后来从来没有再看过任何perl有关的文档或书籍?

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
10 [报告]
发表于 2010-02-04 18:29 |只看该作者
我不想抬杠,不过你真的后来从来没有再看过任何perl有关的文档或书籍?
StephenHuu 发表于 2010-02-04 18:20

基本概念都是在那时候搞清楚的。
至于模块,和函数用法恰恰相反,不是这辈子都不用学了,而是这辈子都休想学完。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP