How to master "all" programming languages? Yes, that's all!

Yes, what I want to talk about here is not how to master a programming language, but all...

Many programming beginners still write to me for advice, asking me what programming language to learn and how to learn.

Since I know how to master "all" programming languages, I always feel that this kind of "one" language question is relatively low-level, so I haven't had time to reply to them.

But gradually, I discovered that it wasn't just Xiaobai who had this problem, and even many senior engineers in large American companies actually didn't understand it.

Today I am motivated, and I want to answer this long-awaited "primary 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 many people, I have a more precise expression of the ideas in my head (not transformed into language).

If you have the following confusions, then this article may be helpful to you:

  • You are a beginner in programming and don't know which programming language to choose to get started.

  • You are a senior programmer or team leader, and you are confused by the emerging languages ​​and don't know which language to "invest" in.

  • Your team is arguing about which programming language to use, and there are various religious struggles.

  • You follow the trend and use a certain fashionable language, and after two months, you find that you are in a quagmire, and you are in pain...

Although I no longer talk about these things, the unquestionable reality is that programming language is still a very important topic, and this situation will not change in a short time.

The job of a programmer often requires familiarity with certain languages, and even some weird companies require you to "in-depth understanding of OOP or FP design patterns."
For incumbent programmers, programming language is still a religious topic that can be popular.

It is so religious that when I criticize and ridicule certain languages ​​(such as Go), some people instinctively think that I am a fan of another language (such as Java).

Obviously I can't be a fan of any language. I'm not even a fan of Yin language. For any language I have never seen before, I just pick it up and use it without the need to go through the process of learning.

Reading this article, maybe you will understand why I can achieve this effect.

Understand the things inside, every programmer should be able to do this.

Well, I hope.


Pay attention to language characteristics, not language

Many people care about whether they or others "know" a certain language. They admire those who "invent" a certain language, and fight over which language is better or worse.

None of these problems exist for me.

Although I have written articles criticizing many language shortcomings, in actual work I rarely argue with people about them.

If there are other people arguing by my side, I will even put on headphones and don’t bother to listen to what they say.

why?

I found that in the final analysis, the reason is that I value "language characteristics" rather than the entire "language".

I can write good code in any language, even the bad language is not much worse.

Any kind of "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 not.

You have to see what type of processor it contains, how many cores, how much clock speed, how many L1 cache, L2 cache..., how much memory and hard disk, how big the display resolution is, what GPU is the graphics card , Network card speed, and so on various "configurations".

Sometimes you have to look at the compatibility between the various components. These configurations correspond to the programming language, which is the so-called "language feature".

Give some examples of language features:

  • Variable definitions

  • 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 statement

These language features are just like when you choose a computer, look at what configuration it contains.

When choosing a computer, no one would say that Dell must be the best, they would only say that this model is equipped with Intel’s i7 processor, which is better than i5, DDR3 memory is so much faster than DDR2, and SSD is better than Disks are much faster, ATI's graphics cards are rubbish... and so on.

The same is true for programming languages.

For beginners, there is actually no need to entangle which language to learn first and which language to learn later.

Someone once sent me a letter asking this kind of question. I struggled with it for several weeks, but I haven't even started learning a language yet.

With this tangled time, he can actually master all the language he tangled.

Beginners often don't understand, every language must have a set of "universal" features. Such as variables, functions, integer and floating point operations, etc.

These are required in every general programming language, and none of them is missing.

As long as you learn these characteristics through "a certain language" and master the basic concepts of these characteristics, you can apply this knowledge to any other language at any time.

The time you invest in this is basically not wasted.

Therefore, beginners are entangled in "which language to learn first". This kind of time is not worth it. It is better to pick a language and jump into it.

If you can't write good code with the basic features in one language, it won't help you to switch to another language. You will write the same bad code.

I often see some people who write Java code quite messy and badly, but they criticize Java as bad and ambitious to switch to the Go language.

These people did not understand that whether they can write good code lies in the people, not the language.

If you don't have a clear and simple thinking model in your mind, it will be a lot of mess if you use any language to express it.

