Live data from Hacker News

DeviceScript – TypeScript for Tiny IoT Devices

github.com

41–50 of 160 posts

Re: DeviceScript – TypeScript for Tiny IoT Devices

#41

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?

One of they main reasons was that they had to: the cost of a more capable system was too high. In the last years that has improved drastically, and there are many usecases where the 5 USD increase in BOM needed to run JS/Python etc can be justified.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#42

I really want to be able to compile typescript to not javascript. Ideally to native but if it’s bytecode or whatever that’s fine I don’t care. It’s a nightmare trying to deal with bundling and compiling and targets and different import schemes ugh. I wish I could compile my programs it compiles all the stuff in node modules and gives me some working code. Desperate to get away from nodejs I tried deno and bun …. neit…

So you want structural typing, but for native? Funny, the fact that typescript is "only" structurally typed is one of my main pain points with the language. (Of course it's tons better than vanilla JS)

What exactly do you miss? JS has built-in reflection, eg `typeof instance`, `instance.constructor.name`. Even multiple dispatch can be hacked together if you really need it, eg there is a library @arrows/multimethod.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#43

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?

I agree, this will mostly go nowhere. Sure when somebody will prepare you DeviceScript environment for *your* board, then you are good to go. But in 99% of cases, you will get hardware in front of you which almost certainly is not supported by DeviceScript. And now without intimate knowledge of C, how are you going to expose interfaces of that particular hardware, so you can work with those interfaces in DeviceScript? Well you won't, you need to know C first.

Same problem for MicroPython. Same problem for LUA, same problem for any scripting language running on constrained MCU.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#44
post #32

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?

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.

How do you get that TypeScript or Python environment on the chip of your interest at the first place? How do you expose hardware interfaces without knowledge of C?

Re: DeviceScript – TypeScript for Tiny IoT Devices

#45
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.

How do you get that TypeScript or Python environment on the chip of your interest at the first place? How do you expose hardware interfaces without knowledge of C?

> How do you get that TypeScript or Python environment on the chip of your interest at the first place?

By having somebody else do it. Abstraction is a wonderful thing.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#46

Earlier quoted context omitted.

So you want structural typing, but for native? Funny, the fact that typescript is "only" structurally typed is one of my main pain points with the language. (Of course it's tons better than vanilla JS)

What exactly do you miss? JS has built-in reflection, eg `typeof instance`, `instance.constructor.name`. Even multiple dispatch can be hacked together if you really need it, eg there is a library @arrows/multimethod.

Those don't change that the type system is structural; the type system is actually not fully safe if you use the things you mention, eg:

  class Dog { woof(){} }
  class Cat { meow(){} }
  function f(a: Dog|Cat) {
    if (a instanceof Dog) { 
      a.woof()
    } else {
      a.meow()
    }
  }

  let dogish = {woof: ()=>{}}
  f(dogish)

This compiles because dogish is structurally a dog, the type system allows instanceof to narrow the type but "dogish instanceof Dog" is actually false, so at runtime this will crash after trying to call meow on dogish.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#47

Earlier quoted context omitted.

Making it easy for hobbyists who already know that technology to have access. Micropython has been successful, and this is an alternative to that.

The github project indicates "DeviceScript brings a professional TypeScript developer experience to low-resource microcontroller-based devices." If you tell me is a toy, and somebody's pet project: fine. Is all about having fun. But then don't mention "professional" in the project description.

Hmm?

Instead of ctrl+f for "professional" I suggest re-reading it

>professional TypeScript developer experience

It is about experience of sane programming environment, right?

Re: DeviceScript – TypeScript for Tiny IoT Devices

#48
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.

There are a number of reasons to do this. This sort of setup typically has the VM runtime flashed into the microprocessor's program space with the interpreted byte code stored in data space --- either internal or external.

1) It is obviously not as fast as native but it is fast enough for a lot of applications. In embedded work, you don't get extra credit for being faster than necessary. Speed critical functions like communications are mostly handled at native speed by the VM.

2) Code size. Interpreted byte code (minus the VM) can be smaller and less redundant than native. And by adding cheap external storage, code can easily expand beyond the native program space of the micro.

3) Easy remote updates. Byte code can be received and stored without making changes to the micro's program code (no re-flashing required). It's possible to fix bugs and make changes or even completely repurpose the hardware from afar.

Re: DeviceScript – TypeScript for Tiny IoT Devices

#49
post #45

Earlier quoted context omitted.

How do you get that TypeScript or Python environment on the chip of your interest at the first place? How do you expose hardware interfaces without knowledge of C?

> How do you get that TypeScript or Python environment on the chip of your interest at the first place? By having somebody else do it. Abstraction is a wonderful thing.

That's just kicking the can down the road. What if you are working on device which is under NDA? What if it is some exotic MCU which nobody else uses?

Re: DeviceScript – TypeScript for Tiny IoT Devices

#50

I really want to be able to compile typescript to not javascript. Ideally to native but if it’s bytecode or whatever that’s fine I don’t care. It’s a nightmare trying to deal with bundling and compiling and targets and different import schemes ugh. I wish I could compile my programs it compiles all the stuff in node modules and gives me some working code. Desperate to get away from nodejs I tried deno and bun …. neit…

What about AssemblyScript?
Post reply on HN