Comparison between dynamic and static languages

Source: Internet
Author: User

I. What are the advantages of static languages?

From Robbin from http://www.javaeye.com/article/33971? Page = 7

ReferenceIt is a strong quasi-static language such as Java or C # That also has great advantages in implementing complex business logic, developing large business systems, and applications with long lifecycles.

 

This is a common sense. I admit that in my subconscious, I think static strong-type languages are suitable for developing complex and large systems. However, the weak scripting language is not suitable for developing too complex and too large projects. However, during my participation in this discussion, I suddenly began to doubt this point of view. Is this true?

First define the standard:

A strong language (static Language) is a language that requires variable/object type declaration. It usually needs to be compiled and executed. For example, C/C ++/Java/C #

A weak language (Dynamic Language) is a language that does not require variable/object type declaration. Generally, compilation is not required (but compilation is also required ). For example, PHP/asp/Ruby/Python/perl/ABAP/SQL/JavaScript/Unix shell.

 

ReferenceViewpoint 1: The static type language is forced to declare the type, so the IDE can achieve good code awareness. Because of the support of the IDE, it is more secure to develop large systems and complex systems.

 

For Java, idea/eclipse is indeed very powerful in terms of Code awareness, which can undoubtedly increase control over complex systems of large systems. However, apart from Java's powerful ide weapons, it seems that other languages have never had such a strong IDE. C # Visual Studio is very strong in GUI development and wizard, but the difference between Code awareness and eclipse is not half past one. As for Visual C ++, it is simply a compiler. I am ashamed to mention the word visual. Not to mention that many C/C ++ developers have started to write hundreds of thousands of lines of code in VI too many developers. In particular, millions of lines of code such as Linux kernel, that is, the code written by VI, is complex enough, large enough, and long enough for a long life cycle.

 

ReferenceOpinion 2: static languages are relatively closed, which reduces the code infringement caused by third-party development kits. Dynamic Language is poor at this point. I think everyone has had the experience of downloading a JS package from the Internet and putting it in the project code for a conflict.

 

That is to say, the static type language can ensure that the package namespace is separated to avoid naming conflicts and the code is well isolated. However, this argument is unconvincing.

In static language, both C and VB lack good namespace separation, which is prone to conflicts. However, the system they developed is not big enough and not complex enough.

The dll version conflict developed by Visual C ++ is also notorious. It seems that the C ++ namespace has not brought much help to it.

In Dynamic Language, Ruby, Python, and Perl all have better namespaces, especially Python and Perl. For example, the third-party libraries on CPAN are ton-to-ton, I have never heard of any conflict issues.

It is true that dynamic languages such as PHP and JavaScript that lack namespaces are prone to problems, but this seems to be due to their lack of OO mechanisms, rather than their dynamic types?

Speaking of large systems and complex business logic systems, Google has developed many things in Python, which proves that dynamic language cannot be used as a large complex system. In fact, I personally think:

Dynamic Language, especially advanced dynamic language, enables people to focus on the implementation of business logic, that is, the process of thinking is the implementation process, without being distracted by programming issues, the process of describing problems with DSL is the programming process. In this respect, Unix shell, Ruby, SQL, and even PHP are well-deserved DSL languages. Obviously, static language basically does not meet this requirement.

What are the advantages of static language? I think the execution efficiency is very high. So whenever you need to focus on the execution performance, you must use a static type language. Other aspects do not seem to have any special advantages.

Several comments:

1. Let's look at Yahoo. It was written in PHP. You may not be able to achieve that performance with Java.

2. I feel that dynamic language is flexible enough, so although it allows people to focus more on the implementation of business logic, it is also closer to the direction of artificial intelligence, however, it also relies more on the technical skills of developers. It is difficult for beginners and intermediate developers to make good use of it. Static language is more consistent with the basic subjects of Computer Teaching (C/PASCAL/basic). Therefore, it is better for new students to accept and learn. Therefore, I think it is still the main factor for learning, training, and development costs. An inappropriate example: Javascript Regular Expressions are powerful but not easy to understand and learn. Generally, only copy/paste can be used. Therefore, in many cases, we prefer to write standard JS Code.

