简体   繁体   中英

What are C++ interpreters used for?

I wonder what is the usage of C++ interpreters. When are they at their best?

Just like ANY interpreted language, they can be used as:

  • Embedded scripting language

  • Shell scripting language

As an example, please look at Ch usage: http://en.wikipedia.org/wiki/Ch_interpreter#C.2FC.2B.2B_interpreter

Like any interpreter, I would say there are two uses:

  • scripting
  • experimentation

I don't see scripting catching on for C++, the language is too verbose and there are other more viable alternatives there (python/ruby/shell).

The experimentation however is very attractive. Being able to test a construct on the side is like writing a small dedicated test. The typical example, for me, is the use of regular expressions (in Python):

> s = "silly test++/++hello world"
> re.search(pattern, s).groups()

I don't want to execute the whole shebang just for the sake of testing that I did write my pattern correctly (the regex compiles) or that it doesn't capture the block I wanted. A quick test catches most of the errors, and I can go on.

I suspect most of them will be made just for curiosity and academic research.

The Advantage of interpreters in general is that you do not need a compiler for a specific platform. This way, can run any program on any platform you want - given that there exists an interpreter for that platform.

Another benefit of interpreters is that changes of the source code of the interpreted program can be immediately visible to the program, so it makes debugging far easier.

Interpreters can give you dynamic typing although the C++ has no constructs to make use of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM