Current location - Recipe Complete Network - Complete cookbook - How to learn programming from scratch?
How to learn programming from scratch?
Think about your goals before learning programming, and the road will be clearer with the ultimate goal. So, what do you want to write? Website? Games? IOS or Android app? Or do you want to automate some boring tasks and let yourself have more time to see the scenery outside the window? Maybe you just want to be more competitive in employment and find a good job. These are valuable goals, and they are part of your motivation to learn programming. Without driving force, people can't go far in the long learning journey that is slightly boring.

Don't impulse.

Badprogrammingiseasy。 Eventdummiescanlearninit21day. Good programming requires thinking, but everyone can experience the extreme satisfaction that comes with it.

Whether online or offline, bookstores are full of crash books such as "2 1 day learning Java", which promises to let you learn related technologies in a short time. MatthiasFelleisen clearly pointed out this trend of "collapse" in his book How to Design Programs, the second edition, and made the above irony.

The so-called "shortcut" or "silver bullet" does not exist. A wise man said that it takes 65,438+00 years or 65,438+00,000 hours to master a thing, which is China's "Sharpen a Sword in Ten Years", so don't worry, you won't make a contribution.

Cultivate interest

The best programmers are not because they expect togetpaidorgetadulationbythepublic, but because it is funtoprogram.

_LinusTorvalds

Addicted to programming, programming is for interest. Interest is an inexhaustible source of motivation. Make this feeling interesting so that you can put it into your 10/10000 hours of programming time. Programming is very interesting, and that is the fun of exploration. That's the joy of creation. It's interesting to see your work displayed on the screen. Interestingly, some people are surprised by your code. It's interesting that someone praises your products in public, neighbors use your products and discuss your products in the media. Programming should be very interesting, if not, find out the problem that makes programming boring and then solve it.

Here are two big pits suitable for beginners:

If beginners only touch the pre-built "engines and components" (without understanding and thinking about their construction principles), this will seriously limit their ability to build these things in the future, and they will have no way to start when diagnosing and solving problems.

The second pit is not as obvious as the first pit: the naive "holism" method sometimes seems to be very effective, somewhat hidden and misleading, but after one or two years (maybe not so long), when you go far on the learning road, you will have great psychological obstacles if you try to "make up the foundation" again. You should abandon the narrow concept before and move forward patiently, which is much more difficult than learning the basic knowledge when you first get started.

But you can't go too far and fall into the pit of reductionism. You just want to make a grand theory when you get started. This will not only lead to the danger of everything becoming empty talk, but also make you lose motivation. This situation often happens to students majoring in computer science.

To better understand, learning programming can be likened to learning cooking: you bought some books about recipes in order to cook well. If you just want to cook for your family, it will be a good idea. Repeat the steps in the recipe and you can make good dishes. But if you have bigger ambitions and really want to show off in front of your friends, cook some unique foods, or even become a "chef", you must understand the thoughts of the masters behind these recipes. But if your only job every day is to read those heavy theoretical books, because of lack of practice, you will only become a bad cook, or even never become a cook, because after reading books for a few days, you will give up learning cooking because of boredom.

In a word, programming is the link between theory and practice, and it is a field where computer science and computer application technology blend. The correct programming learning method should be: through top-down exploration and project practice, get programming intuition and driving force; In the process of laying the foundation from bottom to top, the most important general methods are obtained and the understanding of programming ideas is consolidated.

As a beginner, we should give priority to the latter and supplement the former.

arouse

"What language should I learn to program? This is often the first question a novice asks, but it is a wrong question. Your first question should be "What constitutes the basis of programming learning"?

There are three key parts at the bottom of the programming knowledge pyramid:

Algorithm ideas: for example, how to find the largest number in a group? First you have to have a maxSoFar variable, and then for each number,

Grammar: How to express these algorithms in programming language so that computers can understand them?

System Foundation: Why can a thread never end while( 1)? Why int * foo () {intx = 0; Return to & ampx;; } Not feasible?

