September was all about testing the Qubic programming language Abra and creating its initial support library, which is written in Abra of course. While creating the support library, the need arose to be able to verify all kinds of ideas. This resulted in a parallel trajectory where a simple Abra language parser was created in Java. The parser allowed us to run syntactical sanity checks on the library code even before we had a running Abra compiler. To facilitate the building of the parser we created an EBNF syntax diagram for the Abra language.
The process of building this parser directly resulted in a few changes to the Abra language syntax that make it easier to parse and analyze the language. In addition, while building the support library, it became clear that there was a lot of repetitive programming going on due to the fixed-size nature of the Abra trit vector data type. This resulted in the addition of a template-like feature which allows us to create generic functions and then instantiate them for the required trit vector sizes.
In the mean time, one of our Discord community members, ben75, managed to use the EBNF syntax diagram to implement an awesome syntax highlighter for Abra on the IntelliJ IDEA platform. That turned out to be a great help for us while creating the support library code. This community never ceases to amaze me.
Once the parser/analyzer worked correctly it was decided to give it quick-and-dirty ability to run the Abra code as an interpreter. This allows us to run the Abra code and test it already, even without being able to compile it for a specific platform yet. It also allowed us to debug the support library code by stepping through the Java interpreter code in the debugger while it executes the Abra code.
We’re happy to report that most basic library functions worked exactly as designed, and only a few minor details needed fixing. The most astonishing thing that happened during this phase was that *by far* the most complex function that was written, the integer multiplication function, worked flawlessly right off the bat! Astonishing because when we wrote this code there was no way to run the code other than in our minds.
While we haven’t yet created the corresponding integer division function, the functions that implement arithmetic, logical, and conditional operations have already proven to work correctly in practice when we used them to implement several test functions. The most impressive part of the support library is probably the way we can tailor those functions to any required trit vector size, which allows us to perform integer arithmetic natively on a vast selection of integer ranges that is unmatched by most other programming languages. For example we defined an integer data type we namedHuge, which is a trit vector 81 trits long and can represent values in the range of minus to plus221,713,244,121,518,884,974,124,815,309,574,946,401! We even tested with a 6561 trit data type that is supposed to hold an IOTA signature and found that it can represent integer numbers that are a whopping 3131 digits in length. And the integer arithmetic functions will work correctly with all of them!
Further additions to the parser allow it to generate a ternary representation of the Abra code ready for inclusion in a Qubic message to be sent through the Tangle, and convert that ternary code back into the original representation that can be run by the interpreter. This could prove very helpful in speeding up the process of getting to a working proof of concept for Qubic until a more robust version of the end-to-end functionality can be completed.
The document about the Qubic computational model is coming along nicely. It has grown so large that we decided to split it into multiple parts. The first two parts are currently being reviewed, and the third part is expected to be ready in the first week of October. The following parts are planned at the moment:
- A conceptual overview of the Abra processing model.
- An overview of the basic entities in Abra.
- An overview of the Abra programming constructs.
- Some example Abra functions with details on how they work.
- The Qubic Dispatcher and its interaction with Abra.
It has been very exciting for us to finally see the first working Abra programs in action this month! We hope to be able to share the documentation and interpreter with the community as soon as possible, so that you can start playing with it and contributing to our Abra efforts as well.
Click the above link to see a nice railroad syntax diagram of the Abra language.