开发者

What problems would you expect when switching from JS to C++? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

What problems would you expect whe开发者_StackOverflow社区n switching from JS to C++ ?


C++ is incredibly different from Javascript. A few main differences:

  • Static typing (usually types of variables are specified, most types are known at compile time)
  • Low level memory management (no GC so you'll have to allocate and free a lot of memory yourself)
  • Different object system: C++ is class-based, while Javascript is prototype-based. You'll also have to learn everything that this entails, e.g. access modifiers, class-based inheritance
  • Less safety than JS. C++ doesn't hold your hand much like Javascript does, if you don't allocate the right amount of memory or try to access an out-of-bounds array index, etc. your program will crash (and you've introduced a critical security flaw in the program as well)
  • Templates and everything that comes with that
  • I/O are different, obviously, because you're dealing with files rather than HTML and the DOM.

There are also obviously some trivial differences, e.g. you'll have to compile and link your programs before you execute them. You'll also have to learn a new standard library.

You may also find this amusing.


JavaScript is a very high level language which has found it's main application in the web. C++ is a very low level language compared to JavaScript. The main difference (painful difference) you will find is that C++ does not have a garbage collector. You need to allocate and free memory by hand.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