If you write bad Java code, then you write Go language code will be just as bad, or even worse.

Many beginners don't understand. If a smart programmer starts to use a new programming language, he often does not read the large manuals or books of the language, but first has a problem that needs to be solved.

With a problem at hand, he can browse the manual of the language in two minutes to see what the language looks like.

Then, he directly picked up a piece of example code and started to modify it, thinking of changing the code to the problem he was trying to solve.

In this brief process, he quickly mastered the language and used it to express his thoughts.

In this process, as the need arises, he may ask such questions:

  • What is the grammar of "variable definition" in this language, do you need "declaration type", or can you use "type inference"?

  • What is the syntax of its "type"? Does it support "generics"? How to express the "variance" of generics?

  • What is the syntax of "function" in this language, what is the syntax of "function call", and can "default parameters" be used?

  • ……

Did you notice? The content in each quotation mark above is a language feature (or concept).

These concepts can exist in any language, although the syntax may be different, their essence is the same.

For example, in some languages, the parameter types are written before the variable, some are written after, some are separated by a colon, and some are not.

These practical problems are brought out naturally as the actual code is written to solve the problem at hand, rather than the language manual at the beginning.

Because anyone who has mastered the characteristics of a language knows that the characteristics they need must be expressed in any language.

If there is no direct way to express, then there must be some kind of "bypass".

If there is a direct way of expression, then it is only slightly different in syntax.

Therefore, he was looking for features with questions, like looking up a dictionary, instead of being drowned in a large manual and drowsy for a month before starting to write code.

Once you have mastered the common language features, only certain language "specific" features are left.

Anyone who studies language knows that it is very difficult to design new, good, and harmless features.

So generally speaking, a good language will not have more than one or two unique new features after all.

If there is a language that claims to have more than 5 new features, then you have to be careful, because the sums they bring may not be advantages, but disasters!

In the same way, the best language researchers are often not the designers of certain languages, but the designers (or supporters) of certain key language features.

For example, the famous computer scientist Dijkstra is a strong supporter of "recursion". There is recursion in current languages, but you may not know that early programming languages ​​did not support recursion.

It wasn't until Dijkstra strongly urged the Algol 60 committee to add support for recursion that this situation changed. Tony Hoare is also the language feature designer.

He designed several important language features, but he did not design any language. In addition, please don’t forget that there is a language expert named Wang Yin. He is the supporter and implementer of the early union type and the supporter of the checked exception feature. He pointed out the difference between checked exception and union type in his blog post. Relationship: P

Many people blindly admire language designers. As long as they hear someone design (or "invent") a language, they will be excited and admire it.

They did not understand. In fact, all programming languages ​​are just "assemblers" like Dell and Lenovo.

The designer of language features is the creator of core technologies like Intel, AMD, ARM, and Qualcomm.


Reasonable introductory language

Therefore, if beginners want to do more with less, they should start from a "reasonable" language without obvious serious problems, master the most critical language features, and then apply these concepts to other languages.

Which are reasonable introductory languages? I personally think that these languages ​​can be used to get started:

  • Scheme

  • C

  • Java

  • Python

  • JavaScript

In contrast, which languages ​​do I recommend for getting started?

  • Shell

  • PowerShell

  • AWK

  • Perl

  • PHP

  • Basic

  • Go

  • Rust

In general, you should not use the so-called "scripting language" as an entry language, especially those scripting language tools that originated from the early Unix systems.

Although PowerShell is more advanced than Unix Shell, it still hasn't gotten rid of the fundamental problem of scripting language-their designers don't know what they are doing :P

Using scripting language to learn programming, a very serious problem is that the learner can't grasp the key.

Scripting languages ​​often add some system tools (such as regular expressions, Web concepts) into the grammar, causing beginners to waste too much time for them, but they don’t understand the most critical concepts of programming: variables, functions, recursion, and types. ...

The reason why Go is not recommended is similar. Although Go is not a scripting language, its designer obviously does not understand what he is doing. So using Go language to learn programming, you can't focus on the most critical and best language features.

