TeaAge Solutions

Hello and welcome to TeaAge Solutions,
your solution for professional C++ software development and beyond.

LATEST NEWS πŸ”₯(15. May 2024): Release of TeaScript 0.14.0 is done. πŸ–₯ It comes with the Tea StackVM, a Compiler, Dis-/Assembler, Suspend+Continue, Yield, improved debugging and more. Read more in the news blog post.
β˜›β˜›β˜› Download is available here. ☚☚☚

What is this about?

By the way: for German speaking visitors I provide the main page and the blog also in German.

Introducing TeaScript

In a Nutshell

TeaScript is an embeddable and standalone Multi-Paradigm script language with modern programming features close to C++ syntax but easier to use.

TeaScript can be used

  • to extend C++ Applications with TeaScript dynamically during runtime via the TeaScript C++ Library.
  • for doing arbitrary tasks by executing standalone TeaScript files via the TeaScript Host Application.

More information and the most impressive highlights are available in the Overview and Highlights section.

When embedding TeaScript in applications C++ variables and functions can be made available in the script and vice versa. Within the C++ software TeaScript files can be executed at created customization points and the result of the script, variables and functions can be accessed by the application.

Architectural Overview using TeaScipt at customization points.
Architectural Overview using TeaScipt at customization points.

Recently I created a benchmark for testing and comparing TeaScript and its competitor ChaiScript by computing the Fibonacci number of 25 recursively. The (pretty amazing) result is shown below. Shorter is better/faster, longer is slower. More in the blog post.

Diagram of benchmark result computing Fibonacci.
Diagram of benchmark result computing Fibonacci.

An upcoming highlight of TeaScript will be the Parallel Syntax!

Behind this feature you will find a really awesome way for express parallel / multi-threading execution directly build into the core language syntax of TeaScript. For the time being it cannot be unveiled. Watch out for future blog posts and site updates.

The following picture illustrates roughly the capabilities which will be available with the Parallel Syntax of TeaScript (more details to come…).

Illustrating Parallel Syntax capabilities in TeaScript.
Illustrating Parallel Syntax capabilities in TeaScript.

Use case example

Imagine you are providing a C++ software to your customers who are mostly happy with your software product and its configuration abilities.

But now you have a few but very important customers with some special needs which are too complicated and/or too mutable/dynamically for just configure some static data in configuration files.

What can you do now?

Do you really want to develop 1 to N special cases in your C++ software, re-compile everything, test it and deploy it to the customer installation?

There is a better way!

You could implement customization points in your C++ software once and provide the capability to execute TeaScript files on demand.
With that you can provide a specialized TeaScript file for each special customer without re-compile and update the C++ software.

Let’s quickly check a more concrete example:
One of your customers is maintaining a proprietary and huge CSV file which only exists in the environment of this customer and has nothing much to do with your regular use case. But some of the data in the CSV must be used to compute some concrete configuration options for your C++ software.

Now you can develop and provide a TeaScript file for this concrete customer installation which will be executed within your C++ software. The script will open and read the CSV file, extract and compute the relevant data and provides the result to your C++ software as concrete C++ variables, struct or class instances or whatever you like.

Your C++ code with the customization point might look like this:

class SomeData 
{
    /* some business related data here */
public:
    SomeData( long long param1, std::string const &param2, bool param3 );
};

void MyClass::SomeBusinessOperation()
{
    std::filesystem::path  script{"/path/to/script/custom.tea"};
    if( std::filesystem::exists( script ) ) {
        // tea script file with custom actions present, execute it.
        teascript::Engine  engine;
        // assuming the script returns true on success and providing the 3 
        // needed parameters for construct an instance of SomeData.
        try {
            if( engine.ExecuteScript( script ).GetValue<bool>() ) {
                SomeData data{ engine.GetVar( "param1" ).GetAsInteger(),
                               engine.GetVar( "param2" ).GetAsString(),
                               engine.GetVar( "param3" ).GetAsBool() };
                // do the thing with custom data.
                Apply( data );
            }
        } catch( ... ) {
            // specialized exceptions could be caught instead also.
        }
    } else {
        // default action...
        SomeData data = LoadDefaults();
        Apply( data ); // do the thing.
    }
}

The TeaScript file “custom.tea” may look like this:

def param1 := 0
def param2 := "foo"
def param3 := false

// note: the CSVFile interface is just for illustrating this example.
//       In the final release a different interface could be available instead.
def file := CSVFile( "path/to/data.csv" )
def tmp1 := param1
def tmp2 := param2
def tmp3 := param3

