110 points · by floitsch · 4y ago · 69 comments
Here is the Toit version of it: https://docs.google.com/document/d/1K-TYea7jbYfj2ecMUmr0T0zd...
And here the MicroPython: https://www.makerfabs.com/desfile/files/Get-Started-MicroPyt...
remembered_ = List width/2: initial_value
half_height := height / 2
...
min_value := remembered_.reduce: | a b | min a b
These lines (with seemingly context-sensitive meanings for the / and : characters) feel less obvious to me than the examples on the home page.The `/` are also the same (division), but it's true that we also use `/` to introduce types. For example `x/int`.
I think Toit is relatively easy to learn, but there are definitely a few things that need explaining in the beginning.
In particular, Python basically won the significant-indentation argument. Since all programs are formatted with correct indentation the punctuation is redundant clutter. So for a new language it just feels right to go with indentation instead of curlies.
We also wanted to be free to add type annotations and other enhancements, so it was never going to be compatible with Ruby anyway. And we didn't want to raise expectations of Ruby-compatibility that would immediately be dashed.
https://www.ptc.com/en/products/developer-tools/perc
https://www.aicas.com/wp/products-services/jamaicavm/
Also I should note that many embedded computers in 2022 are supercomputers when compared to the 1961 IBM mainframes running Lisp.
- the GC is a sliding compacting GC. As such there is no fragmentation for heap-allocated memory.
- the memory on these devices is tiny. The GC thus doesn't take long time.
- the ESP32 has really good peripherals, making timing sensitive operations very rare. In most cases there is a hardware module that does the job for you. The timing requirements then usually become significant less important.
I think you can easily do 90% of iot projects with this. Which means you have more time for the 10% of projects that are actually hard.
From an embedded system PoV, your sensor might be a 1-Wire protocol device with a super strict signal timing. How do you mix both timing requirements? How do you differentiate embedded projects requiring "precise timing" from those others requiring "every 60 seconds"?
Unless Toit provides drivers for all kind of buses, sensors and peripherals AND it orchestrates the GC with the strict timing requirements. Otherwise it's probably a good fit only if it just runs on a known controlled development board/architecture/platform.
For example the 1-wire protocol is implemented using the RMT (remote control) peripheral. The pixel strips driver uses the UART or i2s.
If really necessary, we could drop down to C, but the hardware is usually better (more precise and leaves us to do other things in the meantime).
How often are you bitbanging non standard protocols? And if so, which field are you in?
Maybe they don't do[1] dynamic memory allocation in code segments that have real time constraints, or after initialization, etc. (Most embedded projects actually don't have hard real-time constraints, or have them in extremely localized places like bit banging loops...) This is sounds like a good idea and is orthogonal to whether the language's dynamic allocation support is via malloc/free or gc.
On microcontrollers, which often have very limited RAM, I'd prefer avoiding doing any heap allocation at all. If there is any need for any dynamic allocations, they are within fixed-size memory pools — each with only fixed-size objects or with objects on a stack.
Main restriction is, that we haven't finished the Windows implementation yet. Specifically networking and spawning processes only works on Linux/macOS so far. (The main reason we ported the LSP server to Go).
The `host` package (https://pkg.toit.io/package/github.com%2Ftoitlang%2Fpkg-host...) provides some functionality for running things on the desktop.
Whenever a new program is ready, it gets pushed (over WiFi) to the device. The whole process only updates the actual program (not the whole OS), thus making the development cycle really fast.
Compared to MicroPython, Toit is significantly faster. In my (obviously biased) opinion, it's also more robust.
You can't link C drivers directly without modifying the Toit code base, but there is a bridge to talk between C and Toit code. Generally, we prefer to reimplement the drivers in Toit. However, for some bigger ones it clearly makes sense to keep the C version.
As others have noted, Toit seems like a bad name. I suppose non-French speakers will tend to inadvertently mispronounce Toit.
Getting traction is hard. In my opinion, having a restrictive license and a bad name make it less likely Toit will gain traction. Finally, Toit's licensing reminds me of Mongoose OS https://github.com/cesanta/mongoose-os#mongoose-os---an-iot-....
Basically if the thought of your code ever ending up in something that someone might somehow make money from, like maybe in an iOS app, is somehow icky - then GPL is for you! If you just want to put it out there and code, not politics, is your thing - go MIT.
Source... https://www.reddit.com/r/roguelikedev/comments/4g738z/commen...