For beginners in the primary stage, it will be difficult and boring to choose C as the first language, because they are forced to learn these three parts at the same time, and it will take a lot of time to make something.

Therefore, in order to minimize "grammar" and "system foundation", it is suggested to learn Python as the first language. Although Python is friendly to beginners, it doesn't mean that it is just a "toy", and it can also be seen in large-scale projects. After you are familiar with Python, learning C language is a good choice: learning C language will help you think from a perspective close to the bottom, and it will also help you understand some principles at the operating system level in the future. If you just want to be an ordinary (mediocre) developer, you don't have to learn.

The following is a reference guide to the enlightenment stage. When finished, you will build an overall framework in your mind to help you explore from top to bottom.

Complete the Python part of Codecademy. This is just the warm-up part, so finish it as soon as possible, because you will always be in the browser, and you won't learn how to build a development environment. You don't know where to start, even if you just want to do a small project.

Complete MIT6.00. 1x (China culture) (if English is not enough, complete MIT open class: Introduction to Computer Science and Programming). Large-scale open network course is an effective way to learn programming. Although the teaching language of this course is Python, as an excellent introductory course, it emphasizes learning important concepts and paradigms in the field of computer science, not just teaching you a specific language. If you are not an ordinary student, this can broaden your horizons when you study by yourself; Course content: computing concepts, python programming language, some simple data structures and algorithms, testing and debugging. Incidental tasks:

Complete Python core programming

Complete HarvardCS50 (if you fail English: complete the open course of Harvard University: Computer Science CS50). It is also an introductory course, but this course is a supplement to the MIT introductory course. The teaching language involves C, PHP, JavaScript+SQL, HTML+CSS. The breadth and depth of the content are reasonable, and you can learn the latest scientific and technological achievements, which can stimulate your interest in learning computers. Incidental tasks:

The mystery of reading coding

Complete "C Language Programming"

[Optional] If your goal is to be a hacker: Please read The Light of the Hacker.

PS: If the object of education is still children, the following resources will be very helpful:

5-8 years old: Turtle Academy

8- 12 years old: PythonforKids

/kloc-over 0/2 years old: MITScratch or KhanAcademy.

Elementary course

After the end of the enlightenment stage, beginners have accumulated a certain amount of code and have a certain understanding of programming. At this time, you may want to learn a specific technology, such as Web development, Android development, iOS development and so on. You can try to do something as simple as possible, give yourself some positive feedback and supplement your motivation. But remember not to delve into it, these technologies have countless details, and you will have time to learn in the future; Similarly, don't go too far into the specific framework and language at this time. It's time to learn the general basics of computer science. Don't try to take shortcuts, learn what you want to learn now, which is doomed to failure.

So what should we do at the beginning? What you need to do at this time is to reflect on the program you wrote and think about why the program should be designed like this. Thinking about how to write a better program. Try to explore and understand the essence of programming: using computers to solve problems.

Imagine this:

X= time to think about the solution, that is, the "problem solving" section.

Y= the time taken to execute the code, that is, the "using the computer" section.

Programming ability = f (x, y) (x >; y)

If you want to improve your programming ability, you must optimize x, y and function F(X, y). Few books can pay attention to these three points at the same time, but one book has done it-Structured Interpretation of Computer Programs (SICP), which shows you the direction of these three variables. Before reading SICP, you may be able to solve a simple problem by calling several functions. But after reading SICP, you will learn how to abstract and decompose problems, so as to deal with more complex and huge problems. This is a huge leap in programming ability, which will fundamentally change the way you think about problems and solve them with code. In addition, the teaching language of SICP is Scheme, which can give you a preliminary understanding of functional programming. More importantly, his grammar is very simple and you can learn it quickly, so you can spend more time studying the programming ideas in the book and solving complex problems.

PeterNorvig once wrote a wonderful SICP book review, in which there is such a passage:

For example, if it is about cars, it will be used by those who want to know how cars work, how to make them, and how to design fuel-efficient, safe and reliable cars for the 2 1 century. Those who want to drive are people who want to know how to drive on the highway, just like others.

If you are the former in the article, reading SICP will be the key point for you to connect the enlightenment and entry stages.

Although SICP is an "introductory book", it is still difficult for beginners. The following are some very useful auxiliary resources:

Udacitycs2 12 Computer Program Design): The speaker is PeterNorvig, the research director of Google mentioned above. The teaching language is Python, and the content is somewhat difficult.

How to design a program, Second Edition: The starting point of HtDP is lower than that of SICP. The contents in the book are convincing and friendly to beginners. If you think it is too difficult to finish SICP, you can consider reading HTDP first.

UCBerkeleySICP teaching video and video of two authors of SICP training HP employees (China Cultural Project).

ComposingPrograms: an introduction to programming (including some small projects) that inherits SICP ideas but uses Python as the teaching language.

SICP problem set: As a beginner, you should try your best to finish the exercises after the book.

After completing this part of the study, you will gradually establish your own programming model, and your mind will not be messy again. You will realize that memorizing libraries and grammar will not teach you how to solve programming problems, and you will know a lot about what to learn next. This is a good time to really start the project practice and supplement the driving force.

About project practice: it is too early for beginners to participate in open source projects. At this time, you should start to do some simple projects, such as building a website and maintaining it, or writing a small game and expanding it. If your own ideas are not clear, choose a project from MegaProjectList. In short, you must take the first drop of blood from your project practice at this time.

In the meantime, don't forget to continue to lay a good foundation. In order to accumulate wealth in the future, you should continue to do your homework in the following aspects (note: the following contents are in no absolute order):

Fundamentals of computer system

With the foundation of previous programming, if you want to grasp the context of computer science more deeply, you might as well read this book: Understanding Computer Systems in Depth. Criticizing the Chinese translation of this book by name here is actually far from deep enough. This book is just a textbook for CMU to introduce computer systems. CMU's computer science major prefers software. This book is a programmer's perspective to observe the computer system, with "how to execute the program in the computer" as the main line, and comprehensively expounds many details of the internal implementation of the computer system.

If you find reading a little boring, you can pay attention to a large open online course: the hardware/software interface on Coursera. The content of this course is a subset of CSAPP, but the most classic experimental parts have been transplanted. At the same time, you can look at ProgrammingLanguage and review the knowledge of C language.

After learning this book, you will have a solid system foundation and prerequisites for learning operating systems, compilers and computer networks. When learning more advanced system content, reading through the corresponding chapters of this book and programming examples will certainly have a more perceptual understanding of the theory in the book, so that the processed code can be clearly seen from the upper design to the bottom implementation, and the data can also be played back in the brain on the network-> Memory-> Cache-> The flow direction of CPU.

Besides, it's time to get in touch with UNIX philosophy: kiss-keeptsimple, idiot. In practice, this means that you should be familiar with the command line interface and configuration files. And gradually get rid of the IDE used before in development, and learn to use Vim or Emacs (or better try both).

Reading UNIX programming environment

Reading the art of UNIX programming

Throw away your UN*X system.

Data structure and algorithm basis

Nowadays, many people think that the main part of programming (especially web development) is to use other people's code. Being able to express your ideas clearly and concisely is much more important than mastering hard-core math and algorithm skills. Isn't the method of bisection of the data structure sorting function built in? You'll never need it at work. What's the use of learning algorithms? This idea of "coding farmers" under the banner of pragmatism is certainly not desirable. Without a solid theoretical background, it is only a matter of time before encountering bottlenecks.

Data structure and algorithm matching. The main content you should master at the beginning should be: What algorithms and data structures can solve this problem faster? This requires you to be familiar with commonly used data structures and algorithms. You don't have to type the code. Handwriting with paper is a faster method. For unknown data structures and algorithms, search what they are mainly used for and what the usage scenarios are.

Learning resources for your reference:

IntroductiontoAlgorithms: Some people say that this book should not be regarded as an introductory book. This book is not an introductory book at all. Although its title is Introduction to Algorithms, it is only because the author does not want to duplicate this book with other books. Of course, this book is not impossible to get started. Just skip the exercises and proofs the first time you read them. If you still feel guilty, first look at this data structure and algorithm analysis.

Curriculum algorithm: design and analysis. [Part 2]: Stanford's algorithm class is not limited to languages, and both parts will basically have an algorithm foundation; Failing English: MIT Open Course: Introduction to Algorithms

In the initial stage, we should also pay attention to cultivating the ability to solve small-scale problems by using conventional algorithms. We can read these books in combination with the SICP part of the last article "Programming Pearl and Programming Practice".

Fundamentals of programming languages

Different languages solve the same problem in different ways. By learning many different methods, you can broaden your mind. In addition, learn learningmanyalanguagesisfareasiernow, thank you for wealthoffreelyavailable software on the Internet.

-Preview the show

In addition, you should know that learning the nth programming language is half as difficult as learning the (n- 1) programming language, so try different programming languages and programming paradigms as much as possible. If you follow the previous instructions, you have come into contact with three good friends: the "clean" scripting language Python, the traditional imperative language C, and the romantic functional language Scheme/rack. But contact alone is not enough. You need to continue to deepen your friendship with them and try to make new friends. Beautiful and elegant ruby girl and Haskell, the treasure of Hindley-Milner language family, are all good choices. But with such a big partner, you can't hide and have to know-C++,you have to be prepared to make friends with him:

Introduction: c++ Primer

[Optional] Advanced:

Efficient use: EffectiveC++

Deep understanding: Deep exploration of C++ object model; C++ template

Research reflection: thedesignandevolutionofc++;+; +; For the necessity of C++, reading this book allows you to choose whether to be a night watchman or a night watchman.

The reality is cruel. There are still some enthusiasts in the software engineering field. They only master one programming language, and they just want to master one language. They think that the language they master is the best, and other heresies are stupid. Such people are not hopeless. There is a simple solution: let them write a compiler. To truly understand a programming language, you must implement one yourself. Now is the introductory stage, you are not required to take a compiler course, but you are required to implement at least a simple interpreter.

Learning resources for your reference:

"Programming Language-the Road to Practice": a textbook on the principle of CMU programming language and an introductory book on programming language. Reading it now will greatly broaden your horizons and widen the gap between you and ordinary people.

Coursera programming language large-scale open network course: In class, you can come into contact with SML using extreme FP (functional), Racket using neutral FP, Ruby using extreme OOP (object-oriented), learn FP decomposition of vsOOP problem, ML pattern matching, Lisp macro, invariance and variability, and the realization principle of interpreter, so that you can learn a new language more easily.

Udacitycs 262 programming language: preheating, teaching you to write a simple browser-in fact, it is a javascript and html interpreter, and the finished product is still very interesting; Next, try to complete a project mentioned in SICP: write a SchemeInterpreter in Python.

other

Some points that are easy to be ignored in the early stage of programming:

Learn English well: English is the main tool for you to obtain high-quality learning resources, but in the initial stage, the information loss of those translated works you read is not so serious, so you should weigh them according to your own situation. In addition, the importance of English is more reflected in communication. LinusTorvalds is Finnish, and fluent English has always been a magic weapon for him to recruit developers to work for Linux. This is your example.

Learn to ask questions: you will definitely encounter problems in your study. First of all, you should learn the "advanced search" of search engines. When the problem cannot be solved by search alone, ask StackOverflow or Zhihu. Before asking questions, please read this article: What did you get?

Don't be a lone wolf: try to build a simple personal website, not just a lonely About page, learn Markdown and LaTeX, try to record your thoughts on the blog and subscribe to your favorite programming blog. Recommend a few for your reference: Joel on Software, Peternorvig, Coding Horror.

summary

Don't be afraid of the above, getting started with programming is not a small project that can be completed in a few weeks. During this period, you will encounter numerous difficulties. When you hit a wall, try Feynman's technique: divide the difficulties into small pieces of knowledge, then deal with them one by one, and then test whether you really understand them by explaining them clearly to others. Of course, there will still be problems that you can't solve, so don't force yourself at this time-many times when you look back at this problem later, everything will suddenly become clear.