def success := repeat {
    def line := file.readLine()
    if( not line ) { // end of file reached
        stop with true // stops the loop with value true
    }
    // check for some error condition
    if( not isLineValid( line ) ) {
        stop with false // stops the loop with value false
    }
    tmp1 := computeMoreParam1( tmp1, line )
    tmp2 := computeMoreParam2( tmp2, line )
    tmp3 := computeMoreParam3( tmp3, line )
}

// save final values 
if( success ) {
    param1 := tmp1
    param2 := tmp2
    param3 := tmp3
}

// result of the script
success

For other customers you will provide a different TeaScript file for fulfill their special needs or provide none for the default use case.

Further advantages when use TeaScript at customization points

  • You can easily change some part of the script without re-compile and update the software and react quickly on changed requirements, use cases, etc.
  • The scripts might not only be used, changed and/or developed by your core developer staff, but also by e.g., 2nd or 3rd level Support, Pre-Sales, After-Sales, Solution Architects, Product Manager or even Resellers or the IT staff / Operators of the customer itself (if wanted and depending on the environment/use cases/responsibilities, etc.).
  • The scripts are most likely easier to test and verify compared to test each special case in your huge C++ software, because the scripts are separated entities and can be easily used in e.g., test environments.

What about plugins instead?

Yes, of course it would be also possible to implement a plugin interface in your C++ software and realize all the special needs via binary C++ plugins. But with these all the advantages above are not present and you need to maintain and develop also the plugin interface and its API by yourself. It is quite easier and less complex to just use TeaScript.

Why should I use TeaScript and not another existing script language?

There are only a few script languages which are ready to use without prior change the environment. For example, you can use Python only if you have a proper Python setup on the system. Also, the C++ integration (if even existing), the possible use cases and the API is often very limited, complex and difficult to use and maybe bad designed as well.

In contrast to that TeaScript itself is developed as an easy-to-use C++ Library, which don’t need any setups or installations to be operational and one of its main goals is to be executed/used in C++ programs. The API is not adapted or wrapped around other stuff but is designed in C++ from scratch and with modern C++ features and requirements of C++ developers in mind.

Most scripting solutions are programmed in C instead of C++. This has major drawbacks. But TeaScript is able to offer a high bidirectional interoperability because of its inner C++ nature. Read more here.

Also, you might be interested in to read more in this comparison article: Comparison of C++ Script Libraries.

Can TeaScript be used for production already?

Yes, it can. I explain why and what is the best practice:

First, although the 1.0 release is not done yet, every release has 3 levels of quality assurance:

  • UnitTests – on C++ as well as on TeaScript level (TeaScript files testing TeaScript features).
  • Functional tests with scripts.
  • Manual testing.

This ensures a high level of quality already.

Second, the TeaScript syntax and language features which are present already will stay compatible and are covered by the tests mentioned above. In new versions new syntax and new language features will be added, but old written scripts will still be functional in 99% of the cases (only if the script used some quirks or rely on broken functionality or if really big issues are addressed, this backward compatibility might not be hold.)

Third, usage of the high-level C++ API only. This API will stay backward compatible or a soft migration will be provided – except if major issues are detected or at very rare circumstances.
The high-level API consists of the classes teascript::Engine / teascript::EngineBase, all public getters in teascript::ValueObject as well as everything in Exception.hpp / SourceLocation.hpp and version.h (except where otherwise noted).

When will TeaScript be available?

The TeaScript C++ Library and the TeaScript Host Application (Windows 10/11 and Linux (Ubuntu)) are available:
β˜›β˜›β˜› Download is available here. ☚☚☚

Overview and Highlights

A brief overview and the most impressive highlights are available in the TeaScript Overview and Highlights section.

Product Variants

More information about the TeaScript Variants and Characteristics is available in the Product Variants section.

Comparison of C++ Script Libraries

You can read a brief overview about the available C++ Script Libraries and its high-level features in this article: Comparison of C++ Script Libraries.

Motivation and background story

Read more about my motivation and the background story in this blog post. Furthermore, you will find there a comparison with other available solutions.

Contact / Get in touch

If you want know or learn more about TeaScript, want to check or discuss possible use cases, have other questions, suggestions, wishes, recommendations or critic and/or want to know if or how I could help you with my services specific to your C++ software (related or unrelated to TeaScript):

Don’t hesitate to get in touch with me: contact <the-at-symbol> tea-age.solutions
or use the contact form below:

    SPAM Protect: What is the result? 20 times 15