Programming Language (2)-temptation

Source: Internet
Author: User

(2) coming out ......

There is a common idea that many people believe that programming languages are the same. The extension means that if you master one of the languages, you can quickly learn other languages. For example, if you have learned C, you will know that C ++ and Java functions must be declared before they are used. The code is enclosed in braces. You can see that I will soon learn. I think the reason for the popularity of this opinion is that it is tempting. Many programmers are dazzled or even a little scared when they see this sentence: in fact, you only need to learn one of these languages to deal with all the languages. This greatly reduces the learning cost of technology in the subconscious. After all, technological development is changing with each passing day. If there is a point of view that reduces the learning cost, then the popularity of the technology will be understandable.

But it's slow. Is that right? Can I be familiar with other languages easily if I am familiar with one language?

Unfortunately, I do not think this is correct for two reasons.

 

First of all, there is a very simple truth. If there are similar programming languages in the world, why are there so many different programming languages? The fact is that different programming languagesThere is a big difference, as big as most people think.

Programming languages are integrated into the idea of Language designers. One of the key differences lies in the Abstraction Level of languages. C is a process, Java is an object, and LISP programs are built by functions. In contrast, C is closer to machines, while lisp is more abstract. For example, to write a function Foo, the function Foo takes a list of LST and another function OP as the parameter. What Foo does is to call op for every element in the list lst, generate a new list and return it.

How can I use C ++ to complete this task? (Note: This code can be compiled and run in vs2010, but not in GCC. If you have any knowledge about the cause, please kindly advise)

template<typename T>list<T> foo(list<T> lst, T(*op)(T)) {  list<T> result;  for (list<T>::iterator iter = lst.begin();       iter != lst.end();       ++iter)    result.push_back(op(*iter));  return result;}

 

Let's take a look at how scheme solves the problem.

 

(define (foo lst op)  (if (null? lst)      '()      (cons (op (car lst)) (foo (cdr lst) op))))

In contrast, the difference is very obvious. C ++ is actually very close to machines like C. Templates and pointers are used to complete such a small task. The template is used to adapt to various data types. Because different data types occupy different spaces, the compiler must know that the function pointer is used to tell the compiler function address. Therefore, C has been upgraded to C ++, but these low-level concepts still cannot be removed.

 

As for scheme ...... It is easy to complete such a task. If you want to understand this code, it takes 10 minutes to understand the seven basic elements of scheme. In scheme programming, everything is a table (list). In addition, it supports high-order functions and dynamic types, so it is easy to complete this task, almost completely without involving the underlying concepts of computers. In contrast, the abstraction level is higher than that of C ++.

It is the difference that makes the actual difference between different languages bigger than it looks.

 

The second reason is related to people. People are inert, and programmers are no exception. If a programmer has been programming in one language for a long time, his or her thinking will surely be affected. The abstract level of thinking is limited. For example, just two pieces of code, programmers familiar with C ++ may think that scheme's way of thinking is hard to understand, while scheme Programmers think that using C ++'s thinking is limited. I am also confused. I did not change scheme for almost a year after my freshman year. Later I wanted to write a theorem proving machine with Tom using scheme. The result was that the two of us sat down for one night and were dumpted (o) however, I think it is easier for scheme programmers to understand C ++ code, because computers are always dummies ~

Programmers may find that the language they are familiar with is a hot ground. Familiarity means security. Turning to unfamiliar languages involves not only reversing the inherent prejudice to accept new ideas, but also being risky. These factors are more "stimulating" the programmer's inertia.

 

To sum up, whether it is based on the differences between languages or the inertia of the human itself, to master one of the languages, I don't think it is correct to quickly learn other languages.

Of course, don't be too pessimistic about these many languages. As mentioned earlier, scheme programmers are easier to understand C ++ code, because I think scheme is more advanced than C ++. Another reason is that more advanced languages enable programmers to focus more on the essence of programming. If the essence is grasped, in the face of low-level languages, it is only a technical topic to deal with the legacy problems of those machines. In addition, successful people can overcome inertia better than ordinary people, while excellent programmers are constantly learning. Since the world has so many rich ideas, it is easy to be diligent and diligent. The so-called stone of other mountains can attack the jade.

 

-- TT

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.