QuickJS is small compared to say, V8, but quite a lot larger than Elk. Just the main C source file for QuickJS is ~1.7MB, and there's several other source files.
Just saying they seem to be in different niches.
case TOK_CASE: case TOK_CATCH: case TOK_CLASS: case TOK_CONST:
case TOK_DEFAULT: case TOK_DELETE: case TOK_DO: case TOK_FINALLY:
case TOK_FOR: case TOK_IN: case TOK_INSTANCEOF: case TOK_NEW:
case TOK_SWITCH: case TOK_THIS: case TOK_THROW: case TOK_TRY:
case TOK_VAR: case TOK_VOID: case TOK_WITH: case TOK_YIELD:
res = js_err(js, "'%.*s' not implemented", (int) js->tlen, js->code + js->toff);
break;
So that's quite a lot of the language I guess, but it does say that it's a sub-set so of course that's fine. Very impressive code, it really shows that the developer has an eye to minimizing the memory footprint. I was fooled for a couple of seconds by the init call: char mem[200];
struct js *js = js_create(mem, sizeof(mem));
Since it really "feels" like a function that creates a struct instance on the heap, but of course it does not: it's created inside the working memory passed in (so if it works, js == mem).Trust but verify, but also I'll feel mislead if it does since it's an extremely common pattern
Boy oh boy I did not expect to run into memory issues so quickly. Including async/await increases the size of the build so much the esp just dies.
But most npm packages worked just fine, including lodash ( a life saver), as long as you’re willing to work with the super tiny memory budget and the difficulty to detect memory leaks.
Using an esp32 with 8mb of PSRAM yielded much better results.
Good times.
You might have been over doing it! /s
I regularly develop intensive apps in Espruino for the ESP32 (I mentioned in another thread how I pull in exchange data directly using HTTPS, and process it on the TTGO Watch 2020), but it's all hand crafted code. Maybe you should consider a small Friendly Elec board and node...
...and yes PSRAM is super awesome! :)
You’re completely right! Fed up with Arduino C, I tried to bring the entirety of the web toolchain and related dev patterns to the embedded world. :’)
What you’re doing sounds super cool! Is it just as a hobby or your day job as well?
Do you have any tips on debugging long running memory leaks? (basically the board crashes after a few days running continuously, which were my specs)
Nowadays I’m back to Arduino C and the M5Stack/M5Paper boards, it’s a bunch of fun when I find time for it!
It's kind of a serious hobby. I enjoy it.
In Espruino the memory leaks are always almost the variables. So you can do say process.memory() to see if indeed your memory is decreasing, and if it is, then you can E.getSizeOf(global) to see which variable it might be. It's still javascript at the end so, standard techniques apply.
Yeah I like the M5Stack boards, they're quite interesting. I use the their StickC. The orange one. It does take time for sure!
I've used QuickJS but when I got stuck on an issue (stack overflow in win32 because of passing by-value) I got no help from the tiny community on the mailing list and had to abandon the attempt and go back to (overweight) V8.