[Reprinted] What is a strong language and a weak language?

Source: Internet
Author: User

Static Type Definition Language

A data type is a fixed language during compilation.Most static type definition languages force this, which requires you to declare their data types before using all variables. Java and C are static type definition languages.

Dynamic Type Definition Language

A language that discovers data types only during execution, opposite to a static type definition.VBScript and Python are dynamically defined because they are used to find the type of a variable when it is assigned a value for the first time.

Strongly typed language

A language that always enforces type definition.Java and Python are forced Type Definitions. If you have an integer that is not displayed for conversion, you cannot treat it as a string.

Weak Type Definition Language

A language that can be ignored, opposite to a strong type definition.VBScript is defined as a weak type. In VBScript, you can connect the string '12' and integer 3 to get the string '123'. Then, you can regard it as an integer of 123 without display conversion. But in fact their types have not changed. VB only automatically adds a CLONG () or (INT )() this is just a conversion function.This is actually due to the intelligence of the VB compiler, which is not the strength or weakness of the VB language.

Conclusion:

Static data is determined during type compilation; Dynamic Data is determined during type runtime; strong data types are independent and not easily converted; weak data types are not strictly differentiated, generally as long as the size is put down, it can be converted.This is an assembly-level viewpoint. This is not the case of Object-oriented Thinking. objects are not of the same size or type compatibility, but key interfaces must be the same for Type compatibility.

Dynamic language is not a weak type, which is not equivalent. Generally, dynamic languages are strongly typed, because they all follow the object-oriented perspective to design objects.

The disadvantage of Dynamic Language is obvious, that is, the lack of development environment and poor running efficiency. Of course, the language design is also not perfect (static language is more than 10 million, but C ++ is also one ).

The advantage is also obvious, that is, it is easy to write, with a high level, close to natural semantics. The reason for the low efficiency of Dynamic Language is not that the variable type is dynamic, but that the object method is dynamic, at this point, the dynamic type language is no different from Java.

What are the advantages of static language?

Viewpoint 1:The static type language can do a good job because the type is forcibly declared.CodeAwareness capability, because of the support of IDE, it is guaranteed 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.

Viewpoint 2: The static language is relatively closed, so that the third-party development kit can reduce the code infringement to a very low level. 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, can eliminate the need for attention.ProgramProgramming Problems, and focus on business logic implementation, that is, thinking process is the implementation process, the process of describing the problem with DSL is the programming process, such as UNIX shell, Ruby, SQL, even PHP is a well-deserved DSL language in the relevant field. 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.

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.