0 x fa in the complete hydrological series: bloated design philosophy behind Functions

Source: Internet
Author: User

Let's talk about the Function Design in C # language today-this is another serious problem in C # language design philosophy apart from the performance problem-it is not necessary to be bloated. C # functions have the following four types of problems:

 

1. C #Functions are not abstract
A function is not a basic element of a program and does not reflect the key abstraction of the program. Data Segment Storage program execution status, code storage execution instructions? What is the function, how many elements of the stack are pressed, and then the value of the EAX register is changed?

 

2. C #Functions are not universal
Most programs do not have function design requirements and do not implement functions.

3. C #Low function implementation performance
A. The function call is backed by the pressure stack, which is then returned by EAX. the operation efficiency of the stack is much lower than that of the register.

B. C # by default, the function will save the call site, and repeated storage and recovery will cause a large amount of performance loss (see DOS interrupt design)

 

4. C #Function is unnecessary--This isC #The biggest problem with functions is also the focus of this Article

The function is just a variant of the jump. It can be fully implemented using Stack operations.

 

It turns the so-called commonly used program logic into a part of the language structure.C #Another serious mistake in design ideas(The first serious error is for the so-called function, regardless of the performance cost, which is detailed in the previous article "nonexistent ).


Similar examples in C # include the use of if else to replace conditional jump and the use of operators to replace CPU commands-I am here to criticize it and no longer write articles.


If you can use built-in jump and built-in expressions in the C # language, do you want to support string operations?

 

In addition, these common programming methods are embedded in the language, this will cause the programming method to lose implementation flexibility or damage the performance (for example, C # function limits the need to use the pressure stack method to save the call parameters, this restriction causes the program to lose its implementation flexibility)

 

Using libraries to support various Logics is the main path of the programming language. Integrating logic into a part of the language to play with cool, the final result is that the language is becoming increasingly bloated and growing. I hope C # designers will stop on this road.

 

Postscript:

The so-called discussion is helpful for learning, provided that all parties have sufficient basic knowledge and background, and everyone must discuss the problem with the idea of solving the problem.

If a person makes a completely simple remark, a seemingly non-positive statement, in the case of "win", and a sentence is not allowed, then this discussion is worth mentioning.

Although this article focuses on entertainment, the arguments in it are not imaginary,

This hydrology is just a mirror, and I just want to make it clear that no matter how absurd a conclusion can be said, it seems justified.

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.