4 ms·
Running TypeScript on ESP8266/ESP32 Devices
- connicpu 5y agoI'm curious and couldn't find the info from a quick search of the repo, how much flash space does the JS virtual machine take up? And how much space is left to include libraries you may need? Between the Arduino runtime, wifi library, mqtt library, libraries for talking to peripherals, and my C++ application code I'm already getting pretty close to the 512KiB limit for an ESP8266-based thermostat I've been working on. Hard to imagine JS being small enough to fit on that, but perhaps it's designed for embedded chips with a bit more flash space available
- thamer 5y agoI can't speak for a JS virtual machine, but for a point of comparison CircuitPython[1] runs on many ESP32 boards and builds are often under 1.5 MB. It does come with a whole set of modules, with the ones you'd expect to have in Python like "re" or "time" (although they only have a few functions in there), but also with CircuitPython-specific modules like "board" or "digitalio" to access peripherals, or "wifi" for networking. The boards listed on the CircuitPython downloads page usually have between 2 and 8 MB of flash, so you often have enough for the VM and your own code plus a few files. [1] https://circuitpython.org/ https://circuitpython.org/
- __ryan__ 5y agoThis makes use of a JS interpreter made for embedded devices: Espruino More details in the Espruino repo: https://github.com/espruino/Espruino https://github.com/espruino/Espruino
- skittleson 5y agoDevices memory vary in size https://en.wikipedia.org/wiki/ESP8266 https://en.wikipedia.org/wiki/ESP8266. Minification has been common with JS for years so it should be easy to add that in with the rollup.js build. Some checking be a nice to have.
- Already__Taken 5y agoWell, related to espruino as linked below. Having the VM does allow it to handle power and sleep states for you by the nature of the VM understanding the scheduling that's required.
- scommab 5y agohttps://github.com/Moddable-OpenSource/moddable https://github.com/Moddable-OpenSource/moddable lets you do JS development targeting ESP8266/ESP32 .
- deleted 5y ago[deleted]
- CharlesW 5y ago> Transpile TypeScript to Espruino flavor of JavaScript What are the benefits of doing this vs. using a runtime (like Moddable's XS) that supports ECMAScript 2018?
- skittleson 5y agoThe primary goal is to add TypeScript for types and abstractions. I dont think the JS runtime the TypeScript transpiler targets matters as long as it can be transpiled to the current version. I wasnt aware of that project but now I will look into it.
- ge96 5y agoComing from web I do find it brutal transitioning to C++ so it sounds interesting
- bloopernova 5y agoMay I suggest looking into CircuitPython or MicroPython? CircuitPython is well-supported by Adafruit, and works very well on RP2040s and ESP32s
- johnny22 5y agoI've looked into both, but I'd still prefer to write in typescript over python. Although those are both pretty decent. Of course, all my work stuff is still in C and C++ and will probably stay that way.
- skittleson 5y agoThat was the primary decision for working with TypeScript over Python. While I like, it's not my daily language of choice.
- bloopernova 5y agoNow I'm intrigued, because I'm working more and more with Typescript as part of my DevOps work. I'll have to give it a try!
- ge96 5y agoI'm trying to learn C++ just because of how widespread its use is.