Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intergrate C runtime interpreter for dynamic lambdas #2707

Open
apbodrov opened this issue Apr 29, 2024 · 1 comment
Open

Intergrate C runtime interpreter for dynamic lambdas #2707

apbodrov opened this issue Apr 29, 2024 · 1 comment

Comments

@apbodrov
Copy link

apbodrov commented Apr 29, 2024

Describe the problem you have/What new integration you would like
Integrate C-based interpreter, like https://github.com/jingoro2112/wrench

Please describe your use case for this integration and alternatives you've tried:
I want to make HA and ESPHome automations more "transactional". Now it’s more convenient for me to configure sequential commands through HA automation YAML, but this method is not resistant to communication problems between ESP32 and HA.
Using lambdas requires recompiling the config, which is inconvenient for regular updates

Additional context
https://home.workshopfriends.com/wrench/www

A full-featured compiler+interpreter that uses a bare minimum of ram and program space.

How little? The wrench Virtual Machine compiles to ~28k on an Arduino, and
uses less than 700 Bytes of RAM to operate, it is fully functional on an Uno Mini.
Highlights:

  • Weakly typed, supporting native 32-bit int, float and string.
    Code is easy to write with familiar c-syntax

  • Optimizing compiler and very fast VM

  • Produces very compact endian-neutral bytecode: compile-anywhere-run-anywhere.

  • Can execute from ROM, no local copy of the code is made

  • Multiple concurrent contexts supported

  • Code is easy to write, imagine c with the typenames removed; that's pretty much it.

  • Supports everything a good interpreter should: if/then/else/do/while/for/switch/functions/operators/etc..

  • Yes structs too

  • Yes switch (and NO it's not if-else sugar)

  • Can operate directly on data and exposes all static values to be manipulated externally and directly.

  • Can call back and forth to native code with minimal overhead

  • API is designed to be easily extended, that's the whole point!

  • Memory is garbage-collected but only for dynamic arrays. Unless you are allocating/de-allocating arrays the gc never runs.

  • Includes a handy command-line tool

Also, #805 (conditions, loops, expressions) #1840 (changing at runtime)

@apbodrov apbodrov changed the title Intergrate C runtime interpreter to dynamic lambdas Intergrate C runtime interpreter for dynamic lambdas Apr 29, 2024
@beranm
Copy link

beranm commented May 1, 2024

I like that idea. I would like to integrate it in YAML code to be able display GPIO status on 128x128 display for example. Like M5 Atom S3. when device is using ports (RS485 etc) then be able to show wifi status of the ESP and GPIO status as well to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants