Live data from Hacker News

PunyForth: Forth inspired programming language for the ESP8266

github.com

21–30 of 47 posts

Re: PunyForth: Forth inspired programming language for the ESP8266

#21

Great work indeed. Does it support the new ESP32 processors?

The ESP32 also uses an Xtensa, the LX6, which should have the same basic instruction encoding, etc (and I think they both use FreeRTOS, as well, but I only have an ESP32). Probably shouldn't be too hard. You can also stuff more functionality into it, too.[1]

[1] Related: I can't actually even find the documentation on what's precisely changed between the LX6 (ESP32) and the LX106 (ESP8266), other than the basics on the datasheets - I don't know of any documentation on e.g. any different architectural details. Maybe you have to ask Espressif. Or Cadence. Anyone have any idea?

Re: PunyForth: Forth inspired programming language for the ESP8266

#22
post #2

Why can't we get Rust for the ESP8266? :( I really dislike C, I'd love a higher-level language. As great as MicroPython is, the interpreter needs too much RAM, and I think Rust would be a great alternative.

Wouldn't Rust be overkill?

I think Forth is much more suitable here. You can implement a lot of features in 512K. You can extend the code (and language!) at runtime, you can debug remotely, and do other nice things.

Re: PunyForth: Forth inspired programming language for the ESP8266

#23

Earlier quoted context omitted.

Have you seen the eLua LTR (Lua Tiny RAM) patch? http://www.eluaproject.net/doc/v0.9/en_arch_ltr.html As for Rust, why do we think that should use significantly less memory than MicroPython or Lua? I've seen some threads with people doing measurements on simple programs and finding Rust up to 10x heavier on RAM than C. http://stackoverflow.com/questions/32762102/why-do-rust-prog...

If you looked at the link you included you'd see why the Rust version is larger, because they include the static library. There's nothing about Rust that intrinsically makes it larger than C.

You would need a basic standard library built with the binary when building for xtensa (esp) aswell. So yes, the size of the core parts of the stdlib between c and rust definitely do play a role.

Re: PunyForth: Forth inspired programming language for the ESP8266

#24
post #21

Great work indeed. Does it support the new ESP32 processors?

The ESP32 also uses an Xtensa, the LX6, which should have the same basic instruction encoding, etc (and I think they both use FreeRTOS, as well, but I only have an ESP32). Probably shouldn't be too hard. You can also stuff more functionality into it, too.[1] [1] Related: I can't actually even find the documentation on what's precisely changed between the LX6 (ESP32) and the LX106 (ESP8266), other than the basics on t…

Their datasheets only mention the PIN definitions and electrical characteristics of the microcontrollers. Try to get the information from the reference manual[0]. Also there are these books[1][2] by Neil Kolban.

[0] https://www.espressif.com/sites/default/files/documentation/...

[1] https://leanpub.com/ESP8266_ESP32

[2] https://leanpub.com/kolban-ESP32

edit:

More information about the differences: http://www.cnx-software.com/2016/03/25/esp8266-and-esp32-dif...

Re: PunyForth: Forth inspired programming language for the ESP8266

#25
post #21

Great work indeed. Does it support the new ESP32 processors?

The ESP32 also uses an Xtensa, the LX6, which should have the same basic instruction encoding, etc (and I think they both use FreeRTOS, as well, but I only have an ESP32). Probably shouldn't be too hard. You can also stuff more functionality into it, too.[1] [1] Related: I can't actually even find the documentation on what's precisely changed between the LX6 (ESP32) and the LX106 (ESP8266), other than the basics on t…

Most importantly, the ESP32 has register windows.

Re: PunyForth: Forth inspired programming language for the ESP8266

#26
post #22
post #2

Why can't we get Rust for the ESP8266? :( I really dislike C, I'd love a higher-level language. As great as MicroPython is, the interpreter needs too much RAM, and I think Rust would be a great alternative.

Wouldn't Rust be overkill? I think Forth is much more suitable here. You can implement a lot of features in 512K. You can extend the code (and language!) at runtime, you can debug remotely, and do other nice things.

Yes, but Forth doesn't have a borrow checker, so how will you know you're using memory safely?

Re: PunyForth: Forth inspired programming language for the ESP8266