In addition, don't limit yourself to the materials mentioned above. There are also some books worth reading repeatedly in the introductory stage and the subsequent promotion stage. Introduction to Programmers is such an introductory book for programmers and an ultimate book. Some people call this book an encyclopedia of code: from dry to kiss, from being a human being to being a programmer, this book teaches you everything, all you need is to follow the instructions in the book.

postscript

If you can manage to complete all the above tasks, congratulations, you have really achieved the introduction of programming. This means that you will not be afraid of the task of learning a new language, the "complex" API, the specific technology, and even feel relaxed in further study. Of course, in order to master these things, you still need a lot of practice, your back will still hurt, you will still have difficulty walking, and you can't go up to the fifth floor in one breath. But I can guarantee that you will have a great change in your mind, gain great confidence, and have a subtle vision of teachers, classmates and csdn. Although you have just finished the introduction to programming, you have become the Gao Fushuai of the programmer's spiritual world. No, I was wrong. Even Gao Fushuai won't have a strong spirit. He will doubt himself and feel that he is nothing without money. But in short, if you follow the guide and study hard, you will experience the feeling of "once you climb to the top of the mountain, you will see it"

First of all, if you want to learn programming, it is very important to choose a suitable computer language. How to choose is particularly important. It depends on your hobbies and the characteristics of each language. For example, php is a very popular computer language suitable for web development, which is easy to learn and use. I personally recommend PHP language.

Java can be used for web development and Android app development. It may be a little harder to learn than php, but it's no problem. If you are interested in java, you can try it.

Python is a popular language at present, which is suitable for artificial intelligence. In addition, it is also very suitable for writing programs for web crawlers to see personal interests.

It is not recommended to use C, c++, c#, especially C #, which is an outdated language. Even if you study well, it is not suitable for finding a job. C and c++ are not suitable for beginners to learn, so there is no need to consider them. There are some small languages, which is even more unnecessary to consider. Therefore, you should choose a language you are interested in from the above three languages for language learning.

R&D and Architectural Environment

If you choose a good computer language, then the next step is to set up the R&D environment, because only by setting up the R&D environment can you carry out subsequent programming work, such as PHP, and then search Baidu for how to install the PHP environment, and you can find some simple tutorials. Novices can set up the R&D environment step by step, and it will take half a day at most. If it is java, you need to install jdk and configure environment variables first. There are also related tutorials online.

Choose videos and books to help you study. Since it is zero-based learning, it is necessary to study systematically, instead of learning from zero-based knowledge points everywhere.

Code practice

Follow the tutorial chapter by chapter, and it should be noted that you can't just watch it. That won't do. You have to beat the knowledge points of each chapter with your own code and run it to see the effect. Only in this way can we improve our hands-on ability. At first, we will feel a little rusty, and gradually we will become proficient and increase our interest in programming. This process requires repeated practice, a lot of code practice. This process is the most critical stage among the five steps. It's important to practice the code yourself. Don't let go of some chapters you don't understand in programming. You can find some related programming exchange groups online, join them, or consult some experienced people online. Maybe it can help you solve the problem easily, it is very helpful for your study, and the whole process is free.

Project actual combat

If the basic courses have been practiced step by step, then you have some basic skills of programming, then you can try to do some small projects, string together what you have learned, and enter the actual combat stage of the project, such as designing a student management system yourself and completing it. If you don't know how to design it, you can search it online. Slowly, I have an idea.

I'm also studying this aspect. I read a lot of video books, and the most recommended one is the learning materials of going to school in Beijing, including Java.300 episodes and Python400 episodes. They are all classic basic introductory courses, combined with project learning. They are very interesting, full of dry goods, free of charge. I recommend you to read them. I believe they can take you into a changing world.

To learn programming from scratch, the first level is to choose the programming language you want to learn. Faced with a wide variety of programming languages, beginners are often at a loss, unable to make up their minds and don't know which one to choose.