Article From:

Yes, what I’m going to talk about here is not how to master a programming language, but all…

Many beginners are still writing letters to me to ask what programming language I should learn and how to learn. Because I know how to master “all” programming languages, I always feel that the problem of “one” or “what language” is relatively low-level, so I never have time to reply to them: P is gradual.I found out that it was not only the little white people who had this problem, but also many senior engineers in big American companies who didn’t understand it.

Today I have the motivation to answer this long-standing “elementary question” in a unified way. A similar topic seems to have been written before, but now I want to rewrite it. Because after communicating with a lot of people, I have a more accurate expression of the ideas in my mind (not translated into language).

If you have the following confusions, this article may help you:

  1. You are a beginner in programming. You don’t know what programming language to choose to start with.
  2. You are a veteran programmer or team leader who is confused by emerging languages and doesn’t know which language to “invest” in.
  3. Your team has been arguing about which programming language to use, and there have been various religious struggles.
  4. You follow the trend and use some fashionable language. Two months later, you find yourself in a quagmire and in great pain.

Although I’m no longer interested in these things, there’s no doubt that programming language is still a very important topic, and that won’t change in a short time. Programmer positions often require familiarity with certain languages, and even exotic companies require you to “have a deep understanding of OOP or FP design”Mode. For in-service programmers, programming language is still a red-faced religious topic. It’s so religious that when I criticize and ridicule some languages (such as the Go language), some people instinctively think I’m a fan of another language (such as Java).Silk.

Obviously, I can’t be a fan of any language, I’m not even a fan of Yin;) For any language I’ve never seen before, I just pick it up and use it without having to go through the learning process. After reading this article, you may understand why I can achieve this effect. UnderstoodEvery programmer should be able to do this. Well, I hope so.

Focus on linguistic characteristics rather than language

Many people care about whether they or others can “know” a language. They admire people who “invent” a language and compete for the advantages and disadvantages of different languages. These problems do not exist for me. Although I have criticized many language flaws in my articles, I seldom follow others in my practical work.Argument about this. If someone else was arguing with me, I would even wear headphones and be too lazy to listen to them;) Why? I find that in the final analysis, the reason is that I value “linguistic characteristics” rather than “language” as a whole. I can write good code in any language, even if I write it again.Bad language is not much worse.

Any “language” is a combination of various “linguistic characteristics”. For example, a programming language is like a computer. Its brand may be Lenovo, or IBM, or Dell, or Apple. So, can you say that Apple must be better than IBM? You do notYes. You have to see what type of processor it contains, how many cores, how many main frequencies, how many L1 cache, L2 cache… How many memory and hard disks, how big is the display resolution, what GPU is the graphics card, the network card speed, and so on various “configurations”. YesYou also have to look at compatibility between components.

These configurations correspond to the programming language, which is called “language features”. Some examples of linguistic features are given:

  • Variable definition
  • Arithmetic operation
  • for Loop statement, while loop statement
  • Function Definition, Function Call
  • recursion
  • Static type system
  • Type inference
  • lambda function
  • Object-oriented
  • Garbage collection
  • pointer arithmetic
  • goto Sentence

These language features, like when you choose a computer, look at its configuration. When choosing a computer, no one would say Dell must be the best. They would only say that this model contains Intel’s i7 processor, which is better than i5, DDR3.Memory is so much faster than DDR2, SSD is much faster than disk, ATI’s graphics card is garbage… And so on.

The same is true of programming languages. For beginners, there is no need to struggle with which language to learn first and which to learn later. Someone once sent me a letter asking this kind of question, and after several weeks of entanglement, it turned out that a language had not yet begun to learn. With this time of entanglement, we can actually entangle his words.All the words are mastered.

Beginners often do not understand that every language must have a set of “universal” characteristics. For example, variables, functions, integers and floating-point operations, and so on. These are necessary in every common programming language, and none of them can be spared. You only need to learn these characteristics by “some language” and master them.The fundamental concept is that these knowledge can be applied to any other language at any time. The time you invest in it will hardly be wasted. So beginners struggle to “learn which language first”. This time is not worth it. It’s better to pick up a language and jump in.

If you can’t write good code with the basic features of one language, it’s no use switching to another language. You’ll write the same bad code. I often see people who write Java code rather messily and poorly, but scold Java for being bad and ambitious about switching to Go.Language. These people don’t understand that it’s people, not language, that make good code. If you don’t have a clear and simple mental model in your mind, it’s a mess to express it in any language. If your Java code is poorly written, you’ll be just as poorly written in the Go language.Cake, even worse.

Many beginners do not understand that if a skilled programmer starts to use a new programming language, he often does not read the language’s large manuals or books, but first has a problem to solve. With a problem at hand, he can browse the language manual in two minutes to see how long the language is.What does it look like? Then he picked up an example code and began to modify it, trying to change it to the problem he was trying to solve. In this short process, he quickly mastered the language and used it to express his thoughts.

In the process, with the emergence of demand, he may ask such questions:

  • What is the grammar of “variable definition” in this language? Do you need to declare type, or can you use “type inference”?
  • What is the grammar of its “type”? Do you support generics? How to express generic variance?
  • What is the grammar of “function” and “function call” in this language? Can you use “default parameters”?
  • ……