Similarly, I don't think Rust is suitable as an introductory language. Rust spends too much energy to boast of its "new features", and these new features are not only not the most critical part, but many of them are problematic. Beginners who pay attention to these features too early will not only fail to learn the most critical programming ideas, but may also go astray.


Master key language features and ignore secondary features

In order to achieve the effect I mentioned before, the beginner should focus on the most critical features of the language, instead of being distracted by the secondary features.

Give an exaggerated example.

I found that many programming training courses and introductory programming courses at Pheasant University often teach students how to printf print "Hello World!", and then ask them to remember  printf the meaning of various "format characters", and ask them to implement various complex formats. The printout, even required to be printed into a text file, and then read out...

But as everyone knows, this kind of input and output operations are not actually part of the language at all, and they are all secondary to mastering the core concepts of programming.

Some people have been doing Java courses for several weeks, and they are still assigning various  printf homework. Students write hundreds of lines of printf, but they don’t understand what variables and functions are. They don’t even know how to use arithmetic statements and loop statements!

This is why many beginners feel Programming is hard, I could not even  %d, %f, %.2f the meaning can not remember, but also how to learn programming!

However, the title of "professor" at these pheasant universities is so brainwashed that students who have been taught by them (such as my girlfriend) come to me to ask for advice, and they scold me for teaching some useless things, even after learning all  printf the homework. Can't finish: P

Don't tell me about  for loops, functions, etc.... Can you wait a few months  printfand learn those usages after I learn the usage?

So you find that once taught by a bad teacher, the programmer is basically ruined. Even if they meet a good teacher, it is difficult for them to correct it.

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

Here are some examples of secondary language features:

  • In the statement block of C language, if there is only one statement in it, the curly braces can be omitted.

  • If the function parameter types of the Go language are the same, they can be combined and written, such as func foo(s string, x, y, z int, c bool) { … }

  • Perl regards regular expressions as a special grammar of the language

  • JavaScript statements can omit the semicolon at the end of the sentence at some point

  • Currying in languages ​​such as Haskell and ML


Implement language features by yourself

After you have basically learned various language features and can use them to write code, the next step is to implement them.

Only by realizing various language features can you fully own them and become their master. Otherwise, you are just their user, and you will be led by the nose of the language designer.

A great master said that the best way to fully understand a language is to implement 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 changed "language" to "language feature" here. You don't need to implement the entire language to achieve this goal, because we end up using language features.

As long as you implement a language feature yourself, you can understand the implementation and usage of this feature in any language.

For example, when learning SICP, everyone will personally use Scheme to implement an object-oriented system.

The object-oriented system implemented in Scheme is far from the language syntax of Java, C++, Python, etc., 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 various object-oriented implementations.

This kind of effect cannot be obtained by directly learning OOP language, because when you are learning Java, C++, Python and other languages, you are just a user, and after implementing the OO system with Scheme yourself, you become a creator. .

Similar features include type inference, type checking, lazy evaluation, and so on.

I have realized almost all language features, so any language in front of me is a toy that can be disassembled and assembled at will, and is no longer a sacred one above me.


to sum up

Having written so much, repeat the important words three times: language features, language features, language features, language features!

Whether you are a beginner or an experienced programmer, you should focus on language features instead of entangled in the entire "language brand".

Only in this way can we achieve integration, pick up any language and use it almost immediately, and write high-quality code.

1. Inventory of domestic RISC-V core MCU manufacturers!

2. Have you paid attention to the barometer of the economic development of the embedded industry and the industrial development of the EU?

3. How high is the turnover cost of a technical employee?

4. New world, new way: 2021 International Embedded Exhibition and Conference is going digital

5. How is the architecture of the domestic Linux operating system designed?

6. Introduction to Artificial Intelligence: Neural Networks Based on Linux and Python

Disclaimer: This article is reproduced online, and the copyright belongs to the original author. If you are involved in the copyright of the work, please contact us, we will confirm the copyright based on the copyright certification materials you provide and pay the author's remuneration or delete the content.

Guess you like

Origin blog.csdn.net/DP29syM41zyGndVF/article/details/114324294