Dynamic language static language strongly typed language weakly typed language

Source: Internet
Author: User

What is the advantage of static language?

References is a strong type of quasi-static language like Java or C # that has a strong advantage in implementing complex business logic, developing large business systems, and applications that have a long life cycle.

This is a common sense that exists in everyone's heart. I confess that I myself also feel that static strongly typed languages are suitable for developing complex, large systems. The weak type scripting language is not suitable for developing too complex, too large projects. But in the process of participating in this discussion, I suddenly began to question this point of view, is it true?

Define the criteria first:

A static type language is a language that can be determined at compile time for a variable's data type, and most static type languages require that the data type must be declared before the variable is used, and some modern languages with type derivation capabilities may be able to partially mitigate this requirement.
A dynamic type language is a language that determines the data type at run time. A type declaration is not required before a variable is used, and the type of the variable is usually the type of the value being assigned.
A strongly typed language is a language that cannot be converted once the type of the variable is determined. In fact, the so-called seemingly transformed, are through the intermediate variables to achieve, the original variable type must be unchanged.
Weakly typed languages Conversely, the type of a variable is determined by its application context. For example, the language directly supports strings and integers can be done directly with the + number. Of course, in a strongly typed language that supports operator overloading, this can be done formally in the form of an external implementation, but this is a completely different connotation.
Generally speaking, Java/python are strongly typed, and vb/perl/c are weakly typed.

References Point one: Static type language because of the type mandatory declaration, so the IDE can do very good code-aware, because the IDE's backing, so the development of large-scale systems, complex systems are more secure.

For Java, Idea/eclipse does have a strong sense of code awareness, which can undoubtedly increase the ability to control complex systems in large systems. But in addition to Java having such a strong IDE weapon, it seems that other languages have never been so strong IDE. Visual Studio in C # is strong in terms of GUI development and the wizard, but the code-aware capability and eclipse are not at 1:30. As for Visual C + +, it is simply a compiler, ashamed to mention the word visual. Not to mention that so many C + + developers are operating VI Chi Chi wrote hundreds of thousands of lines of code. In particular, such as the Linux kernel millions of lines of code, that is, the vi written out, complex enough, large enough, long enough life cycle of it.

References point two: Static language relatively closed features, so that the third-party development package of code infringement can be reduced to very low. Dynamic language in this aspect of the poor performance, I think we all have to download a JS package from the Internet, and then put in the project code conflict Experience

This means that the static type language can guarantee the namespace segmentation of the package, thus avoiding the naming conflict and the good isolation of the code. But the argument is also unconvincing.

C,vb in static type languages lack good namespace segmentation, which is prone to conflict, but it does not affect the system they make is not big enough, not complex enough.

The DLL version conflicts developed by Visual C + + are notorious, and it seems that the C + + namespace does not give it much help.

In dynamic type languages, Ruby/python/perl have better namespaces, especially Python and Perl, such as the third-party library on cpan tons, and never heard of any conflict.

Admittedly, dynamic languages that lack namespaces like php,javascript are prone to problems, but this seems to be because they lack the OO mechanism, not because of their dynamic type.

When it comes to large-scale systems, complex business logic systems, many of Google's things are developed in Python, which proves that dynamic type language is not a big, complex system. In fact, I personally think:

Dynamic type language, especially the advanced dynamic type language, can let people not need to think about programming problems, but focus on the realization of business logic, that is, the process of thinking is the realization process, the procedure of describing the problem with DSL is the process of programming, which is like Unix shell,ruby,sql, Even PHP is a well-deserved DSL language for the field. However, it is obvious that static type language does not satisfy this requirement.

What is the advantage of the static type language? I think that is the implementation of very high efficiency. So whenever you need to focus on performance, you have to use a static type language. Other aspects do not seem to have any particular advantage.

Several comments:

1. Look at Yahoo!, it's written in PHP. You may not be able to do that with Java.

2. My point of feeling, dynamic language is flexible enough, so although it can make people more focused on the implementation of business logic, but also to the direction of artificial intelligence to go closer, but it is also more dependent on the developer's own technical skills, beginners, intermediate developers, it is difficult to use it very well. But static type language, and our computer teaching basic subject (C/PASCAL/BASIC) continuity is better, so for the newly graduated student, better accept and study. So I think the main factor is the study/training/development cost. An inappropriate example: JavaScript's regular expressions, though powerful, are not easy to understand and learn. Generally only copy/paste to use. So many cases, still prefer the handwriting standard JS to deal with.

