cognate icon indicating copy to clipboard operation
cognate copied to clipboard

Actual interpreter for microcontroller?

Open dragoncoder047 opened this issue 2 years ago • 3 comments

From the readme:

CognaC (the Cognate Compiler) compiles Cognate sources directly into C. This produces very small and rather fast binaries, allowing Cognate to outperform most dynamic languages. This also makes Cognate a candidate for scripting in embedded environments, such as microcontrollers.

... but microcontrollers can't compile and run C. Is there a "pure interpreter" for a microcontroller somewhere that actually executes the code instead of transpiling it to C? If there isn't, how do I make one out of this code here?

dragoncoder047 avatar Oct 18 '22 16:10 dragoncoder047

The intention is for code to be compiled for the microcontroller from C - that way small microcontrollers can be used without the overhead of an interpreter. Maybe the word scripting is misleading here(?). I'm planning to explore actually running Cognate on a microcontroller once I've got the new compiler feature complete and stable.

StavromulaBeta avatar Oct 18 '22 16:10 StavromulaBeta

I was worried of that. What I want to do is hook up the microcontroller directly to a storage device (flash drive, SD card, etc), have it read the .cog files and execute them onboard, without having to be connected to a regular computer to do the compiling. I'm going to be using an ESP32, which has megabytes of both RAM and flash, so memory consumption and speed are not concerns at least for me.

dragoncoder047 avatar Oct 18 '22 16:10 dragoncoder047

Ah yeah that'd be a problem with the current implementation. I'll almost certainly ship a small interpreter with the new compiler once it's done, but CognaC in its current iteration won't be much help here, sorry!

StavromulaBeta avatar Oct 18 '22 17:10 StavromulaBeta