Rob's garden / notes / note

Note

Doing some C++ at work and wow it’s hard to go back to from JavaScript 😂 making me manage my own memory and actually plan my data structures😅

Although I’m working on an interesting library to add a basic JavaScript runtime to ESP microcontrollers to make their software malleable. So overall less C++ needed, which is pretty cool!

Yesterday I got it to run a “console.log(‘hello world’) and today I’ve been getting some timers involved. The current target script is:

console.log('starting at ' + Date.now())

setTimeout( () => console.log('done at ' + Date.now()), 1000 )

I’ve had to make my own internal timers and track the active ones to keep the program alive until they’re all complete. And it needs to call the right js function at the right time too!

The microcontroller doesn’t know about time, so I’ve added dodgy hack to override Date.now() in JavaScript to return the milliseconds since boot