mJS – A new approach to embedded scripting
21–30 of 61 posts
Re: mJS – A new approach to embedded scripting
#2225k of flash space sounds like a lot for what is effectively just a JavaScript parser and interpreter. I recall the days when you could fit a whole language's compiler into a few measly KB. 1KB RAM is also quite a lot for certain boards, especially if it has to be stack or SRAM. How's the performance? Will my 72MHz Cortex or 16MHz Arduino be able to run interesting things with mJS? If I have to do everything through…
Re: mJS – A new approach to embedded scripting
#2325k of flash space sounds like a lot for what is effectively just a JavaScript parser and interpreter. I recall the days when you could fit a whole language's compiler into a few measly KB. 1KB RAM is also quite a lot for certain boards, especially if it has to be stack or SRAM. How's the performance? Will my 72MHz Cortex or 16MHz Arduino be able to run interesting things with mJS? If I have to do everything through…
I'd wager a large amount of that is handling symbol lookup for calling through the FFI.
> In order to make FFI work, mJS must be able to get the address of a C function by its name. On POSIX systems, dlsym() API can do that. On Windows, GetProcAddress(). On embedded systems, a system resolver should be either manually written, or be implemented with some aid from a firmware linker script.
So I guess they don't provide any implementation for their FFI linking on embedded platforms? It's not clear if the 25k size figure includes any dlsym support, but if it requires instrumenting your firmware image on-disk then the size costs could balloon significantly.
Re: mJS – A new approach to embedded scripting
#24I've never worked with embedded systems, so forgive my ignorance. Why is this any more useful than just writing c code, if all the code that actually interacts with the hardware has to be written in c anyway?
Re: mJS – A new approach to embedded scripting
#25In their docs, they claim 25K storage and 10K RAM. Blog post claims 25K storage and 1K RAM.
[0] https://github.com/cesanta/mjs/blob/master/mjs.c
Re: mJS – A new approach to embedded scripting
#26Earlier quoted context omitted.
I'd wager a large amount of that is handling symbol lookup for calling through the FFI.
I quote the mJS readme from the repo: > In order to make FFI work, mJS must be able to get the address of a C function by its name. On POSIX systems, dlsym() API can do that. On Windows, GetProcAddress(). On embedded systems, a system resolver should be either manually written, or be implemented with some aid from a firmware linker script. So I guess they don't provide any implementation for their FFI linking on embe…
https://github.com/cesanta/mongoose-os/blob/master/fw/exampl...
Re: mJS – A new approach to embedded scripting
#27Is this a re-packaged v7 [0] (it's from Cesanta as well)? mjs.c is 477K. It looks like it as v7.c is 475K [1]. It shaves whole entire 1MB from my staticly linked builds (v7 1.9MB vs. mjs 998K), and almost 2MB from dynamically linked builds (v7 1.9MB vs. mjs 99K) on amd64. If it shares the same underlying architecture and api [2] then this is a pretty great achievement. In their docs, they claim 25K storage and 10K RA…
Re: mJS – A new approach to embedded scripting
#28Earlier quoted context omitted.
Scripting is rarely about syntax. It's about being able to load code dynamically, being able to create ad-hoc data structures, quick changes and distributing executables as source rather than binaries.
None of which are particularly appropriate for embedded programming.
I understand your point. These tools aren't appropriate for serious embedded systems, but they're also not meant for them. They're meant for people who want to have fun and want to play with things quickly.
Re: mJS – A new approach to embedded scripting
#29Is this a re-packaged v7 [0] (it's from Cesanta as well)? mjs.c is 477K. It looks like it as v7.c is 475K [1]. It shaves whole entire 1MB from my staticly linked builds (v7 1.9MB vs. mjs 998K), and almost 2MB from dynamically linked builds (v7 1.9MB vs. mjs 99K) on amd64. If it shares the same underlying architecture and api [2] then this is a pretty great achievement. In their docs, they claim 25K storage and 10K RA…
i wonder if the size could be reduced by replacing the yacc code with a hand-written parser.
V7 uses hand-written recursive-descent parser. Initially, it was using ordinary C functions, and that created a problem on systems with low stack size. E.g. each '(' starts statement parsing from the top, so 1 + (2 + (3 + (4 + 5))) consumed stack, and sometimes resulted in stack overflow in e.g. interrupt handlers or network callbacks.
Therefore we have rewritten recursive descent using C coroutines, and that is extremely sophisticated piece of work. See https://raw.githubusercontent.com/cesanta/v7/master/v7.c , search for #line 1 "v7/src/parser.c"
mJS on the other hand uses lemon parser generator - the one from sqlite project. It generates a LALR parser which is quite efficient in terms of memory.
Re: mJS – A new approach to embedded scripting
#30Earlier quoted context omitted.
Scripting is rarely about syntax. It's about being able to load code dynamically, being able to create ad-hoc data structures, quick changes and distributing executables as source rather than binaries.
None of which are particularly appropriate for embedded programming.
"We can't do things that way, because we do things a different way", is something that many people will automatically recognize as a bad argument if you put it that way. (It's in the same bucket as, "Well, nobody has ever complained before.") But anyone—even by accident—can end up using this argument while saying different words. The effect is that it comes in a different package that's more difficult to spot. In the end, though, it's the same invalid discussion killer.
Anyway, that's a lot of exposition. What I came here to say is that your comment is tripping the filter for me right now.
What's inappropriate about a fast development feedback cycle when doing embedded programming?