10 ms·
The Toit language is now open source
- scrubs 5y agoHumor HN: Can I get a +1 for Austin Powers connection to title word?
- lgas 5y agoI was assuming Brooklyn 99.
- pansa2 5y ago> more than 30x faster than MicroPython on an ESP32 Based on a quick look at the file “interpreter_run.cc”, Toit’s VM appears to be a stack-based interpreter like MicroPython’s. It would be interesting to know what techniques are being used that enable Toit to be so much faster.
- kasperl 5y agoAmong other things, Toit uses the selector-based row displacement technique for building a compact method dispatch table that can be queried in constant time. If you're into fast virtual method calls - also for dynamic languages - you might want to take a look at Karel Driesen's excellent PhD dissertation on the subject: https://cs.ucsb.edu/sites/default/files/documents/1999-24.ps https://cs.ucsb.edu/sites/default/files/documents/1999-24.ps
- kasperl 5y agoOh, and full disclosure: I'm the author of the blog post.
- tomp 5y agois this the disertation (.pdf link)? http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.5449&rep=rep1&type=pdf http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34....
- floitsch 5y agoIt's this one: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.29.8713&rep=rep1&type=pdf https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.29...
- deleted 5y ago[deleted]
- matt_trentini 5y agoSome, you know, _actual benchmarks_ might be nice too. The claims are certainly possible, but somewhat hollow without evidence...
- kgeist 5y agoWhat are the advantages of creating a whole new language, as opposed to creating an implementation for a strict subset of an existing language? I skimmed through some tutorials and didn't find anything special about the syntax/semantics. The blog post doesn't explain it either.
- mpfundstein 5y agothe answer is hidden in the name of the language ;-)
- sroussey 5y agoLike AssemblyScript?
- ErikCorry 5y agoI don't personally think that using a subset of an existing language is a pleasant solution for programmers. The language doesn't get a coherent design, and you don't know which parts of the language will be present. We made lots of small decisions to make Toit useful for IoT. One of the things we optimized for was making the program code ROMable, so you can leave it in Flash. This has subtle effects on the language design but is vital on small devices where flash is often much larger and more power efficient than RAM. We also just wanted to make a modern language with decisions that are natural in 2021, but weren't well known when Python was invented. Things like nullable types, or a language server that gives you nice autocompletion in VS Code. This also affects language design: collection.size is better than len(collection) because you can type collection.<tab> and the editor will help you. https://twitter.com/toitlang/status/1395365234664161283 https://twitter.com/toitlang/status/1395365234664161283 https://docs.toit.io/language https://docs.toit.io/language
- CornCobs 5y agoI also dislike language subsets. I feel that you run into the limitations of the subset real quick and figuring out the boundaries of the subset often feels like groping in the dark. Especially true for large languages like Python. My most recent experience is with Numba, the python subset JIT, so it may be slightly different for micropython
- the__alchemist 5y agoThe docs page linked is, as expected, about language and syntax basics. Is there an example of it in use in a project, eg with interrupts, GPIO, bus access, DMA etc? There are a few examples on the Github, but they're terse. What does performing an SPI etc operation look like? How will syntax for things like this map to MCU hardware? Eg built in to the language, or with HAL and peripheral access libs etc? What makes it specifically targeted at IoT vice general embedded? RF support built into the standard lib? Security features, eg like nRF-53 and Cortex-M33?
- ErikCorry 5y agoAs an example, here's the driver for small TFT screens of the type that is built into the M5Stack. This is an SPI-attached device: https://github.com/toitware/toit-color-tft/blob/main/src/color_tft.toit https://github.com/toitware/toit-color-tft/blob/main/src/col... If you just have an M5Stack Core2 and want to play with it, then you don't need to write a new driver though. Probably you want the examples from this package: https://pkg.toit.io/package/github.com%2Ftoitware%2Ftoit-m5stack-core2@v1.1.0 https://pkg.toit.io/package/github.com%2Ftoitware%2Ftoit-m5s... (The implementation of that package in the src directory is an example of using an I2C peripheral.)
- akavel 5y agoHow many bytes of bytecode & any envelope does this file compile to? Together with the include'd deps vs. alone without them? How many bytes does the VM interpreter & runtime take?
- laydn 5y agoGiven that this stack costs $6/year, running on a $2 controller, it seems somewhat expensive, unless it is providing some sort of advantage/benefit. However, the examples on Github aren't complex enough to show what is the advantage of this ecosystem. Perhaps a much more detailed blog post going over an example would help us understand why this stack is useful? Since you appear to have paying customers, clearly, there is an advantage, but it is not immediately obvious.
- the__alchemist 5y agoWhat happens if the devs making a device stop paying? Do the customers' devices stop working? Also, that seems like an unacceptably steep BOM item for a consumer device. The MCU itself costs less in many cases over reasonable device lifetimes.
- matharmin 5y agoI'd assume offline features would keep functioning, but online features would stop working. The online features seem to be device provisioning (so may not be able to change WiFi access points?), OTA updates, and cloud PubSub.
- kasperl 5y agoIt is worth noticing that you enable and disable the serviceability for individual devices when you want to. Your unserviced devices are free and keep running your code. https://toit.io/pricing https://toit.io/pricing
- detaro 5y agoThe submission is about the language, which they just open-sourced and thus doesn't cost anything.
- meltedcapacitor 5y agoYes but may not be worth learning if it gets orphaned once the sugar daddies realize selling cloud service subscriptions to $2 sensors is a naff idea. A community could pick it up, but doesn't work every time with open but abandoned VC-ware.
- jb1991 5y agoThis is an extraordinary step forward for our industry, and I’m quite certain we will look back five or perhaps 10 years from now at this moment and realize just how pivotal it was.
- Rochus 5y agowhy? what's different?
- kgersen 5y agohow does it compare to tinygo ? (https://docs.toit.io/language/toitversus https://docs.toit.io/language/toitversus compares only vs 'not made for iot' languages which is not very relevant to do)
- floitsch 5y agoIt's not Go ;) In all seriousness, though: if you like Go, then tinygo could be a good solution. Personally, I find coding in Toit just a much more pleasant experience.
- smarx007 5y agoPrevious attempt to create a language for networked embedded systems specifically: https://sing.stanford.edu/site/publications/pldi03gay.pdf https://sing.stanford.edu/site/publications/pldi03gay.pdf
- drewm1980 5y agoNaming is hard... https://en.wikipedia.org/wiki/Twat https://en.wikipedia.org/wiki/Twat Was that intentional? Someone must have said your acronym(?) out loud at least once during development, right?
- floitsch 5y agoTo me those two sound quite different. Here is, how we pronounce it: https://www.youtube.com/watch?v=JVKb8cm1B20 https://www.youtube.com/watch?v=JVKb8cm1B20
- drewm1980 5y agoEnglish spelling is a mess... spelling it as "Toyt" would avoid the ambiguity. Or if the "IT" is from "Internet of things"... you could go with "Adroit"... That's a real word and thus has a memorized pronunciation in English, even though ~that's in turn a "mispronounced" French word. Sorry for bikeshedding! I love new programming languages, but even ~I'm going to be distracted if it's named after a female body part. For fun: George Carlin: https://youtu.be/6ulTgP6fjfA?t=598 https://youtu.be/6ulTgP6fjfA?t=598
- tokai 5y agoIts tɔɪt versus twŏt. Definetly not the same. Your bikeshedding is way over the line. It is just as much the french word for roof or a slangy spelling of tight. Don't make it their problem that you have an (weird) association.
- handrous 5y agoI spent about a minute wondering why someone made yet another software project that I can't talk about with non-nerds (or in mixed company at all, or with people I don't know very, very well and do not work with, et c.), before figuring out other ways to say it (my first alternative guess was as in "a round tuit" = "to it", though note the spelling there...) Blame French classes, I guess. And I'm American! I bet if I passed this around on my non-nerd chat friend groups at least half would guess the vulgar-sounding version first.
- akavel 5y agoKnowing Lua, what advantages would I see if I tried using Toit instead? what disadvantages? how about eLua in particular? how about OpenResty with LuaJIT maybe? (I'm asking honestly to try to understand, including which level of "IoT" it's trying to target, which I still am lost at, even after trying to browse to toit.io - which only added to my confusion suddenly seeing "containers" and ESP32 mixed in the same sentence there.) How about vs. ye olde Java VM running on your SIM-card? (!)
- antattack 5y agoI notice that one of the differences is licensing. "The Toit compiler, the virtual machine, and all the supporting infrastructure is licensed under the LGPL-2.1 license." Lua - MIT license eLua - MIT license OpenResty - BSD style licenses Could LGPL license limit it's growth and popularity?
- deknos 5y ago> Could LGPL license limit it's growth and popularity? No.
- colejohnson66 5y agoMaybe. Some developers have an aversion to the GPL family because of its “viral” nature. An MIT licensed project can be used in an LGPL one, but not the other way around. However, many projects are successful despite being GPL licensed. The Linux kernel is a major one, and Marlin FW (for 3D printers) has had its license used a few time to force Chinese 3D printer makers to release their source. There’s a lot of misconceptions and FUD about the GPL family. So, as a clarifier: The LGPL does not restrict what the user can do with a product;[a] it only limits other developer’s. If another program wants to integrate Toit (or any LGPL based thing) into their product, they need to abide by the LGPL’s linking and open source[b] provisions. But a user can use an LGPL or GPL licensed product without restriction. [a]: Despite what some developers may claim [b]: It’s more “source available” but for the users only. Open source is just one way to fulfill that requirement
- 5y ago
- syrusakbary 5y agoThis is awesome, congrats on the work. Is the Toit language compilable to WebAssembly? I think it could be a great win for usage across different ecosystems!
- floitsch 5y agoI believe I once managed to make Toit run in web-assembly. I know for sure that the compiler compiled to it, but I'm pretty sure I also had a "hello world" that worked. I would need to find that branch and see if it still merges cleanly.
- syrusakbary 5y agoThat would be great, thanks! I think if Toit can jump into the Wasm train it could help the language even further (executing cleanly programs in the browser as well!)
- pansa2 5y agoYou were able to compile Toit code direct to WASM? I guess that required using static types throughout? Or did you compile the VM to WASM instead, and interpret the Toit code as normal?
- floitsch 5y agoI compiled the VM to WASM and ran the bytecode in it.
- intricatedetail 5y agoIt is a language and a platform for Chinese ESP32. I wish it was in the article header. That would have saved me from reading the article.
- floitsch 5y agoThe Toit language isn't bound to run on ESP32s. We routinely run it on our desktops as well.
- pansa2 5y agoIs it possible to compile the code at https://github.com/toitlang/toit https://github.com/toitlang/toit to run on a desktop? Are there instructions on how to make such a build?
- FpUser 5y agoI am pretty sure whatever you used to type this message in has a lot of Chinese parts.
- oulipo 5y agoCan the language compile to WASM?
- IshKebab 5y agoLooks like it isn't statically typed and doesn't even support type hints. That seems like a fairly bit mistake to me and I'm surprised to see it from the authors of Dart who went through the whole Dart 1/2 "optional type hints" to "hmm it turns out static types are actually fairly critical". Surely better to design the language with static types than to have to awkwardly tack them on later if it gets popular? Documentation looks excellent though! Especially the language comparison.
- floitsch 5y agoToit is optionally typed, and supports type annotations. Type annotations for locals, fields, and globals are written with a trailing `/Type`. Return types are written with `-> ReturnType`. See https://github.com/toitware/toit-lsm303dlhc/blob/main/src/accelerometer.toit https://github.com/toitware/toit-lsm303dlhc/blob/main/src/ac... for a file I recently edited. When a type annotation is written, the compiler enforces it. It uses it for static optimizations, and dynamically checks that the type is correct. When a type can be null, it has to be suffixed by `?`.
- pansa2 5y ago> dynamically checks that the type is correct How thorough is this? Beartype is also on the front page right now, and its README contains an example of dynamic type checking in Python that takes over an hour to run [0]. Is Toit able to avoid being that slow? [0] https://github.com/beartype/beartype#why-should-i-use-beartype https://github.com/beartype/beartype#why-should-i-use-bearty...
- floitsch 5y agoToit doesn't have generic types yet. This limitation means that the dynamic checks are very fast. Since these checks also allow some optimizations, the cost of the dynamic checks is maybe 10-15%. And that's before doing a global type-inference, which should remove many of the checks.
- IshKebab 5y ago
- nikitaga 5y agoProgramming for Arduino in C/C++ has been the worst most unproductive endeavor I ever undertook as a software developer. I have no idea how people write whole browsers and operating systems in this language. Rewrote everything in CircuitPython after 1500 loc of cpp madness, and living happily thereafter. I had to switch to a more powerful board though, it would be great to have lower requirements. Adafruit's M0 adalogger board has been perfect for me in every way except it does not have enough flash for CircuitPython. Toit looks funky, but nice. They seem to already have a decent start at the ecosystem, with very basic libraries like drivers for HD44780 already made. Doesn't have everything that I need yet, but looks very promising. I'm working on a flight controller, not IoT, so I don't need their serviceability API, but that's an interesting way to monetize. If I needed that, I can definitely see it being cheaper to pay the fee than to develop stuff like a reliable OTA update system myself.
- PMunch 5y agoAgreed, C/C++ can sometimes be a real pain to work with. I went a slightly different route however after seeing how much less I could do with an equally powerful board running MicroPython and settled on Nim. It has a syntax that looks familiar to Python, but it's compiled through C/C++ so every board I could run C/C++ on I could run Nim on. It also meant I didn't have to rewrite all the libraries. Recently I've been digging into creating a pure Nim ecosystem for microcontrollers after discovering just how much overhead Arduino and other generic C approaches are. The benefit Nim has here is that it is incredibly strong at compile-time execution. This means that I can write succinct Python-looking code which compiles to tiny binaries with great performance. My biggest project in it so far is a keyboard firmware for a keyboard split in half. The whole project compiles down to about 4Kb with all the code for the port expanders and the layouts and special key macros I use. For comparison the Arduino code to blink an LED over one such port expander was about 3.8Kb and MicroPython can't even compile a hello world for the board I'm using.
- nyanpasu64 5y agoI wonder if Nim is better or worse suited for low-powered boards than TinyGo. Zig is probably not mature enough and insufficiently safer than C++ to satisfy you and your parent post's requirements though.
- Rochus 5y agoA subset of Python with a flair of Smalltalk?
- pabs3 5y agoAnother Python-esq embedded language is Snek: https://sneklang.org/ https://sneklang.org/
- eggy 5y agoDoes it have distribution and fault tolerance like Nerves on Elixir aside from having an LGPL vs. Apache (Nerves) license? It may be fast, but how does it compare to Nerves for highly-distributed, swarm or fault-tolerant networks using many IoT devices for distributed control and information and gathering?
- e_proxus 5y agoNerves (or Erlang’s VM BEAM) is nowhere near small enough to run on ESP32. I think a comparison is not very useful. If you have an ESP32 you need something like Toit, if you have a Raspberry Pi you might as well run embedded Linux (with Nerves on top).
- eggy 5y agoI agree, but I saw the defense that Toit wasn't just for ESP32. I have been playing with ESP chips since first tinkering with them over 8 years ago. C is fine when you're that small, Lua or even ulisp [1], forth, etc. Why Toit? Bowery Farming uses Elixir Nerves for their network of small interconnected devices to run their vertical, indoor farming operations, and I think others are looking to shrink it. [1] http://www.ulisp.com/ http://www.ulisp.com/
- ossusermivami 5y agoI am not sure the end sentence "let the game begin" entitle me to check this out
- losvedir 5y agoInteresting YAML-esque syntax. I've always liked the idea of automatic variables, since seeing them in the array languages like J or K. I half wonder if the team felt any pressure to release the language now, ahead of Advent of Code...
- shrubble 5y agoCan I run my own server and avoid the fees for updating devices?
- r283492 5y agoUnpublished CLA is a no go. I assume the CLA says you can distribute my code under a proprietary license. Nope, nope, nope. Fix that, then I'll take a look.
- sergiotapia 5y agoToit like a toiger!
- petecooper 5y agohttps://www.youtube.com/watch?v=gu31VyXlTzo https://www.youtube.com/watch?v=gu31VyXlTzo (I will admit I thought the same thing, pleased to see it wasn't just me.)
- kodeninja 5y agoIs Lars Bak no longer involved with Toit? https://toit.io/company/about https://toit.io/company/about
- mjul 5y agoHe is still a minority shareholder according to the Danish Central Business Register: https://datacvr.virk.dk/data/index.php?enhedstype=virksomhed&id=38984594&language=en-gb&soeg=Toitware&sortering=default&type=Alle&q=visenhed https://datacvr.virk.dk/data/index.php?enhedstype=virksomhed...
- dang 5y agoOne previous related thread: The Toit Programming Language - https://news.ycombinator.com/item?id=26365202 https://news.ycombinator.com/item?id=26365202 - March 2021 (18 comments)
- tekknolagi 5y agoIt's always fun seeing VMs written in the SmallTalk/V8/Dart/... lineage because the implementations use similar structure, style, and naming. It's a pleasure to read.
- brundolf 5y agoCan you elaborate on what you mean?
- tekknolagi 5y agoCheck out, for example, Dart's VM. Or https://github.com/facebookexperimental/skybison https://github.com/facebookexperimental/skybison Look at objects.h for example. Or the interpreters
- discreteevent 5y agoI also found it immediately a pleasure to read so I was going to attempt to answer your question. However, I think "pleasure to read" in a language is very subjective and hard to break down.