3 ms·
For those interested in a comparison to MicroPython: I recently wrote a Toit version of the MakePython ESP32 Dev Kit lessons. Here is the Toit version of it: h
by floitsch 4y ago
For those interested in a comparison to MicroPython: I recently wrote a Toit version of the MakePython ESP32 Dev Kit lessons.
Here is the Toit version of it: https://docs.google.com/document/d/1K-TYea7jbYfj2ecMUmr0T0zd4JDpk5lo0mJNOLPUrhc/edit?usp=sharing https://docs.google.com/document/d/1K-TYea7jbYfj2ecMUmr0T0zd...
And here the MicroPython: https://www.makerfabs.com/desfile/files/Get-Started-MicroPython-with-ESP32-V2.2.pdf https://www.makerfabs.com/desfile/files/Get-Started-MicroPyt...
- hoosieree 4y agoThanks for sharing. Complex examples like these are great to highlight syntax which simpler examples never mention. For example (heart rate sensor excerpt): 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.
- floitsch 4y agoThe `:` are actually doing the same thing, introducing a block (think of it like a limited function). 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.
- mananaysiempre 4y agoExcuse my idle curiosity, but... slash for type ascription? How did that happen? The only precedent I can think of is Prolog’s arity annotations (and jq’s, but I suspect a direct influence there). Does this come from some chunk of programming-language lore I’m unaware of?
- krallja 4y agoIt’s also used in Elixir and Erlang for arity, but now that I think about it, it’s probably descended directly from Prolog.
- floitsch 4y agoWe couldn't use `:` as that one is already used for too many things. We then experimented with different tokens, and `/` felt best.
- mananaysiempre 4y agoWadler’s law or not, I’m not criticising, just curious :) Thank you (and 'EricCorry in sibling comment) for taking the time to answer! [Yes, colons are nice as block introducers but don’t play nice with colons for type ascription, which is where we got Python’s asinine f(x: int, y: bool) -> str; don’t know why Rust went with that instead of ML’s uniform f(x: int, y bool): str.]
- hoosieree 4y agoAnswers from the implementors, awesome!
- ErikCorry 4y agoPart of it is that we already used colon for several things. Also types are optional in Toit, so they are a bit like comments (though they are now checked so they are less like comments now). So they look a little like // comments.