cognate-lang / cognate

A human readable quasi-concatenative programming language
BSD 2-Clause "Simplified" License
245 stars 12 forks source link

Actual interpreter for microcontroller? #18

Open dragoncoder047 opened 2 years ago

dragoncoder047 commented 2 years ago

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?

StavromulaBeta commented 2 years ago

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.

dragoncoder047 commented 2 years ago

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.

StavromulaBeta commented 2 years ago

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!