========================================================== ==============
Note:
I haven't published a document for a long time. Post a new article. I posted it directly from the Word without careful formatting.
For a detailed introduction to the dynamic features of DLR and C #4, please refer to my article 《. NET 4.0 Object-Oriented Programming secrets (application), the book is currently in the editing and publishing process, is estimated to be listed in December.
The technical resources related to this book will be published in the blog and CSDN blogs.
========================================================== ========================================================== =====
Jin xuliang
In recent years, in the programming language ranking [1] released by tibench every month, C # is always the top 10, and in the programming language ranking in the last 10 years, C # The general trend is increasing. C # There are many factors that are working to make such achievements. Among them, it is impressive to be forging ahead in terms of language features (figure 1 ).
Figure 1 innovations of C # versions
C #4, released in 2010, has the characteristics of dynamic programming languages.
1. ZTE of Dynamic Programming Language
Dynamic Programming Language is nothing new. As early as the mainstream of object-oriented programming language, people have already used dynamic programming language for development. Even when object-oriented programming languages, such as Java, C #, and C ++, were thriving and popular, dynamic programming languages were quietly tapping into the market, it occupies a considerable field of development. For example, JavaScript has become the mainstream language for Web clients.
In recent years, dynamic programming languages have become increasingly popular, such as Python and Ruby, which are very active and widely used.
Here is a question: why do we need to apply dynamic programming languages during development? What are the advantages of dynamic programming languages compared with static programming languages that are very mature and powerful such as C # and Java?
To put it simply, using dynamic programming language development has the following features:
(1) Supports the development mode of REPL (Read-evaluate-print Loop: "Read A. Execute a. Output" Loop iteration). The whole process is concise and clear, pointing to the core of the problem.
For example, Figure 2 shows how to use IronPython [2] to program and compute "1 + 2 + ...... + 100 "screen, we can quickly enter a piece of code to complete the accumulate sum, and then we can see the result immediately:
Figure 2 Use IronPython for programming
If you use C # for development, it will be much more troublesome. You must first create a project with Visual Studio, add a class to it, and write a method in the class to complete the summation function, compile the code that calls this method, compile and correct the code, and finally obtain the required results ......
Obviously, the REPL development model of dynamic programming language is very attractive for short jobs.
(2) convenient extension. You can adjust the code at any time. You can simply add the required functions to dynamic objects without removing them. This modification can take effect immediately, and does not need to modify the definition and declaration of the type as C # does, and the new method is available after compilation.
In other words:Dynamic Language Programming does not require "heavyweight"OOADThe entire development process is quickly iterated and never dragged on..
(3) The type resolution of dynamic programming languages is completed at runtime, which saves a lot of unnecessary type conversion code. Therefore, compared with static programming languages, code written in dynamic programming languages is often more compact and less intensive.
Dynamic Programming Languages have two major weaknesses:
(1) many errors in the code can only be detected at runtime, and must be supported by a specific runtime environment, which is not convenient for testing, it does not support many software engineering tools used to improve the code quality. Therefore, it is not suitable for developing large-scale application systems that include complex processing logic.
(2) Compared with static programming languages, Dynamic Programming Languages provide low programming performance. However, with the continuous development of computer hardware and software technologies, such as the wide application of multi-core CPUs, dynamic programming language engines and runtime Environments