5 ms·
There is also QuickJS (by Fabrice Bellard) that I use and it's very fast to start and run js programs. QuickJS is a small and embeddable Javascript engine. It s
by rsiqueira 5y ago
There is also QuickJS (by Fabrice Bellard) that I use and it's very fast to start and run js programs. QuickJS is a small and embeddable Javascript engine. It supports the ES2020 specification.
https://bellard.org/quickjs/ https://bellard.org/quickjs/
- tyingq 5y agoQuickJS is also fantastic, but not anywhere near Elk in terms of size. Elk is ~59k (1300 lines) of C code, and has some limitations (like no for loops, for example) that I assume were traded off so it could run on things like the 2K RAM / 30K flash Atmel shown in the article. 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.
- unwind 5y agoThis part of the code hints at what else is left unimplemented: 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).
- BoorishBears 5y agoI write embedded code and the moment I see (data, sizeof(data)) in any kind of initialization method, I immediately expect it not to allocate. Trust but verify, but also I'll feel mislead if it does since it's an extremely common pattern
- gigel82 5y agoThe project appears dead though. It looks like the GitHub mirror has a couple PRs but no one is looking at them and it doesn't look like he's added any collaborators.
- dapids 5y agoIt might not be updated often but I find QuickJS to be quite stable. I've been building on it for years with no compatibility issues whatsoever. It's well written, and I don't think the fact someone hasn't made a commit recently makes it be of any less quality or usefulness. Fabrice works on many projects and is quite prolific in open source, he's probably busy.
- bendmorris 5y agoIt says clearly on the GitHub mirror that pull requests aren't accepted; there's a mailing list that you can submit patches to.
- breakfastduck 5y agoIf something works, why does it need to be actively developed ad infinitum to be useful?
- gigel82 5y agoBecause JS is an ever-evolving language. ChakraCore has been "abandoned" by MS (technically transitioned to community ownership) for less than a year and it's already behind on ES6 and ESNext compatibility. 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.
- cxr 5y agoIf ChakraCore is behind on ES6 compatibility, that has nothing to do with its recent abandonment. ES6 was finalized over 6 years ago (not to mention the time that was available to work on supporting it concurrent with the development of the actual standard itself).
- hungryforcodes 5y agoWell if we are mentioning different projects, there is also Espruino which has alot of support and drivers. One of rhe neat things about it, is that it gives you a "browser" like console to interact with your javascript and has commands similar to Node.js. https://espruino.com https://espruino.com
- omneity 5y agoI implemented once an Espruino target for webpack to enable a git workflow, npm packages, and transpile modern JS features to ES5, as supported by Espruino (targeting an esp8266 specifically). 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.
- hungryforcodes 5y agoWell it's designed to run on NRF processors with just 64KB of RAM and as little as 128KB of flash, which last a week on one CR2032 battery. 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! :)
- omneity 5y ago> You might have been over doing it! /s 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!
- dvh 5y agoFabrice Bellard is making us, average programmers, look bad.
- dapids 5y agoHas been since the 90's. QuickJS is just one of dozens of incredibly complex projects he has worked on, relative to the abilities of an sole programmer.
- ducktective 5y ago`ffmpeg`, `QEMU` and `tcc` also want to have a word ¯\_(ツ)_/¯
- ricardobeat 5y agoQuickJS' base memory usage is somewhere around ~200KB, it's not really targeted at embedded devices. When you have 8-64KB of RAM you're better off running Elk, Duktape in low memory mode, or other engines developed specifically for this purpose like Espruino/JerryScript.