+ 2

JavaScript for Arduino

I came up with the idea of building a JS compiler for AVR (the architecture of the Arduino microcontrollers), since JS is getting more and more popular. At first I thought that I should check out V8 engine and see if I can make it generate AVR machine code. What I found out was that V8 is a JIT compiler/interpreter. I am currently thinking of writing a new compiler from the ground up, since modifying V8 could be a lot of trouble. I believe that, even if I could make it generate binaries Ahead Of Time, it would still be difficult to customize it for such an architecture. Do you guys think that I should give V8 a try or go ahead and write a new compiler?

10th Jun 2019, 9:14 PM
dim_knp
dim_knp - avatar
5 Antworten
+ 2
You can't write a javascript compiler alone, it's just infeasible. But what I do know is that javascript-on-microcontrollers has been done before, check out the Espruino!
11th Jun 2019, 1:45 AM
Schindlabua
Schindlabua - avatar
+ 2
I found a thread about the reasons for which making a JS compiler is a pain. https://news.ycombinator.com/item?id=10228904
11th Jun 2019, 4:44 AM
dim_knp
dim_knp - avatar
+ 1
Schindlabua I just checked out Espruino. It uses an interpreter, instead of a compiler, and it doesn't support Arduino boards. Seems like JS is very complex to get compiled AOT 😅
11th Jun 2019, 4:25 AM
dim_knp
dim_knp - avatar
+ 1
You can use cylon.js module https://cylonjs.com
5th Aug 2019, 7:07 PM
magad
magad - avatar
0
magad I will definitely give this a try
6th Aug 2019, 12:30 AM
dim_knp
dim_knp - avatar