Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Espruino Use Bytecode or JIT compilation #73

Closed
gfwilliams opened this issue Oct 3, 2013 · 3 comments
Closed

Make Espruino Use Bytecode or JIT compilation #73

gfwilliams opened this issue Oct 3, 2013 · 3 comments

Comments

@gfwilliams
Copy link
Member

This ALWAYS comes up, so I'm creating a bug for it and discussion about it.

Pro points:

  • Possibly faster (although there are easier optimisations)
  • Stop people reading your code
  • Adding comments won't make code slower

Bad points:

  • Uses precious RAM (unless we throw away source code)
  • Uses precious flash (as you need two interpreters, or a compiler as well as a bytecode interpreter)
  • Without the source code, you can no longer edit what you've written. Line numbers of errors probably get lost too.

Other options:

  • JavaScript Minifier : JavaScript minifier #67
  • Add a way to execute actual assembler instructions (then WebUI can contain a compiler for C/JS/whatever language)
@gfwilliams
Copy link
Member Author

I should point out that this is not a small change to make (in fact it's bordering on a rewrite), and I think people are completely missing the point of Espruino.

Espruino was designed this way for a reason. JavaScript is always going to be slower than C - but at least Espruino is small, cheap, and low-power.

Sure you could add JIT compilation, more RAM, Flash, USB host support and a bunch of other stuff - but then it's not small, cheap, or low-power. Another project exists right now that does this too (and does it better) - it's called node.js, and it runs on BeagleBone, Raspberry Pi, and plenty of other boards.

@pfalcon
Copy link

pfalcon commented Oct 3, 2013

Thanks for opening this ticket. As someone who added comments touching this topic in the other ticket, I'd like to comment here too. (Maybe this should have been topic on a forum, but everyone is lazy sometimes to register on yet another size, plus codebase is here).

and I think people are completely missing the point of Espruino.

I believe I understand it. And while it's easily can be seen that Espruino interpreter implementation is not very efficient in general, for particular usage it appears to be just the gold mean, leading to very bright, really "exciting new" solution.

it's called node.js, and it runs on BeagleBone, Raspberry Pi

And yet you provide Espruino version for RPi ;-). KISS algorithms put into Espruino may work "well" for 16-64K of mem, but probably won't scale to megabytes of mem and big apps which people may want to run there. Also, sooner or later folks may want to run real webapps on Cortex-M3 too ;-).

So, all in all, this question is more of "what plans do you have regarding that?" My personal interest is that just some time ago (and after ~half-year consideration) I started to hack on unbloated language (http://squirrel-lang.org/ just in case), which I'd like to be scalable down to MCUs. It needs slimming down to achieve that (still hardly could target less than 16K RAM). Well, if you have plans to "pump up" Espruino, I might be interested in it instead (though I dislike JS ;-) ). If not, I'm just relieved that effort I already put into Squirrel is not vain :-D.

Of course, I hope this ticket will be useful for other folks too - as you say, this is going to come up regularly, so having central location with food for thought to refer folks to is helpful.

@gfwilliams
Copy link
Member Author

Closing this now, as we have http://www.espruino.com/Compilation

The interpreter is kept basically as-is, but you can tag functions and before they are uploaded via the Web IDE (or the command-line tool espruino-tools) they are compiled into ARM Thumb instructions.

It's still very beta, but any issues relating to it should really be in the EspruinoTools repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants