In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you the differences between C++ and javascript. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Differences: 1, C++ is a static language, while javascript is a dynamic language; 2, C++ is a compiled language, while javascript is an interpretive language; 3, C++ has a pointer, but javascript does not; 4, javascript is a functional programming language, C++ is not.
The operating environment of this tutorial: windows7 system, javascript1.8.5&&C++17 version, Dell G3 computer.
The difference between C++ and javascript
1. C++ is a static language and js is a dynamic language.
The differences are as follows:
Static language:
Type checking can also be done when it is not executed, and some logic errors can be detected to a certain extent. But too many declarations make the program redundant.
At the beginning of writing code, consider what types of variables and expressions should be, which is conducive to writing good, high-availability programs.
It not only works for compiler hints, but also for understanding code.
Problem: not flexible enough to write a program without defining a type.
Dynamic language:
The biggest advantage is the simplicity of the code.
Very flexible.
Problem: the running speed will be relatively slow, so type checking should be done. The biggest disadvantage is that errors cannot be detected without execution.
2. C++ is a compiled language and js is an interpretive language.
C++ compilation process: preprocessing-> compilation optimization-> assembly-> link.
Parsing mechanism of Js: preprocessing (segmented read code preprocessing)-> interpretation execution
3. C++ has pointers, but js has no pointers.
In C++ assignments, all basic types are copied directly, while custom types can choose to copy deeply (copy) or shallow copy (reference) because of the existence of pointers. In js, all primitive type assignments are duplicated, while all other type assignments are references.
4. Js is a functional programming language, not C++.
Js treats a function as an object and can treat it as an input parameter and output value of a function (a higher-order function).
If C++ wants to use a function as an input parameter to other functions, that is, to implement a higher-order function, it must pass a function pointer (often passing an extra parameter of type (void *) as an argument to a function).
5. C++ 's inheritance is based on class, and js's inheritance is based on prototype.
In C++, inheritance is done through classes. It is more in line with people's intuitive thinking. At the same time, after generating a class, you cannot modify it unless you modify its definition. (Ruby can append the contents of the class after definition based on the inheritance of the open class.)
In js, inheritance is done through a prototype chain. You can also modify the prototype chain after definition. At the same time, you can also modify the prototype chain of built-in types to expand built-in types (with caution, monkey patching can cause significant changes to built-in objects to produce unexpected behavior).
What is the difference between C++ and javascript? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are 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.