Jon and I released the first release of ChaiScript earlier today. ChaiScript is designed to make it trivially easy to use scripting in your C++ application and to expose your C++ to the scripting system.
ChaiScript is a header only implementation. It requires no external libraries and is distributed under the BSD license, making it free and easy to distribute.
So, how easy is easy, really? How does 3 lines of code sound for a classic hello world example?
#include <iostream> #include <chaiscript/chaiscript.hpp> int main(int argc, char *argv[]) { chaiscript::ChaiScript_Engine chai; chai.evaluate_string("print('Hello World');"); }
Of course, this example is quite limited in usefulness. But I want to keep this article short and not get into too much detail. So, I will provide on more example that shows how to expose a C++ function to ChaiScript.
#include <iostream> #include <chaiscript/chaiscript.hpp> std::string get_message() { return "Hello World"; } int main(int argc, char *argv[]) { chaiscript::ChaiScript_Engine chai; dispatchkit::register_function(chai.get_eval_engine(), &get_message, "get_message"); chai.evaluate_string("print(get_message());"); }
ChaiScript never gets much more difficult than that. Stay tuned for more ideas, or check out the The Book of ChaiScript for more information.
Recent comments
1 week 1 day ago
1 week 5 days ago
2 weeks 7 hours ago
2 weeks 4 days ago
2 weeks 4 days ago
2 weeks 6 days ago
3 weeks 4 days ago
3 weeks 4 days ago
3 weeks 5 days ago
4 weeks 3 days ago