Thursday, June 30, 2022

Script Binding for C++ - Introduction


                                                            source https://www.swig.org 


SCRIPT BINDINGS

Scripting will allow C++ API to be accessed from a scripting language, such as Python, Ruby, Lua, Tcl, or Perl. 

Extending


In extending client can use the library or API as a module in the client's own script

eg expat and md5 modules in the Python standard library

are implemented in C, not Python.

Embedding

In Embedding Client C++ application embeds a scripting language inside it, the script bindings are used to call the core functionality of the library or API

eg Adobe Director multimedia authoring platform, which embeds the
Lingo scripting language.

Why scripting?

  • Cross-platform
    • Scripting languages execute in ASCII source code or platform-independent byte code
    • Scripting languages can work on different platforms without modification 
    • Disadvantage - Scripting code will have to be distributed in source form
  • Faster development
    • In c++ any changes done to code has to compile and link
    • In the case of a large c++ module or API, this can be time-consuming
    • in scripting language there is no compile and link stage, therefore edit the code and just run it This allows you to prototype and test new changes quickly.
  • Write less code
    • Scripting languages don’t require explicit memory management, they tend to have a much larger standard library available than C++’s STL, and often take care of complex concepts such as reference counting behind the scenes.
  • Support for expert users
    • Adding a scripting language to an end-user application can allow advanced users to customize the functionality of the application by writing macros to perform repetitive tasks or tasks that are not exposed through the GUI.
  • Extensibility
    • A scripting interface can be used to let users add entirely new functionality to the application through plugin interfaces. users have the power to solve their own problems.
    • For example, the Firefox Web browser allows new extensions to be created using JavaScript as its embedded scripting language.
  • Testability 
    • Scripting languages can have automated tests using that language
    • QA engineers will not write C++ code. but QA can write scripting languages
  • Expressiveness.  
    • Flexibility and ease of use of a programming language could impact the kinds of solutions that you can envision. That’s because you don’t have to be distracted by low-level issues such as memory management or statically typed data representations.









No comments:

Post a Comment

LeetCode C++ Cheat Sheet June

🎯 Core Patterns & Representative Questions 1. Arrays & Hashing Two Sum – hash map → O(n) Contains Duplicate , Product of A...