Building a Programming Tool?

Build for 5 languages at once

-- | Inserts "blocksCovered[n] = true" printouts for test-coverage
--   at every basic block
-- Runs on C, Java, JavaScript, Lua, and Python
instrumentTestCoverage :: forall fs l. (CanInstrument fs)
                       => ProgInfo fs -> TermLab fs l -> Annotater (TermLab fs l)
instrumentTestCoverage progInfo t = performCfgInsertions @(StatSort fs) progInfo
                                  $ allbuR (addCoverageStatement progInfo) t

Cubix is a Haskell framework for building language-parametric programming tools.

Do the tutorial

Built for transformation. Useful for everything.

It’s one thing to lower many languages into a common bytecode, and then do some program analysis. It’s another thing to turn that back into source code, and still have it resemble the original program.

Source-to-source transformation is the hardest problem of building multi-language tools. Prior to Cubix, no other framework even tried. Yet Cubix’s powerful generic-programming capabilities are also useful when building program analysis or generation tools.

For example: We have also built the world’s most powerful semantic code search tool — and we did it for multiple languages simultaneously.

Both language-specific and language-generic

If two languages are 90% similar, then tools for them should share 90% of their code. And the tools should still work flawlessly for the remaining 10%.

Cubix is based on incremental-parametric syntax. This means that languages are defined as a hybrid of language-specific and generic parts. Correspondingly, tools are written as a hybrid of language-specific and generic parts.

This means that it's possible to both develop for multiple languages and to cover every language-specific corner case. Indeed, in the original Cubix paper, we ran our transformations on gcc-torture and other compiler test suites, and achieved a 100% pass rate.


Cubix is in transition from a research prototype to an industrial framework.

This means that you may find some key feature missing for your intended application. It also means we are willing to dedicate substantial resources to help you.

For questions, either contact the creators directly, or post on our mailing list.


Publications About Cubix

James Koppel, Varot Premtoon, and Armando Solar-Lezama. One Tool, Many Languages: Language-Parametric Transformation with Incremental Parametric Syntax. In OOPSLA 2018.
James Koppel, Sreenidhi Nair, and Armando Solar-Lezama. One CFG-Generator to Rule Them All. In submission.

Publications That Use Cubix

Varot Premtoon. Multi-language Code Search. Master's Thesis.
Varot Premtoon, James Koppel, and Armando Solar-Lezama. Semantic Code Search via Equational Reasoning. In PLDI 2020.