What's the difference between C++ and Python

47 篇文章 0 订阅
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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值