Right, what I'm going to talk about here is not how to master a programming language, but all the ...
Many programmers are still writing to me to consult, ask me what program language to learn, how to learn. As I know how to master all the programming language, I always feel this "what language to learn" the problem is so low, so has not had time to reply:P but gradually, I found that the original is not only small white people have this problem, even the United States a large number of senior engineers, actually did not understand.
Today leisure activities into the second week, a little idle, I would like to unified answer this long-held "primary problem." This topic seems to have been written, but now I want to write it again. Because after interacting with a lot of people, I have a more precise expression of my thoughts in my head.
If you have any of the following puzzles, this article might help you:
- You are a beginner of programming and do not know what programming language to choose to get started.
- You are a senior programmer or team leader who is confused about the new language and does not know which language to invest in.
- Your team is arguing about which programming language to use, and there are various religious struggles.
- You chase the tide with some kind of fashionable language, the result of two months later found deep mire, the pain is unbearable ...
Although I am no longer involved in these things, the reality is that procedural language is still a very important topic, and this situation will not change in a short time. Programmers ' positions often require familiarity with certain languages, and even some exotic companies require you to "delve into OOP or FP design patterns." For working programmers, the language of the program is still a hotly-heated religious topic. It's so religious that when I criticize and ridicule certain languages (such as the Go language), some people instinctively think I'm a fan of another language (like Java).
Obviously I can't be a fan of any language, I'm not even a fan of the Yin language;) For any language I've never seen before, I use it directly, without having to go through the process of learning. Read this article, maybe you will understand why I can achieve this effect. Understanding what's inside, every programmer should be able to do it. Well, let's hope so.
focus on language characteristics, not language
Many people care about themselves or others whether "will" a language, the "invention" of a language of the people to worship, for a variety of languages, the pros and cons of the red. These questions don't exist for me. Although I have written articles criticizing a lot of language flaws, I seldom argue with people in practical work. If there were other people arguing with me, I would even wear headphones and not listen to what they were saying;) Why is it? I find that the bottom line is that I value the "language trait" rather than the whole "language". I can write good code in any language, even if the bad language is not much worse.
Any "language" is a combination of various "language features". For example, a programming language is like a computer. Its brand may be called "Lenovo", or "IBM", or "Dell", or "apple". So, can you say that Apple must be better than IBM? You can't. You have to see what type of processor it contains, how many cores it has, how much it is, how many L1 cache,l2 cache ..., how much memory and hard drives, how big the display resolution, what GPU, Nic speed, etc. "Configuration". Sometimes you have to look at the compatibility between the various components.
These configurations correspond to the language of the program, which is called "language features". Cite some examples of language features:
- Variable definition
- Arithmetic operations
- For Loop statement, while Loop statement
- function definition, function call
- Recursive
- Static type System
- Type deduction
- Lambda functions
- Object oriented
- Garbage collection
- Pointer arithmetic
- Goto statement
These language features, like when you're choosing a computer, look at what's in it. When choosing a computer, no one would say that Dell must be the best, they will only say that this model is installed in the Intel i7 processor, this is better than i5, DDR3 memory is faster than DDR2, SSD much faster than disk, ATI graphics card is garbage ... And so on
The same is true of programming languages. For beginners, there is no need to dwell on which language to learn first, and what to learn. I was sent a letter to ask this question, tangled for several weeks, the result of a language has not yet begun to learn. With this tangled time, in fact, all of his tangled language can be mastered.
Beginners often do not understand that each language must have a "universal" characteristics. such as variables, functions, integers and floating-point arithmetic, and so on. These are all common programming languages must have, one can not be less. You can apply this knowledge to any other language at any time by learning these traits through "a language" and mastering the underlying concepts of these features. The time you spend on it is basically not wasted. So beginners struggle to "learn what kind of language first", this time spent is not worth, it is better to pick a language, jump in.
If you can't write good code with the basic features of a language, it doesn't help if you switch to another language. You'll write the same bad code. I often see some people Java code is quite messy, rather bad, but scold Java bad, ambitious to switch to the Go language. These people do not understand that the ability to write good code is human, not language. If you don't have a clear, simple thinking model in your mind, you can express it in any language as a bunch of mess. If your Java code is poorly written, it will be as bad or worse for you to write the Go language code.
Many beginners do not understand that if a smart programmer begins to use a new programming language, he is often not going to see a large manual or book in the language, but rather a problem that needs to be solved first. With a problem at hand, he could take a two-minute look at the language handbook and see what the language looks like. Then he picks up an example code to start tinkering with the idea of changing the code to the problem he's trying to solve. In this brief process, he quickly mastered the language and used it to express his mind.
In the process, as the need arises, he may ask questions such as:
- What is the syntax for the "variable definition" of this language, do you need a "claim type", or can you use "type deduction"?
- What is the syntax of its "type"? Do you support "generics"? How is the generic "variance" expressed?
- What is the syntax of the "function" of this language, what is the syntax of "function call", and can I use "Default parameter"?
- ......
Have you noticed? The contents of each quotation mark above are a linguistic feature (or concept). These concepts can exist in any language, and although the syntax may be different, they are essentially the same. For example, some language parameter types are written in front of variables, some are written later, some are separated by a colon, and some are not.
These practical problems are the actual code, to solve the problem at hand, naturally brought out, rather than the beginning to hold the language manual to see carefully. Because people who have mastered the characteristics of language know that they need the characteristics, in any language there must be a corresponding way of expression. If there is no direct way to express, then there must be some kind of "bypass way". If there is a direct expression, then it is only a slightly different syntax. So, he was looking for a character with a problem, just like a dictionary, rather than being drowned in a voluminous handbook, and was sleepy for one months before he began to write code.
Mastering the Universal language features, the rest is only some of the language "unique" features. People who study language know that it is very difficult to design new, good, harmless properties. So generally speaking, a good language, its unique new features, after all, no more than one or two kinds. If there is a language claiming to have more than 5 new features, then you have to be careful because they bring and may not be an advantage, but a disaster!
In the same way, the best language researchers are often not the designers of a language, but rather the designers (or supporters) of some key language features. For example, Dijkstra, a well-known computer scientist, is a strong supporter of "recursion". There are recursion in the language now, but you may not know that the early programming language does not support recursion. The situation changed until Dijkstra strongly demanded that the Algol 60 committee join the support for recursion. Tony Hoare is also a language feature designer. He has designed several important language features, but has not designed any language. And let's not forget that there is a language expert named Wang Yin, who is a supporter and a checked of the early union type, and a supporter of the exception feature, who in his own it points out the relationship between the checked exception and the union type: P
Many people blindly worship language designers, as long as they hear someone design (or the United States their people said "invented") a language, the blood boiling, admire the pleasantly surprised. They did not understand that, in fact, all the programming language, just like Dell, Lenovo's "Assembly machine." The designer of language features is the creator of the core technology like Intel,amd,arm,qualcomm.
a reasonable introductory language
So if beginners want to do more with less, they should start with a kind of "reasonable", no obvious serious problem language, grasp the most critical language characteristics, and then apply these concepts to other languages. What are the reasonable introductory languages? I personally think these languages can be used to get started:
- Scheme
- C
- Java
- Python
- Javascript
So in contrast, what languages do I not recommend to get started?
- Shell
- PowerShell
- Awk
- Perl
- Php
- Basic
- Go
In general, you should not use the so-called "scripting language" as a starting language, especially for scripting language tools that originate from early Unix systems. Although PowerShell has progressed more than the Unix Shell, it still does not get rid of the fundamental problem of scripting languages-their designers don't know what they're doing:P
In scripting language programming, a very serious problem is to make learners unable to grasp the key. Scripting languages tend to add things like regular expressions and Web concepts to the syntax of some system tools, causing beginners to waste too much time on them, without understanding the most critical concepts of programming: variables, Functions, recursion, types ...
The reason why the go language is not recommended is similar, although the go language is not a scripting language, but his designers obviously do not understand what they are doing. So using the Go language to learn programming, you can't focus on the most critical, best language features.
Mastering key language features, ignoring minor features
To achieve the follow effect that I mentioned earlier, beginners should focus on the most critical features of the language, rather than being distracted by secondary features.
Give an example of exaggeration. I have found many programming courses and the introduction of the Pheasant College programming classes, often to teach students how to use printf to print "Hello world! In turn, they want to remember the meaning of the various "format characters" of printf, to enable them to print out a variety of complex formats, even to print to a text file, and then read it ...
But as everyone knows, this output input operation is not really part of the language, and for mastering the core concept of programming, are secondary. Some people have been working on the Java course for several weeks and are still laying out various printf assignments. Students write hundreds of lines of printf, but do not understand what variables and functions are, even arithmetic statements and loop statements do not know how to use! This is why many beginners feel that programming is difficult, I even %d
, %f
, %.2f
the meaning can not remember, but also how to learn programming!
However, these pheasant University "Professor" title is so brainwashed, so that they taught students (such as my girlfriend) to my here to consult, actually scold me to teach some useless things, learned that even printf's homework can not be completed:P you don't tell me about the For loop, function or something ... Can wait a few months, and so I learned the usage of printf to learn those ah?
So you'll find that once you've been taught by a lousy teacher, the programmer is basically ruined. Even if you meet a good teacher, they will be hard to correct.
This is, of course, an exaggeration, because printf is not a language feature at all, but this example illustrates the problem of secondary superficial linguistic features from the same perspective.
Here are some examples of minor language features:
- C language of the statement block, if there is only one statement, you can not play curly braces.
- The function parameter types of the Go language can be combined together to write, such as
func foo(s string, x, y, z int, c bool) { ... }
- Perl takes regular expressions as a special syntax for language
- A JavaScript statement can omit a semicolon at some point in the end of a sentence
- Currying in languages such as Haskell and ML
implement your own language features with your own hands
After the basic learning of various language features, which can be used to write code, the next step is to implement them. Only by implementing a variety of language features can you fully own them and become masters of them. Otherwise you are just their users, and you will be led by the language designer to take the nose.
A master said well, the best way to fully understand a language is to do it yourself, that is, to write an interpreter to implement its semantics. But I think this sentence should be slightly modified: the best way to fully understand a "language feature" is to implement it yourself.
Note that I have changed "language" to "language feature" here. You don't need to implement the whole language to do this, because we end up using language features. As long as you implement a language feature yourself, you can understand how and how this feature is implemented in any language.
For example, when learning SICP, everyone will personally use Scheme to implement an object-oriented system. The object-oriented system implemented with Scheme is a far cry from language syntax such as Java,c++,python, but it can help you understand the concept of "object-oriented" in any of these OOP languages, and it can even help you understand the differences in the various object-oriented implementations.
This effect is that you directly learn the OOP language can not get, because in learning Java,c++,python language, you are only a user, and use Scheme to implement the OO system yourself, you become a creator.
Similar features include type derivation, type checking, lazy evaluation, and so on. I have achieved almost all of the language features, so any language in front of me, can be arbitrarily disassembled assembly of toys, and no longer is above me the sacred.
Summary
Write so many, important words repeat three times: language features, language features, language features, language features! Both beginners and senior programmers should focus on language features rather than on the entire "language brand". Only in this way can we achieve mastery, pick up any language almost immediately will be used, and write high-quality code.
This digest from: HTTP://WWW.YINWANG.ORG/BLOG-CN/2017/07/06/MASTER-PL
How to master All languages