Photo by Will Tarpey on Unsplash


Scierra is not a fishing company. Well, at least not this Scierra.

It is a Simulated C++ Interpreter with Recurrent Adaptation.

In human words, it’s a interactive interpreter for C++, which allows you to run and debug your program immediately as you type it.

But I didn’t want just another C++ interpreter, like Cling - why install another unfamiliar infrastructure, only for that one expression you need to verify now?

You see, I wanted Scierra to be a nice add-on feature, to run on nothing other than an installed compiler. Any installed compiler. However, at the same time, it should offer all the additional benefits of an interpreter. That would make installation and usage a lot more lightweight and cleaner.

Essentially, I was thinking of a way to build a C++ interpreter on top of a C++ compiler.

But, how?

Now that’s when the idea of recurrent adaption comes in.

Scierra isn’t techincally an interpreter, but it gives the illusion of one. Every time you complete a block of code, Scierra assigns that block to a particular location in the anatomy of your current C++ program. If you’re declaring variables, then that will fall under the main() function. Otherwise, if you’re defining functions, your block may be moved in front of main() into the globals section.

Then, Scierra compiles and runs your full C++ program. Every time.

Instead of maintaining the values of user-defined variables and the definitions of various functions, recurrent adaptation stores your whole program and recompiles it every time a new code block is typed in. That creates the illusion of an interpreter.

But there’s other problems. To avoid clutter and to maintain the illusion of an interpreter, cout statements that have already been executed in the main() function will be removed. cin statements, on the otherhand, are a huge pain for implementing recurrent adaptation, and I’m still working to support those expressions.

Recurrent adaptation may sound slow, but overall Scierra works at a reasonable efficiency, unless you make it run a million-line code. But Scierra’s mainly used for debugging and quick testing anyway, like what you’d do with the Python console, so I’d say it’s good for its purpose.

Anyway, that’s a high-level overview. There’s a lot of little details ommitted, like Scierra’s ability to detect whether you’ve completed a block of code, or how it understands whereabouts in a C++ program to insert that block. Recurrent adaption might seem like a simple idea, but overall everything works surprisingly well. I think it’s a really helpful hand for testing and debugging in competitive programming!

Here is an example run of writing a C++ program in Scierra:

++> cout << "Hello, World!";
Hello, World!
++> int factorial(int n){

-->     if (n==1 || n==0)

-->         return 1;

-->     else return n * factorial(n-1);

--> }

++> cout << "10 factorial is: " << factorial(10);
10 factorial is: 3628800

Debug as you run, run as you type. Without installing another infrastructure.

Love the idea? Get started here!