#27

Earlier quoted context omitted.

Lua is strictly worse than MicroPython, I find. Memory usage is worse, and managing programs on it is bad too, although I haven't used it as much as MicroPython.

Have you seen the eLua LTR (Lua Tiny RAM) patch? http://www.eluaproject.net/doc/v0.9/en_arch_ltr.html As for Rust, why do we think that should use significantly less memory than MicroPython or Lua? I've seen some threads with people doing measurements on simple programs and finding Rust up to 10x heavier on RAM than C. http://stackoverflow.com/questions/32762102/why-do-rust-prog...

My problem with Lua and MicroPython is that your actual code takes up memory, ie even comments. Micropython can now compile to bytecode and load that, though, so it's better. I've had problems with Lua trying to load one or two hundred lines, though.

Re: PunyForth: Forth inspired programming language for the ESP8266

#28
post #21

Earlier quoted context omitted.

The ESP32 also uses an Xtensa, the LX6, which should have the same basic instruction encoding, etc (and I think they both use FreeRTOS, as well, but I only have an ESP32). Probably shouldn't be too hard. You can also stuff more functionality into it, too.[1] [1] Related: I can't actually even find the documentation on what's precisely changed between the LX6 (ESP32) and the LX106 (ESP8266), other than the basics on t…

Most importantly, the ESP32 has register windows.

Right, this is the kind of information I was looking for (maybe some actual ISA documentation; the instruction encoding method itself, etc).

But for this specific point -- I thought all of the Xtensa series used register windows? Or did they both have them but the ESP8266 never actually use them (somehow?)

Re: PunyForth: Forth inspired programming language for the ESP8266

#29
post #21

Earlier quoted context omitted.

The ESP32 also uses an Xtensa, the LX6, which should have the same basic instruction encoding, etc (and I think they both use FreeRTOS, as well, but I only have an ESP32). Probably shouldn't be too hard. You can also stuff more functionality into it, too.[1] [1] Related: I can't actually even find the documentation on what's precisely changed between the LX6 (ESP32) and the LX106 (ESP8266), other than the basics on t…

Their datasheets only mention the PIN definitions and electrical characteristics of the microcontrollers. Try to get the information from the reference manual[0]. Also there are these books[1][2] by Neil Kolban. [0] https://www.espressif.com/sites/default/files/documentation/... [1] https://leanpub.com/ESP8266_ESP32 [2] https://leanpub.com/kolban-ESP32 edit: More information about the differences: http://www.cnx-soft…

The ESP32 datasheet is really woefully inadequate for this part; it mostly describes the chip, but I guess what I'm really looking for is things like "A description of the ISA itself", i.e. the "LX6 datasheet", so to speak. So I want something like the the actual instruction encoding, instruction listing, etc for the LX6 series and what it supports precisely.

Re: PunyForth: Forth inspired programming language for the ESP8266

#30
post #8
post #3

Earlier quoted context omitted.

Isnt there an axpetimental Rust backend for ARM Cortex? ISTR seeing it discussed here.

Rust has Tier 2 support[0] for ARMv6 to ARMv8 and Tier 3 support[1], so there are experimental limited[2] backends for the various Cortex in Tier 3. However the ESP8266 is built around Tensilica's Xtensa, not ARM's Cortex. There currently is no support whatsoever for Xtensa in LLVM (let alone in Rust). Current microcontroller work is on MSP430[3] with work being planned for Amtel AVR[4] since the AVR branch was merge…

>However the ESP8266 is built around Tensilica's Xtensa, not ARM's Cortex.

DOH!

I have to say, though, that having the AVR code generator merged is very cool. At one time I was a big user of avr-gcc and remember when the AVR LLVM effort was just getting started. I haven't been following it, though.

One of the annoyances with gcc is that the optimizer kept wanting to use code motion to relocate the interrupt disable instruction to the beginning of the function it was found in. The only way to keep the optimizer from doing that would have been to make the instruction depend on all of RAM, which would effectively disable optimization for any function that disabled interrupts. So coding critical sections required a bit of jiggery-pokery to keep the optimizer from breaking your code. I hope the LLVM back-end found a way around that.

Post reply on HN