What you have to know on the way to the architect (1)--the concept of programming language

Source: Internet
Author: User

It is extremely naïve to argue that a programming language is a good one in the network. Because the language used is different and divided into different camps, it is extremely inappropriate to compete against the pros and cons, which is not only a distant distance from the architect, but also a great distance from a high-yielding programmer. However, it is not said that the discussion about programming language should not be, the programming language is human design, the flaw must have, need is at a higher level of discussion. A programmer with an architect degree can have a preferred language and a nasty language, but there should be no obstacles in the face of programming language, at a higher level, any language can be learned within a week , and any language can have a customer's evaluation and choice.

No mainstream programming language has the three elements of input, output and logic control structure , although there are different classifications such as process oriented, object-oriented and so on, this is only the organizational form of these three elements. Logical control structures include order, selection, looping, and [direct] jumps . The choice and the loop are essentially logical judgments + jumps . Just select and loop the two forms of jump, plus the order to achieve all the control structure, so the direct jump in some languages are discarded.

Examine any block of code that has input and output. What does the input have? Parameters of a function or method, variables created or declared, direct quantities, input streams, and so on. And what about the output? The return value of a function or method, a reference to a function or method, or a parameter of a pointer type, a variable assignment, an output stream, and so on. Look at such a simple assignment statement `int a = b*12;` . This is a simple sequential structure, which can be viewed simply as a step from the advanced language level, from assembly and machine language to a sequence of operations performed sequentially, in which a is the output, B is the input of the variable type, and 12 is the input of the direct magnitude type.

At present, if a programming language only considers these three basic elements, it is not necessary to exist, especially in machine language, assembler language gradually fewer people will, even C language. Therefore, when designing a programming language, it is necessary to consider how to combine these three elements , if you have to solve some of the problems that have to face in development . How to combine these three elements now only need to consider the object-oriented one. The problems that have to be faced in development are two of the most critical----memory management and program execution methods. Program execution methods are compiled to execute the file after execution, from the source code directly executed two kinds.

How to solve these two kinds of problems, constitute a programming language of the greatest features . For example, Java and C # solutions to the first problem are: Single inheritance, everything is class wrapper, interface; C + + solves the first problem: multiple inheritance, class, and function parallelism. Java, C #, C + + in the execution of the way there is no essential difference, all need to compile the results and then execute; Java and C # although there are multiple VMS or runtime things, if you integrate these two things with the operating system, there is no difference between the three languages. The languages Python and Perl can run directly from the source code in the execution environment. Java, C # and C + + have significant differences in memory management methods. Java and C # bind the types and types of storage together, class (reference type) must be stored on the heap and be automatically freed, struct and base type (value type) must be stored on the stack (automatically released, of course) A reference type object is created with a value type object that indicates the location of the object, and the type of the value type object with the position indicator is called a reference, and the object of the value type is created to obtain the object itself. While the type and type of C + + is not bound, any type can be stored on the heap or on the stack, and the memory occupied by objects stored on the heap needs to be explicitly encoded in the code to be freed.

Note the preceding wording, "any mainstream programming language" rather than "any programming language", because the mainstream programming language is imperative, and only the imperative language contains the element of logical control structure . Imperative language feature is the need to tell the computer what steps to complete the function, there is a logical control structure in order to have steps. There has been another language----declarative language, the function is a declarative vest or a declarative way of implementation. Declarative language is characterized by the need not to tell the computer to solve the problem of the steps, only enter what needs and wait for the output of the results, then the declarative language is no logical control Structure , in the current von Neumann architecture of the machine more accurate statement is the declarative language hidden Logical control Structure . Declarative languages are best at data processing, and declarative languages cannot accomplish everything that imperative languages can accomplish. A very typical example is SQL, which uses SQL to query without specifying "read all data and then one by one to return" and so on, but through the "Select what from table WHERE condition" the statement entered the " From where to find what meets what conditions "this demand. To improve programming efficiency, many object-oriented programming languages include "declarative Programming" features, such as lambda expressions, the ability to pass in Delegate (C #), function (JS, Java), functor (C + +), callback + +) methods such as executable objects.

What you have to know on the way to the architect (1)--the concept of programming language

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.