9 ms·
DeviceScript: TypeScript for Tiny IoT Devices
- LispSporks22 3y agoWould be cool if they could host the compiler and the runtime on the target device like in Forth. Do my hardware hacking and experiment over serial port that way without the edit compile flash reset cycle..
- rektide 3y agoIt'd be nice if AssemblyScript + wasm could compete here too. Quite the effort! Made their own small vm interpetter.
- dmitrygr 3y agoWasm is just a lobotomized assembly. On an embedded device your code is likely the only thing running so just use normal asm? Your free copy of GCC will happily compile c to it. Try.
- rektide 3y agoI think it's a bit simplistic to assume native, already compiled code is the only payload worth considering. The portability of wasm will be pretty excellent, and over time there may be a great cross-language ecosystem surrounding wasm that native may not match. Wasm also seems like a potentially better target than what we have here, which seems interpetter focused. Wasm otoh might actually be able to jit/aot compile down (which the mentioned wasm3 interpretter eskews with a list of good reasons, for anyone looking for counterarguments). And likely will have more invested in the ecosystem in doing optimizations in general.
- dmitrygr 3y ago> I think it's a bit simplistic to assume native, already compiled code is the only payload worth considering. WASM IS compiled code > The portability of wasm will be pretty excellent, and over time there may be a great cross-language ecosystem surrounding wasm that native may not match. 1. They said that about java too. 2. Problem is...you need to compile something to WASM, and currently a lot more somethings are compileable to native than to wasm, and i doubt this will ever change, since compiling to wasm is a strict superset of compiling to native, in terms of work involved in making a compiler. (this is not true for old esoteric architectures, but i do not see you offering me a WASM runtime for the 8051 either) > Wasm otoh might actually be able to jit/aot compile down You know what else does that? Any compiled language ... to native code... In fact, we "AOT" it from the start in a process we call ... compilation. Your local free copy of gcc can do this for you. Check it out. > And likely will have more invested in the ecosystem in doing optimizations in general. You know what else does good optimization for a given target? You local free copy of gcc. Check out the "march", "mcu", and "O" flags Point is: I buy the use of interpreted code on IoT: so people who cannot program can still make a light blink. But as soon as you go to compiled code, might as well compile for your actual target, and not a pointless IL (which is what WASM is until you show me your HDL for a WASM cpu)
- pjmlp 3y agoThe amount of WebAssembly push, ignoring all bytecode based formats since the late 1950's is incredible.
- hutzlibu 3y ago"WASM IS compiled code" Yes, but to a VM, so the same code can run wherever there is a wasm runtime (number is growing).
- rektide 3y agoI feel like you are super trapped in a very small way of thinking. Say I run an IoT system across a variety of embedded systems. I could dynamically load small behaviors & scripts to all targets with this. User scripts could target all devices. Your aim that native code can target everything seems to be pretty limited. A lot of languages can't or won't invest in wide micro-architectural & embedded support. I feel lile you are confining yourself to a very very narrow position, & refusing to see possible middle grounds or uses. We needn't adopt such stark framing.
- circuit10 3y ago> but i do not see you offering me a WASM runtime for the 8051 either As long as there’s a C compiler for it, just use https://github.com/WebAssembly/wabt/blob/main/wasm2c/README.md https://github.com/WebAssembly/wabt/blob/main/wasm2c/README.... or https://github.com/turbolent/w2c2 https://github.com/turbolent/w2c2 That way, you get the portability of C, the optimisation power of GCC or your favourite C compiler and the portablity and determinism of WASM! Obviously there’s some overhead but there are definitely situations where this is a good option, especially where there’s a compiler available for WASM but not for whatever obscure platform you want to use
- dolmen 3y ago> The portability of wasm will be pretty excellent, and over time there may be a great cross-language ecosystem surrounding wasm that native may not match. I'm old enough to have lived the Java experience: "Write Once, Run Everywhere".
- qbasic_forever 3y agoIt can, wasm3 is a wasm interpretor ported to a lot of bare metal microcontrollers: https://github.com/wasm3/wasm3 https://github.com/wasm3/wasm3
- circuit10 3y agoOr you can compile it to C with wasm2c or w2c2 for much better performance
- gedy 3y agoLooks nice, didn't see in info what devices are supported yet?
- aroman 3y agoLooks like at least the Pi Pico and ESP32 are supported: https://microsoft.github.io/devicescript/devices https://microsoft.github.io/devicescript/devices
- gigel82 3y agoInteresting choice to build a brand new JS engine from the ground up. Wondering if there's a life for that outside of the project as an embeddable JS / TS engine (especially after Microsoft abandoned Chakra/ChakraCore a few years back).
- mmoskal 3y agoThere are many choices we have made that wouldn't make sense on desktop class cpu... 5 orders of magnitude of difference in RAM size is somewhat significant in design choices :)
- gigel82 3y agoHey, desktop apps that embed JavaScript engines would also love to get an option 5 orders of magnitude less memory intensive :) Even ES5 (the rest can be polyfilled).
- niea_11 3y agoIt's a subset of typescript : https://microsoft.github.io/devicescript/language https://microsoft.github.io/devicescript/language Microsoft did something similar before (without a vm) called Static Typescript : https://www.microsoft.com/en-us/research/publication/static-typescript/ https://www.microsoft.com/en-us/research/publication/static-...
- mmoskal 3y agoSame people :) We tried to make DeviceScript closer in semantics to real JS (prototypes etc) and easier to port. You pay with performance.
- CharlesW 3y agoI believe Moddable's XS was the first to compile JavaScript to bytecode on a computer for embedded deployment: https://www.moddable.com/faq#xs-in-c https://www.moddable.com/faq#xs-in-c (XS is a complete ECMAScript 2020 implementation, though.)
- anujdeshpande 3y agoI am always a little surprised by efforts like these coming from big companies. There have been multiple efforts in the past to put languages meant for the web on small footprint devices - especially JavaScript. - Tessel (closed down, domain used to be tessel.io) - Toit Lang: https://toitlang.org/ https://toitlang.org/ - Moddable: https://www.moddable.com/ https://www.moddable.com/ - Espruino: http://www.espruino.com/ http://www.espruino.com/ - mBed tried it too: https://os.mbed.com/javascript-on-mbed/ https://os.mbed.com/javascript-on-mbed/ - https://github.com/coder-mike/microvium https://github.com/coder-mike/microvium I am sure I am missing a few here.. Note that some of these projects are over a decade old! Maybe I am the "old man yelling at the cloud" meme, but I don't see embedded developers who have to maintain a project for many many years, using a programming language that changes often.
- astrobe_ 3y agoBut being able to fish in the ocean of JS devs for embedded is the dream of every manager.
- CSSer 3y agoAnd it may be a foolish one because that ocean is filled with sea monsters that even TS can’t tame.
- akiselev 3y agoFrontend developers can barely be arsed to read the short React docs once a year to catch up on any updates. There is no way in hell we're going to be able to function in an industry with thousand page data sheets and programming manuals.
- EddieEngineers 3y agoThis looks pretty nice! Especially https://microsoft.github.io/devicescript/developer/simulation https://microsoft.github.io/devicescript/developer/simulatio...
- steve_adams_86 3y agoI’m interested in that too. There are a lot of simulators out there, but they tend to be either under-featured or very user-unfriendly.
- Ins43b 3y agoI've been using Espruino with TypeScript code for some years now, but this looks quite interesting too. Time for a new IoT project to test this out.
- epolanski 3y agoI have always been interested now that I've bought and renovated my home into some nice experiments with IoT devices or building my own stuff. What would be an interesting starting point? I honestly don't even know what I want to build to be fair but always been interested in what the possibilities could've been with this kind of pico boards up to the raspberry (which is in a totally different range).
- huseyinkeles 3y agoI've been doing home automation for many years. From what you described, using Home Assistant in the center would be the way to go (works fine on a raspberry pi, in the beginning at least) For the devices, I mainly use zigbee sensors and lights etc. and bunch of fully DIY stuff running mostly on ESP32 with ESPHome. For the starters, you can skip the zigbee devices all together and experiment with Home Assistant + ESPHome
- baq 3y agoNote that the rpi is way overpriced for what it is currently, just get a mini pc with real storage, unless you need the gpio
- sunshine-o 3y agoM5Stack (https://m5stack.com/ https://m5stack.com/) could be a good starting point, especially if you do not know exactly what you wanna do.
- mmackh 3y agoAccess control with NFC (sticker on the phone) is a big upgrade. I’ve developed some hardware around this https://instanfc.com https://instanfc.com
- zokier 3y agoMicroPython has managed to find its niche and be moderately successful, I don't see why this couldn't manage similar status. But in the same vein I don't think this will become default choice for embedded anytime soon
- photochemsyn 3y agoWhat's the minimal reasonable footprint in terms of memory requirements and processing power for such a 'tiny IOT device'?
- deleted 3y ago[deleted]
- steve_adams_86 3y agoThey support specific devices:https://microsoft.github.io/devicescript/devices https://microsoft.github.io/devicescript/devices
- nonethewiser 3y agoOn that site, cmd+f makes the video full screen. yuck
- orhmeh09 3y agoI have found the browser extension StopTheMadness to be invaluable to browsing the web in 2023. https://underpassapp.com/StopTheMadness/ https://underpassapp.com/StopTheMadness/ It even works on Chrome: https://underpassapp.com/StopTheMadness/support-chrome.html https://underpassapp.com/StopTheMadness/support-chrome.html
- therein 3y agoTIL about the `ping` attribute on HTML anchor elements.
- cedarcedar 3y agoI've been having a lot of fun with https://kalumajs.org/ https://kalumajs.org/ recently for silly JS embedded things. It's been great so far, and has a cool little community! It's a runtime built on top of JerryScript, which has been pretty neat to look into as well: https://jerryscript.net/ https://jerryscript.net/
- dolmen 3y agohttps://jerryscript.net/getting-started/ https://jerryscript.net/getting-started/ => "Currently, only Ubuntu 18.04+ is officially supported as primary development environment." :(
- bakugo 3y agoI know companies are desperate to replace every programming language with javascript so they can just hire cheap junior web devs to do everything, but this is ridiculous.
- henning 3y agoI love the idea of the code in my grandma's pacemaker having dozens of exploitable vulnerabilities from all the fucking JavaScript code in there! Yaass, slay (old people and people in elevators and heavy machinery)!
- jaywalk 3y agoNothing you mentioned falls into the realm of IoT. This is not for life- or safety-critical devices.
- detaro 3y agoIoT includes all kinds of big industrial stuff. One would hope the people building it do a good job keeping the connected bits away from the critical bits, but past decades of that industry don't make one too hopeful about it. (Although something like this specifically would be less likely to be used, yes)
- HeyLaughingBoy 3y agoI'll just leave this here on the doorstep: https://www.fda.gov/medical-devices/digital-health-center-excellence/cybersecurity https://www.fda.gov/medical-devices/digital-health-center-ex...
- dolmen 3y agoWhat about C?
- paulddraper 3y ago"TypeScript is a superset of JavaScript." "DeviceScript is a subset of TypeScript." We need to go deeper.
- leodriesch 3y agoTypeScript is a superset of JavaScript.
- 0xCAP 3y agoFor good and for bad, let's not forget it won't support (at least a big portion of) existing npm modules.
- robbywashere_ 3y agoI have personally been trying to find either a language which transpiles to c or c++ or one with near performance to run on a ESP32. It would be nice to also make use of existing c++ libraries. I’ve seen NodeMCU, go lite, mini python, you name it. Any suggestions? I am considering rust or zig…
- franky47 3y agoVery cool, looking forward to seeing more integration with the IDE for debugging (eg: serial interface monitors, register watches, interrupt control, logic trace analyser etc). I've been using PlatformIO [1] (albeit with C++) in VScode, it would be a good DX baseline for a comparison. [1] https://platformio.org https://platformio.org
- ilyt 3y agoWhat those poor devices did to deserve such malady be placed upon them...
- Humphrey 3y agoI wonder if the compiler could be adapted to target other platforms, such as desktop, mobile, WebAssembly, or WASI? TypeScript is a wonderful language to develop in, and it would be awesome to be able to build TypeScript code down to small apps that don't need a JS Runtime to execute. I'd definitely be up for sacrificing some of the dynamic part of JS for being to build small native executables.
- dolmen 3y agoThe DeviceScript project already provides a WebAssembly VM: https://microsoft.github.io/devicescript/api/vm https://microsoft.github.io/devicescript/api/vm
- qbasic_forever 3y agoAssemblyScript might be what you're interested in, it's a typescript-like language that compiles to WASM code: https://www.assemblyscript.org/ https://www.assemblyscript.org/
- SEJeff 3y agoRelevant: ESPHome is a firmware for esp8266 / esp32 series IoT chipsets that can be configured mostly with a web gui or yaml file. https://esphome.io https://esphome.io
- kubota 3y agoI've used C++ on hobby esp32 projects, this is appealing to me. I could not find details on resource usage in the documentation.
- andrewstuart 3y agoWhen do we get a TypeScript compiler for Windows/Linux?