Wang Yin: How to master all the programming languages

Source: Internet
Author: User
Tags arithmetic function definition lenovo

  

From: Wang Yin's blog

Links: Www.yinwang.org/blog-cn/2017/07/06/master-pl

  

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. Because I know how to master the "all" of the programming language, always feel that this learning "one" what language of the problem is relatively low, so have not had time to reply to their: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 I have the motivation, want to unified answer this long-held "primary problem". A similar 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:

    1. You are a beginner of programming and do not know what programming language to choose to get started.

    2. You are a senior programmer or team leader who is confused about the new language and does not know which language to invest in.

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

    4. 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. A programmer's post often requires familiarity with certain languages, and even some exotic companies require you to "get a deeper understanding of OOP

or FP design mode ". 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 criticized a lot of language flaws in the article, in the actual work I have seldom with people

Argue about this. 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 need to see it inside.

What type of processor, how many cores, how much frequency, how many L1 cache,l2 cache ..., how much memory and hard disk, the monitor resolution, graphics card is what GPU, Nic speed, and so on various "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 the model contains Intel's i7 processor, this is better than i5, DDR3 memory

So much faster than DDR2, SSDs are 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 have learned these traits through "some language,"

By mastering the fundamental concepts of these features, you can apply this knowledge to any other language at any time. 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. Having a problem at hand, he could take a two-minute look at the manual in the language,

Look 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 in the back, 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". Now there are recursion in the language,

You may not know, however, that early programming languages do 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 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 tool nature, causing beginners to waste too much time on them.

There is no understanding of 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! "And, in turn, they remember the meaning of the various" format characters "of printf, to enable them to print out a variety of complex formats,

Even ask 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 don't 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 of can't remember, 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 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 far from the language syntax such as Java,c++,python, but it can help you understand any of these OOP languages

The concept of "object-oriented" can even help you understand the differences in 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 and use it almost immediately, and write high-quality code.

Wang Yin: How to master all the programming languages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.