What's the difference between C++ and Python
2015-07-20 11:07
197 查看
In Principle
1. C++ is a "statically typed" language, while Python is a "dynamically typed" language.
In one case, the types of the main components of the set of instructions (the computer program) are explicitly declared while in the other case they aren't.
In Practice
2. C++ is "faster" than Python. C++ is typically a "compiled" language while Python is typically an "interpreted" language.
With C++, the instructions are very well understood with all types specified and so they are translated into machine code (they are compiled) and executed unambiguously by the computer ...while with Python a separate computer program has to figure out
what the Python instructions really mean [2,3] and how to "interpret" them to produce an output. The overhead of running this extra program versus simply just running the well defined machine code typically ensures that C++ runs much faster than Python.
3) Python is more concise than C++
Python is considered to be cleaner and more direct, with emphasis code readability.
Though this is certainly not an absolute truth, the example also shows one of the reasons why Python code tends to be shorter than that written in C++ (i.e. there is no need to declare types explicitly and this literally saves space in written code). Smaller
code size for the same task leads to "rapid prototyping" and this is partly why one would use something like Python when speed of development is important.
4) Python has garbage collection while C++ not.
1. C++ is a "statically typed" language, while Python is a "dynamically typed" language.
In one case, the types of the main components of the set of instructions (the computer program) are explicitly declared while in the other case they aren't.
In Practice
2. C++ is "faster" than Python. C++ is typically a "compiled" language while Python is typically an "interpreted" language.
With C++, the instructions are very well understood with all types specified and so they are translated into machine code (they are compiled) and executed unambiguously by the computer ...while with Python a separate computer program has to figure out
what the Python instructions really mean [2,3] and how to "interpret" them to produce an output. The overhead of running this extra program versus simply just running the well defined machine code typically ensures that C++ runs much faster than Python.
3) Python is more concise than C++
Python is considered to be cleaner and more direct, with emphasis code readability.
Though this is certainly not an absolute truth, the example also shows one of the reasons why Python code tends to be shorter than that written in C++ (i.e. there is no need to declare types explicitly and this literally saves space in written code). Smaller
code size for the same task leads to "rapid prototyping" and this is partly why one would use something like Python when speed of development is important.
4) Python has garbage collection while C++ not.
相关文章推荐
- c++ 11新特性
- [C++设计模式] adapter 适配器模式
- POJ3069 Saruman's Army
- C++知识点总结(5)
- C++知识点总结(5)
- 大话设计模式C++实现-文章7章-代理模式
- [C++设计模式] command 命令模式
- c语言求最大公约数和最小公倍数
- 【C++】修改VS2013的默认堆栈大小
- 彻底搞清 C/C++中a++与++a的区别
- 步步为营(三)贪心(2)选择不相交区间
- C++ HOJ 约瑟夫问题 之 神牛代码
- C++ 简单读写文本文件、统计文件的行数、读取文件数据到数组
- [libxml2]_[C/C++]_[使用libxml2读取分析xml文件]
- [libxml2]_[C/C++]_[使用libxml2读取分析xml文件]
- C语言按关键字搜索文件夹中文件的方法
- C语言函数指针与回调函数
- C++中通过指针修改类内私有成员变量 & 类的大小
- C/C++校招笔试面试经典题目总结五
- 线程安全的SRILM语言模型c++接口