[HN Gopher] Toit - A Language Designed for Microcontrollers
       ___________________________________________________________________
        
       Toit - A Language Designed for Microcontrollers
        
       Author : floitsch
       Score  : 80 points
       Date   : 2022-06-08 13:11 UTC (9 hours ago)
        
 (HTM) web link (toitlang.org)
 (TXT) w3m dump (toitlang.org)
        
       | titzer wrote:
       | It's worth noting that Toit is developed by the team that
       | developed V8, so it's got a really solid implementation by very
       | knowledgeable people.
        
         | frankus wrote:
         | I wonder what the memory model is, and if it's suitable for
         | low-level and real-time code.
        
       | lawrenceduk wrote:
       | I looked at this the other day! Sadly no way to configure WiFi
       | other than at the point of flashing the device which rules it out
       | for a lot of use cases.
        
       | sk0g wrote:
       | The syntax looks pretty fun to work with! Nice balance of
       | terseness and readability.
        
       | ilvez wrote:
       | Random fact Wednesday: Toit is food in Estonian.
        
         | bmacho wrote:
         | https://en.wiktionary.org/wiki/toit
        
         | Zababa wrote:
         | Toit is roof in French.
        
           | speed_spread wrote:
           | Le toit! Le toit est en feuuuuu!
        
         | oneplane wrote:
         | Another random fact: Toit is followed up with noice in Brooklyn
         | 99
        
       | extinctpotato wrote:
       | It feels very Ruby-like. In fact, it makes me wonder why not
       | reuse Ruby's syntax if you're making a thing like that.
        
         | ricardobeat wrote:
         | That idea is taken. Twice.
         | 
         | https://mruby.org/
         | 
         | https://microruby.com/
        
       | Jistern wrote:
       | As long as Toit is licensed under the GNU Lesser General Public
       | License v2.1, I am unlikely to consider using it. By contrast,
       | MicroPython is licensed under the MIT License (MIT).
       | 
       | 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-....
        
       | hoosieree wrote:
       | I like the syntax. It looks like a combination of Ruby and Python
       | with a goal of being more terse than either.
        
       | skybrian wrote:
       | Supported hardware is very limited [1]. I guess it could be good
       | if you know you want to use an ESP32.
       | 
       | [1] https://toit.io/product/supported-hardware
        
       | AYoung010 wrote:
       | Call me old-fashioned, but I personally do not like the idea of
       | using a garbage-collected language for embedded development in
       | general, and it's just flat out non feasible to use for anything
       | which is timing-sensitive...
        
         | pjmlp wrote:
         | Astrobe, PTC, Aicas and microEJ disagree on that front.
         | 
         | https://www.astrobe.com/
         | 
         | https://www.ptc.com/en/products/developer-tools/perc
         | 
         | https://www.aicas.com/wp/products-services/jamaicavm/
         | 
         | https://www.microej.com/
         | 
         | Also I should note that many embedded computers in 2022 are
         | supercomputers when compared to the 1961 IBM mainframes running
         | Lisp.
        
         | turbinerneiter wrote:
         | What do you think is the ratio between projects that need
         | precise timing and projects that publish some sensor data every
         | 60 seconds?
         | 
         | 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.
        
           | cozzyd wrote:
           | If you're using LoRaWAN to publish and don't want to blow up
           | your power budget, you need to get somewhat good timing.
        
         | floitsch wrote:
         | In big parts that's true, but there are some good arguments in
         | favor of a GC for these small devices:
         | 
         | - 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.
        
         | stjohnswarts wrote:
         | depends on how the system works. What are the timing
         | requirements? How powerful is the CPU? How much memory do you
         | have? How often will the system be reset? Embedded isn't just
         | 8/16 bit CPUs with < 128k of memory these days.
        
       | hammyhavoc wrote:
       | Can't wait to hear all the mangled pronunciations of this.
        
         | ghkbrew wrote:
         | I don't see an etymology of the name on the site, so I'll just
         | assume they misspelled "tuit" [0]
         | 
         | [0] https://en.m.wiktionary.org/wiki/round_tuit
        
           | aaa_aaa wrote:
           | AFAIK this name was intentionally given with Austin Powers
           | reference.
        
           | stjohnswarts wrote:
           | too late for me, it will forever be "toyt"
        
         | one-more-minute wrote:
         | Must be because I learned some French as a kid, but I can't
         | help reading the "oi" as a "wa" sound in this context. Probably
         | not what the authors were going for.
        
       | lin83 wrote:
       | Is Jaguar an interpreter and Toit the scripting language? How
       | does it compare to MicroPython? Can I link in C drivers?
        
         | floitsch wrote:
         | Jaguar is the tooling to enable rapid development. It consists
         | of two parts: one that runs on the ESP32 and another one that
         | runs on your computer.
         | 
         | 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.
        
       | causi wrote:
       | I like it, but I am _never_ going to be able to read the name
       | without thinking of Goldmember saying  "toit like a tiger".
        
         | [deleted]
        
         | laputan_machine wrote:
         | I instinctively read the title of this thread in Goldmember's
         | voice
        
           | causi wrote:
           | "Toit, a languaj de-shined for microcontrolersh, yaysh"
        
       | floitsch wrote:
       | 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-TYea7jbYfj2ecMUmr0T0zd...
       | 
       | And here the MicroPython:
       | https://www.makerfabs.com/desfile/files/Get-Started-MicroPyt...
        
         | hoosieree wrote:
         | Thanks 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 wrote:
           | The `:` 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 wrote:
             | Excuse 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 those are similar
             | enough that I suspect an ancestral relationship). Does this
             | come from some chunk of programming-language lore I'm
             | unaware of?
        
       ___________________________________________________________________
       (page generated 2022-06-08 23:01 UTC)