3. I feel that a strongly typed quasi-static language like Java also has an important feature. Once the programmer has mastered grammar rules and writing specifications, the written program is much more readable because it has more limitations. In a large system, it is important for team members to know what each other is writing about, which is also a key basis for communication.

However, Ruby's language, although it seems more in line with the "description of the problem is to solve the problem", but for the same logic, the same can meet the requirements, the wording is quite different. I have seen a 1-line solution to solve the number-reading algorithm of the Ruby method, who can understand?

4. What I see more often is the Java programmer fart big thing to write hundreds of lines, Ruby a few lines will be done

5. A static type language is a language that can be determined at compile time for a variable's data type, and most static type languages require that the data type must be declared before the variable is used, and some modern languages with type derivation capabilities may be able to partially mitigate this requirement.
A dynamic type language is a language that determines the data type at run time. A type declaration is not required before a variable is used, and the type of the variable is usually the type of the value being assigned.
A strongly typed language is a language that cannot be converted once the type of the variable is determined. In fact, the so-called seemingly transformed, are through the intermediate variables to achieve, the original variable type must be unchanged.
Weakly typed languages Conversely, the type of a variable is determined by its application context. For example, the language directly supports strings and integers can be done directly with the + number. Of course, in a strongly typed language that supports operator overloading, this can be done formally in the form of an external implementation, but this is a completely different connotation.
Generally speaking, Java/python are strongly typed, and vb/perl/c are weakly typed.
However, compared to dynamic/static language classification, strong type/weak type is more of a relative concept.

6. With dynamic languages, unit tests work much more than static languages

Robbin back to this one. In fact, you have overlooked the point that when using a framework like ROR, the amount of code applied is very small, so there are few parts that need to be tested, much less than the ones that need to be tested with static type languages.

In addition, the lack of unit testing is not as scary as you say. We do not write unit testing now, Ruby code has more than 6,000 lines, programming, or wrong, just as easy, which you blew so horrible.

7. The complexity of the business system lies in the difficulty of organizational communication, a large company in which a person can make the business process clear and good, the person can also explain the process to the software staff that is almost impossible to find. This use of Ruby instead has advantages, can quickly develop, promote communication, develop a model for business people to see, use, natural communication is much easier.

Now a developer's development efficiency is much higher than before, the main reason is because the development of language and compiler progress, this trend, will only continue, do not hold the dogma of the past, Java is constantly improving, add reflection, add assert, add generics, next version, Script support is also needed.

8. In fact, static type language, in addition to performance considerations, the biggest advantage is that you can provide static type security, the compiler can check that each of your function calls is not the correct name is written, is not provided with the correct type of parameters. Such a system, with the function of custom types, can make many errors (more than many people think) can be found and positioned at compile time.

9. I have seen in the discussion on similar topics in Slashdot that there are people complaining about dynamic language, the man is engaged in the banking system, about 100,000 lines of Python code, and finally because of the small hidden errors constantly feel unable to maintain, it seems to go to the Java platform. (If you look at the posts and comments on Ruby and Python for nearly two years on Slashdot, you'll probably find this keep abreast)
Judging from this buddy's description, his main problem is that there is no unit test or unit tests that do not reach the statement overlay or the stronger weak conditional combination coverage, causing some abnormal processes to occur, Passing through these non-tested statements results in a syntax error and eventually the entire program hangs up. This is a very serious matter for business systems. As I said earlier, my own program has died on logging statements more than once, because I did not initially test the accessibility of such statements.
As for the unit test there is no use, 35 people of the project thousands of lines of code is not visible. In fact, the workshop-type development can still make a lot of things, 5 years ago, the domestic development method is basically no unit test, so also can play to turn.
However, as far as my own experience is concerned, although I do not follow TDD, unit testing is exhaustive and the test network gives me confidence (especially when modifying code and larger refactoring) that is unthinkable before. I estimate that thousands of programs will be able to benefit from the incremental unit tests.
10. The compiler's help to the programmer is exactly how big, this still should be human-like. Many of the things that the compiler can find are typographical errors and misspellings. For Robbin, even without the compiler, it is a piece of cake to check for this error. But for the inexperienced programmer, the situation is probably a lot different. After all, an important aspect of the programmer's experience is the difference between debug capability and experience. It may take one or two hours for some novices to read the two-time program and find out the errors, which I have encountered many times in the actual project.

Here are some examples

No type: assembly
Weakly-typed, Static-type: C + +
Weak type, dynamic type check: perl/php
Strongly typed, static type checking: java/c#
Strongly typed, dynamic type checking: Python, Scheme
Static explicit type: JAVA/C
Static implicit type: Ocaml, Haskell



Dynamic language static language strongly typed language weakly typed 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.