3. I think a strong quasi-static language like Java has another important feature. Once the programmer has mastered the syntax rules and writing standards, the readability of the written program will be much stronger, because it has more restrictions. In a large system, it is critical for team members to know what the other party is writing to each other, which also forms an important basis for communication.

However, although Ruby seems to be more in line with "Problem description: solving the problem", the same logic can also meet the requirements, but the writing is quite different. I have seen a ruby solution that uses one line to solve the number read algorithm. Who can understand it?

4. What I often see is that Java programmers write hundreds of lines of code in big cases, just a few lines of Ruby.

5.Static LanguageIt refers to the language in which the data type of the variable can be determined during compilation. Most static language types must be declared before using the variable, some modern languages with the ability to deduce types may partially alleviate this requirement.
Dynamic LanguageIs the language used to determine the data type at runtime. You do not need to declare the type before using the variable. Generally, the type of the variable is the type of the value to be assigned.
Strong LanguageIs a language that cannot be converted once the type of the variable is determined. In fact, the so-called seemingly conversions are all achieved through intermediate variables, and the type of the original variables is certainly not changed.
Weak LanguageOn the contrary, the type of a variable is determined by its application context. For example, the language directly supports strings and integers and can be done directly with the + number. Of course, in a strongly typed language that supports Operator overloading, this can also be achieved through external implementation in the form, but this is completely different from the meaning.
Generally, Java/python is strongly typed, while Vb/perl/C is weak.
However, compared with dynamic/static language classification, strong/weak types are more of a relative concept.

6. If dynamic language is used, unit testing requires much more work than static language.

Robbin returns this one. In fact, you ignore this point. When a framework like ror is used, the amount of application code is very small, so there are very few parts to be tested, this is much less than testing with a static language.

In addition, the lack of unit testing is not as scary as you said. Now we haven't written unit tests. Ruby code already has more than 6000 lines, programming, troubleshooting, and so on. It's as easy as that. How can you blow it.

7. the complexity of the business system lies in the difficulty of organizational communication. A large company has an individual who can clearly understand the business process, this person can also tell the software personnel about the process, which is simply impossible. In this way, Ruby is advantageous. You can quickly develop, promote communication, and develop a model for business personnel to see. It is much easier to use and naturally communicate with each other.

The development efficiency of a developer is much higher than before, mainly because of the progress of the development language and compiler. This trend will only continue, so do not stick to the old dogma, java is also constantly improving. It adds reflection, assert, generic, and script support in the next version.

8. in fact, in addition to performance considerations, the biggest advantage of a static type language is that it can provide static type security. The compiler can check whether every function call has a correct name, is a parameter of the correct type provided. Such a system, coupled with the custom type function, enables many errors (more than many people think) to be detected and located during compilation.

9. I have seen some people complain about Dynamic Language in discussions on similar topics on Slashdot. The buddy is engaged in banking systems and has about 0.1 million lines of Python code, at last, I felt unable to maintain because of the small hidden errors. It seems that I have to go to the Java platform. (If I read Slashdot's post and comments on Ruby and python over the last two years, I can still find this post)
According to this buddy's description, his main problem is that there is no unit test, the unit test does not meet the statement coverage, or the weak condition combination overwrites, which leads to some abnormal processes, these untested statements cause syntax errors and eventually the entire program fails. this is a very serious issue for business systems. As I mentioned earlier, my own program has been killed on logging statements more than once, because at first I did not test the feasibility of such statements.
As to whether unit tests are useful or not, thousands of lines of code for a three-five project cannot be seen. As a matter of fact, traditional development can still make a lot of things. Five years ago, there was basically no unit test in the domestic development mode, so it could be quite easy.
However, as far as my own experience is concerned, although I do not follow TDD, unit testing is sufficiently detailed, the confidence level provided by this test network (especially when code modification and large-scale refactoring) is unimaginable. I estimate that thousands of lines of programs will benefit from incremental unit tests.
10. The size of the compiler's help to programmers should vary with people. Many of the statements that can be found by the compiler are incorrect typing and spelling. For Robbin, even if there is no compiler, checking this error is a piece of cake. However, for programmers with less experience, the situation may be quite different. After all, a major difference in programmer experience is the difference in debug capability and experience. For the experts, it may take a couple of hours for new users to read the program twice. I have encountered this problem many times in actual projects.

 

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.