Inspiration is pretty much the standard when it comes to doing portable programming or needing an IDE in a pinch. However, it has the downside of always needing a reliable network connection and not supporting graphical applications. If your internet is unreliable, using can be frustrating. NCC attempts to fix the short comings of online IDEs by providing the user's browser with the C++ toolchain for instant offline use.

What it does

NCC accepts C++ source code and a list of JavaScript functions it's allowed to call then returns an array of bytes representing a WebAssembly module. The modules can be generated and executed client-side with certainty that they will only have the permissions explicitly given to it.

Toy++ is a graphical sample web app that uses NCC. In it, the user can click a button to display the generated .wasm byte code in the console with annotations about what each byte does. Toy++ is built using the Monaco editor made by Microsoft. It has all the built-in features such as multi-cursor. I added extra code to support using CTRL+D to duplicate the current line or selection without overwriting the clipboard.

How I built it

JavaScript, CSS3, HTML5, C++, and Clang 8.0, Monaco editor

Challenges I ran into

Writing WebAssembly by hand is difficult and error-prone. C++ has a complicated grammer which cannot be compiled into WebAssembly in one pass. In an attempt to keep the resulting compiler binary small, I don't use the C++ standard library and instead call imported JavaScript functions for the purposes of debugging. This was a tedious but rewarding process.

Accomplishments that I'm proud of

Basic support for variables, arithmetic, control flow, and graphical function calls are available in the MVP.

What I learned

C++ grammar is complicated and difficult to compile. I should choose projects appropriate for the amount of time allotted to a given hackathon.

What's next for Nathan C Compiler

I will finish supporting the core C++ feature set and make Toy++ a fun C++ learning experience. Then, I will create a separate more full-featured IDE to compete with

Built With

Share this project: