25k 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.<p>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 FFI, what's the benefit vs. e.g. C++11? The latter has nice language features too but compiles to much smaller native code!
That FFI interface looks <i>way</i> nicer than the node-ffi interface.<p><pre><code> let f = ffi('int gpio_write(int, int)');
</code></pre>
vs.<p><pre><code> var current = ffi.Library(null, {
'atoi': [ 'int', [ 'string' ] ]
});</code></pre>
This looks a lot like Lua's FFI interface[0], which is a compliment (but contradicts the statement that this sort of FFI is "the feature that no other engine implemented so far"). Nicely done.<p>[0] <a href="http://csl.sublevel3.org/post/luajit-cpp/" rel="nofollow">http://csl.sublevel3.org/post/luajit-cpp/</a>
Is 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.<p>In their docs, they claim 25K storage and 10K RAM. Blog post claims 25K storage and 1K RAM.<p>[0] <a href="https://github.com/cesanta/mjs/blob/master/mjs.c" rel="nofollow">https://github.com/cesanta/mjs/blob/master/mjs.c</a><p>[1] <a href="https://github.com/cesanta/v7/blob/master/v7.c" rel="nofollow">https://github.com/cesanta/v7/blob/master/v7.c</a><p>[2] <a href="https://docs.cesanta.com/v7/master/#/v7-internals/" rel="nofollow">https://docs.cesanta.com/v7/master/#/v7-internals/</a>
I'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?
> One common thing these projects share is an attempt to implement the whole language specification, together with the more or less complete standard library<p>Not in the case of Lua. Well, the "whole language" part is correct, but Lua is a very tiny language spec. It's "standard library", however, is the opposite of "complete".
So is the only benefit of wasting that space and CPU so you can bill your platform/project/whatever as being "js" and C/C++-free? What does a no standard library JS buy you over a no standard library C++11 everyone else is using these days, besides the pain and trouble of dealing with a dynamically typed language without native debugging support?<p>Why is there so much stigma against _learning_ to code in something other than $favlang these days? Most hard core developers I know appreciate the importance of using the right tool for the job, I don't see embedded/desktop developers shying away from using whatever the native toolkit/language is for their chosen platform and instead shoehorning $x to fit as much as we see this constant trend to try to use "web tech" everywhere. (Scripting in embedded systems has long been a solved problem: use lua.)
Neat. Although languages which are "almost, but not quite <x>" are, I would say, harder for people who know <x> to learn than languages that are entirely different from <x>.
Taking this example:<p><pre><code> let malloc = ffi('void *malloc(int)');
let mem = malloc(10);
</code></pre>
How do you manipulate that memory?<p>How can you do the following in mJS?<p><pre><code> int* mem = malloc(10);
mem[0] = 3;
mem[1] = 7;
mem[2] = 12;
int *rest = mem + 3;
</code></pre>
There are some things you can do in C without functions. How does mJS achieve this?
Worth mentioning: <a href="https://github.com/elua" rel="nofollow">https://github.com/elua</a><p>Allows to run Lua on bare metal, no OS involved. It's what the nodemcu firmware for the ESP cards is based on.