Have you noticed? The content of each quotation mark above is a linguistic feature (or concept). These concepts can exist in any language, although the grammar may be different, their essence is the same. For example, some language parameter types are written in front of variables, some are written in back, and some are written in front of variables.Some are separated by a colon, some are not.

These practical problems are brought out naturally along with the actual code and the solution of the problems at hand, instead of reading carefully with the language manual at the beginning. Because everyone who has mastered the language characteristics knows that there must be corresponding expressions in any language for the characteristics they need. If there is no straightnessThere must be some kind of “bypass way” when it is expressed in the form of connection. If there is a direct way of expression, then it’s just a slightly different grammar. So, instead of being drowned in most of the manuals, he started writing code after a month of drowsiness.

Having mastered the general linguistic features, only some linguistic “peculiarities” remain. Everyone who studies languages knows that it is very difficult to design new, good and harmless features. So generally speaking, a good language, its unique new features, after all, will not exceed one or two. If there is oneLanguage claims to have more than five new features, so you have to be careful, because what they bring is not an advantage, but a disaster! uuuuuuuuuuu

In the same way, the best language researchers are often not the designers of a language, but the designers (or supporters) of some key linguistic characteristics. For example, the famous computer scientist Dijkstra is a strong supporter of recursion. Now there are recursions in the language, butAnd you may not know that early programming languages did not support recursion. This situation did not change until Dijkstra urged the Algol 60 Committee to join in support of recursion. Tony Hoare is also a language designer. He designed several important things.Language features, but no language has been designed. In addition, let’s not forget that there is a language expert named Wang Yuan, who was a supporter and implementer of early union type and a supporter of checked exception features. He pointed out in his blog post thatThe relationship between checked exception and union type: P

Many people blindly worship language designers, as long as they hear someone design (or “invent”) a language, they are full of blood and admiration. They don’t understand that, in fact, all the programming languages are just “assembly machines” like Dell and Lenovo. Design of Language CharacteristicsThose are the creators of core technologies like Intel, AMD, ARM and Qualcomm.

Mastering Key Language Features and Ignoring Secondary Features

In order to achieve the convergence and universality I mentioned earlier, beginners should focus on the most critical features of the language, rather than be distracted by the secondary features.

Take an exaggerated example. I found that many programming training courses and introductory courses at Pheasant University often teach students how to print “Hello World!” using printf. And then they need to remember the meanings of printf’s various “format characters”, and they need to be realNowadays, printing out in various complex formats even requires printing into text files, and then reading out…

However, this kind of output-input operation is not really part of the language at all, and is secondary to mastering the core concepts of programming. Some people’s Java classes have been going on for weeks, and they’re still assigning various printf assignments. Students write hundreds of lines.Printf, but do not understand what variables and functions are, and even do not know how to use terminology and loop statements! That’s why many beginners find it difficult to program, I even think.%d%f%.2f I can’t remember the meaning. How can I learn to program?

However, the “professor” titles of these pheasant universities are so brainwashed that students (such as my girlfriend) who have been taught by them come to me to ask for advice and scold me for teaching some useless things. They have learned that even printf’s homework can’t be completed: P, don’t tell me about for loop, function.What’s the matter? Can you wait a few months until I learn the usage of printf by heart?

So you find that once taught by a bad teacher, the programmer is basically ruined. Even if they meet good teachers, they can hardly correct them.

Of course, this is an exaggerated example, because printf is not a linguistic feature at all, but this example illustrates the problems caused by secondary superficial linguistic features from the same perspective.

Here are some examples of minor linguistic features:

  • C If there is only one sentence in the sentence block of a language, it can not be bracketed.
  • Go Language function parameter types can be written together if they are the same, such asfunc foo(s string, x, y, z int, c bool) { ... }
  • Perl Regarding Regular Expressions as a Special Grammar of Language
  • JavaScript Statements can sometimes omit semicolons at the end of a sentence
  • Haskell Currying in ML and other languages

Manual Realization of Language Characteristics

After learning the basic language features and using them to write code, the next step is to implement them. Only by realizing various linguistic features can you fully possess them and become their masters. Otherwise, you are just their users, and you will be led by the language designer.

A master speaks well and the best way to fully understand a language is to implement it by himself, that is, to write an interpreter to realize its semantics. But I think this sentence should be slightly revised: the best way to fully understand a “linguistic feature” is to implement it yourself.

Notice that I am here to change “language” to “linguistic characteristics”. You don’t need to implement the whole language to achieve this goal, because we end up using language features. As long as you implement a language feature yourself, you can understand how and how it is implemented in any language.

For example, when learning SICP, everyone will implement an object-oriented system with Scheme. The object-oriented system implemented with Scheme is far from the language grammar of Java, C++, Python and so on, but it can help you.Understanding the concept of “object-oriented” in any of these OOP languages can even help you understand the differences in various object-oriented implementations.

This effect is not available for you to learn OOP directly, because when you learn Java, C++, Python and other languages, you are only a user, and when you implement OO system with Scheme, you become a creator.

Similar features include type inference, type checking, inert evaluation, and so on. I have achieved almost all the linguistic features, so any language in front of me is a toy that can be disassembled and assembled at will, rather than a sacred one over me.

Post Views: 0

Leave a Reply

Your email address will not be published. Required fields are marked *