Live data from Hacker News

DeviceScript – TypeScript for Tiny IoT Devices

github.com

121–130 of 160 posts

Re: DeviceScript – TypeScript for Tiny IoT Devices

#121

Is really hard for me to understand how running an VM on a resource constrained device has any benefit. There is a reason why those devices run using very lightweight "OS"s like FreeRTOS and Embedded C. Why the constant obsession to apply a technology designed for a specific purpose everywhere else, even when it doesn't make sense?

The Apollo program went to the moon with a complex VM on top of an extremely limited physical architecture. That's actually one of the main reasons to do it, because you can implement a strictly better (in all sorts of ways) virtual machine on top of really awful hardware.

Not to say that's valid in this instance, but plenty of early VMs were entirely made to improve resource constrained hardware

Re: DeviceScript – TypeScript for Tiny IoT Devices

#122
post #35

Earlier quoted context omitted.

A VM can make all the gaping security holes portable between IOT devices.

I appreciate the tongue-in-cheek, but I think there‘s really the chance for better IoT security when using a VM. Those things are connected to the internet (duh) and sandboxing is probably a good idea. You obviously don’t need a VM for that, but maybe the tradeoffs are favorable.

99% of the security issues in the IoT things are software design stupidity. Using a "safe" language or "sandboxed" VM cannot save your lightbulb when it's main loop includes "fill buffer with content from HTTP endpoint and execute it"

Re: DeviceScript – TypeScript for Tiny IoT Devices

#123
post #32

Earlier quoted context omitted.

Easy: because TypeScript or Python are way easier to learn than C. Learning C is a long, arduous, uphill battle against arcane error messages and undefined behaviour. Unless you have a background in C/C++ already, most people can probably get up and running with something like this way, way faster.

Good luck understanding things like `if(!!!c) { ... }` or why a line-break after a return statement matters in JavaScript/TypeScipt ;) JS has its own footguns and legacy baggage.

I've never seen `!!!` in JavaScript, and I do a lot of it. Care to share?

Re: DeviceScript – TypeScript for Tiny IoT Devices

#126

My personal opinion is that good typescript to C transpiller would do a way better job, tons of microcontrollers supported out of the box. I would be also happy to use it for desktop. With some tricks it could even support references and additional numeric data types (u8, i8 ... ) without breaking any syntax

I think a language that just transpiled to the equivalent C would be pretty awesome. I know Google is building Carbon, but it is more focused on C++. They pitch it as Typescript to JavaScript, Scala to Java, Carbon to C++.

Instead of Rust or Zig trying to replace C++ or Java, is seems better to just integrate with it without linking through some FFI.

I'm working on some C code for some microcontroller since it was too difficult to use Rust.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#127
post #17

Is the only reason for this to make it possible for web developers or people who know TypeScript to write code for IoT Devices? To fill the lack of experienced low level programmers? Because as language alone, I don't see a reason why I should I ever use this if I am not familiar with TypeScript already.

>Is the only reason for this to make it possible for web developers or people who know TypeScript to write code for IoT Devices? To fill the lack of experienced low level programmers? Which is funny because there's no lack of low level programmers in my experience. Companies just try and pay Embedded Systems Engineers and Electrical Engineers dirt compared to "Software Engineers". In the same part of NY where SWE bas…

In my experience, a firmware engineer contractor is much more expensive than a web contractor. But that's probably just a contractor supply/demand thing vs full-time.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#128
post #26

Earlier quoted context omitted.

They should integrate with Zephyr OS, as they have a good generic sensor API, with tons of device drivers and platform support.

I wouldn't say zephyr has "tons" of drivers, except maybe in comparison to other RTOSes. It has a few drivers for each of the device types you might use, but you can't just buy random hardware without checking support the way you can with Linux. There's enough that you have examples for implementing your own drivers pretty easily though.

Tons might be stretching it. But to my knowledge there are not many alternatives for microcontrollers that have more? Hopefully one day it will be like Linux. At least they are trying to tackle the driver problem, unlike other most other RTOSes.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#129
post #100

I’ve been mixed about using alternative languages or specialized runtimes on IoT devices and while I think an inherently event-driven language like JavaScript, with its first-class function as value support and widely used patterns, I’ve been of the mind lately that building firmware with these tools may be the wrong approach. First, most IoT device behavior can be described with a finite number of actions, and usual…

I don't think there's anything inherently event-based in JavaScript the language, it's just how the browser API works. You can just as easily write busy loops.

Sure, but that’s not the point here. With that logic, nothing is truly event-based if you can conceivably use it other ways. JavaScript was designed to interface with the DOM and had to support certain flows which is why I classify it inherently event based even if that does not meet technical requirements to call it so.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#130

My personal opinion is that good typescript to C transpiller would do a way better job, tons of microcontrollers supported out of the box. I would be also happy to use it for desktop. With some tricks it could even support references and additional numeric data types (u8, i8 ... ) without breaking any syntax

Does such a thing exist? I would love something like that, but is it even feasible? Isn’t there a lot more you need to be aware of, to make a translation of say TS’s objects into C?

These are far from perfect, but still something:

https://github.com/andrei-markeev/ts2c/

https://github.com/evanw/thinscript

If you aim for 32 bit microcontrollers then you can go with assemblyscript to wasm and then with wasm to C transpiller

Post reply on HN