In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to distinguish between dynamic and static in the programming language, which is very detailed and has a certain reference value. Friends who are interested must read it!
Dynamic type & static type
According to the literal meaning, dynamically typed language, that is, the type of the language is dynamic, what kind of type is dynamic? Quite simply, this type does not need to declare a type, and exactly what a type is is only known at run time. For example, python,PHP is a dynamically typed language, and you will find that there is no such thing as type declaration in python and PHP, and neither does JavaScript.
In JavaScript, declare a variable like this:
Var a Tina = "W3cschool"
We can see that when we first declared the variable, we didn't specify the type of the variable (var here is not a variable type, but just a declared keyword), and we determined the type of the variable in subsequent references (this should be a string, as you can tell from the code).
In python and PHP, variable declarations are more aggressive (keywords such as var are not even needed in variable declarations in python and PHP)
In python:
A = "W3Cschool"
In PHP:
$a = "W3Cschool"
The difference between dynamic type and static type is not only in the declaration of variable type, but also in the declaration of function. Take JavaScript as an example, when defining a function, we do not need to consider the type of return value, so it is enough to use a simple function when declaring a function, and there is no need to declare the type of formal parameter. Such a function can only know the specific parameter type when the data is passed in:
Function add (aformab) {return aforb;}
Next, let's take a look at how static types are done. Here are C language function declarations and variable declarations:
Int add (int aheadint b) {return aintb;} / * this is the function declaration * / int main () {int a; / * this is the variable declaration * / axi10; return 0;}
The biggest difference between the function declaration of static types and dynamic types is that the declaration of functions and variables is full of declaration-related keywords.
The respective advantages of dynamic types and static types can go to Baidu to search or follow follow-up articles. To put it simply, the use of dynamic types is flexible, and static types have relatively low requirements for compilers (saving the overhead of determining variable types). And static types are easier for code to read and understand.
Static types are easy for code to read and understand, as can be seen in the evolution of the python version. The introduction of the function of type annotation to the parameters and variables of the function in python3.6 solves the disadvantages brought by the dynamically typed language.
Summary
After introducing dynamic and statically typed languages, do friends have some understanding of the judgment that a language is a dynamic language? The following figure shows a quadrant division of dynamic (static) and strongly typed (weakly typed) programming languages, with some common languages listed above:
These are all the contents of this article entitled "how to distinguish between dynamic and static in programming languages". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.