[ACCEPTED]-Scripting language for C/C++?-rad

Accepted answer
Score: 25

With a C/C++ interpreter you can use C/C++ as 12 a scripting language


Note: So far, I 2 have tried only Ch and CINT. I have added ccons and 1 UnderC to make the list more complete.

Score: 10

You may try Lua quite often used with C++ in 9 games industry. It has a small memory footprint 8 and is quite mature, has a great library... just 7 give it a try.

hm... I do not understand 6 what you want to achieve: do you want to 5 find a scripting language that will somehow, magically 4 be converted into c++ source? Or what you 3 really want is just an option to create 2 an executable from the script? If the latter 1 - then you may try py2Exe.

Score: 4

Anybody interested in a scripting language 27 that is (mostly) very similar to C++, may 26 want to take a look at angelscript (ZLIB):

The AngelCode 25 Scripting Library, or AngelScript as it 24 is also known, is an extremely flexible 23 cross-platform scripting library designed 22 to allow applications to extend their functionality 21 through external scripts. It has been designed 20 from the beginning to be an easy to use 19 component, both for the application programmer 18 and the script writer.

Efforts have been 17 made to let it call standard C functions 16 and C++ methods with no need for proxy functions. The 15 application simply registers the functions, objects, and 14 methods that the scripts should be able 13 to work with and nothing more has to be 12 done with your code. The same functions 11 used by the application internally can also 10 be used by the scripting engine, which eliminates 9 the need to duplicate functionality.

For 8 the script writer the scripting language 7 follows the widely known syntax of C/C++ (with 6 minor changes), but without the need to 5 worry about pointers and memory leaks. Contrary 4 to most scripting languages, AngelScript 3 uses the common C/C++ datatypes for more 2 efficient communication with the host application.

For 1 more info, check out: http://www.angelcode.com/angelscript/sdk/docs/manual/index.html

Score: 2

Many projects combine e.g. C++ and Python 4 -- see for example boost.python.

I prefer R and use 3 the Rcpp interface from R to C++.

Either case 2 gives you your scripting language for prototyping 1 and easy 'glue' to C++ for performance.

Score: 2

pawn

pawn is a simple, typeless, 32-bit extension language with a C-like syntax. A pawn "source" program is compiled to a binary file for optimal execution speed. The pawn compiler outputs P-code (or bytecode) that subsequently runs on an abstract machine. Execution speed, stability, simplicity and a small footprint were essential design criteria for both the language and the abstract machine.

This language is very simular to c syntax, so 5 anyone that has done any c++,c,c#,java will 4 be able to read it and its simplyfied so 3 none coders can read it to. This language 2 is currently used all around, among other 1 places scripting against halflife 1 and halflife2 servers.

Score: 2

There is a new package Chaiscript which is designed 2 for C++. It's relatively new and not completely 1 stable yet.

Score: 1

GML : www.yoyogames.com

0

Score: 1

For Python, I sometimes find psyco useful. Not 9 sure if there is any equivalent for perl 8 though.

When choosing a language for a task, I 7 find it more useful to choose the language 6 most suited for the job. If the job asks 5 for more performance than a scripting language 4 can provide under normal conditions, it 3 is usually better to just switch than to 2 bend over backwards to try to make your 1 code fast.

Score: 0

The question could be interpreted different 14 ways...

If you have already coded a part 13 of your application in C++ and need to add 12 modules or scripts, that you want to add 11 in the C++ code eventually for improved 10 performance, you could use Qt which is a solid, very 9 complete multi-platform framework.

It includes 8 support for scripts (ECMAScript, the standardized 7 version of Javascript), from which you can 6 access your C++ objects if you need to. It 5 also provides support for plug-ins.

With 4 that approach, you can even proceed in three 3 steps,

  • first do some tests in Javascript,
  • then code the base of your application in C++ and still use a part in scripts (for example if you need to try different algorithms),
  • and finally port everything, or at least the critical parts, in C++.

Another option is to embed a Python 2 interpreter in your code, although that 1 will probably require more work.

Score: 0

I'm not sure I understand your question 24 but if your looking to implement your own 23 scripting language which could interface 22 with your c++ code you can take a look at 21 boost::spirit. You just have to tell it 20 your grammar and you have your scripting 19 language doing whatever you tell it to in 18 c++. You specify your grammar using c++ operators 17 making it very easy and intuitive.

That's 16 what I currently used for my recent needs 15 and it looks like it will do the job just 14 fine. You have full access to your c++ objects 13 when specifying your grammar and your user 12 can have a very simple language to learn 11 (compared to CINT where the language would 10 be c++ itself).

Compile time are a little 9 slow right now but if you don't need to 8 implement a very complex language it should 7 be manageable (I wouldn't like to see the 6 compile time for something like c++). Also 5 documentation is a little lacking for the 4 newest version (and the most up-to-date 3 version is a little hard to find) but it's 2 relatively easy to use so it might be worth 1 a check, depending on your needs.

Score: 0

You could code using D programming language 3 as both a script or a fast compiled output.

here 2 is an article that talks in detail about 1 D and its advantages "The Case for D"

Score: 0

Cling is an interpreter for c++ cling

0

More Related questions