LWN: Comments on "A tiny Python called Snek" https://lwn.net/Articles/810201/ This is a special feed containing comments posted to the individual LWN article titled "A tiny Python called Snek". en-us Thu, 18 Sep 2025 01:15:22 +0000 Thu, 18 Sep 2025 01:15:22 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net A tiny Python called Snek https://lwn.net/Articles/811554/ https://lwn.net/Articles/811554/ zoobab <div class="FormattedComment"> Any plan for STM32 boards? especially the popular and cheap STM32F103? They are ARM Cortex M3, so it should be close to the other ARM boards already supported...<br> </div> Wed, 05 Feb 2020 09:23:10 +0000 A tiny Python called Snek https://lwn.net/Articles/811226/ https://lwn.net/Articles/811226/ simcop2387 <div class="FormattedComment"> It's not generally possible with the default ATMEGA328 processors on arduinos. Porting the code and everything generally works fine and is easy to do but the real problem is the lack of memory on them, only 2KB of RAM. That causes a number of problems for LUA to do anything non-trivial due to the way the VM and everything works. That said I use a cortex m3 + lua to run my christmas lights. You don't need much more ram for it to suddenly be useful, about 4K seems to be the spot in my experience, and the 32kb on the arm processor I use is obviously morebetter.<br> </div> Fri, 31 Jan 2020 20:35:16 +0000 A tiny Python called Snek https://lwn.net/Articles/811106/ https://lwn.net/Articles/811106/ ejr <div class="FormattedComment"> If you use signaling NaNs for other types, you can run through a sequence of arithmetic operations and check if they were actually numbers after the fact. Old technique.<br> </div> Thu, 30 Jan 2020 22:34:03 +0000 A tiny Python called Snek https://lwn.net/Articles/810975/ https://lwn.net/Articles/810975/ Wol <div class="FormattedComment"> Could something like this help... ?<br> <p> <a rel="nofollow" href="https://www.amazon.co.uk/Serial-Adapter-Prolific-Chipset-Windows/dp/B0753HBT12/ref=asc_df_B0753HBT12/?tag=googshopuk-21&amp;linkCode=df0&amp;hvadid=309968313994&amp;hvpos=&amp;hvnetw=g&amp;hvrand=7916766039746234830&amp;hvpone=&amp;hvptwo=&amp;hvqmt=&amp;hvdev=c&amp;hvdvcmdl=&amp;hvlocint=&amp;hvlocphy=9044990&amp;hvtargid=pla-397003917010&amp;psc=1">https://www.amazon.co.uk/Serial-Adapter-Prolific-Chipset-...</a><br> <p> or this?<br> <p> <a rel="nofollow" href="https://www.perle.com/products/multiport-serial-card.shtml?gclid=Cj0KCQiAmsrxBRDaARIsANyiD1oBRtnH2960pF64qpijLdJVql-Q07qOQOGx1uQfl7Vhc0ZcA5iaPpwaApYjEALw_wcB">https://www.perle.com/products/multiport-serial-card.shtm...</a><br> <p> Cheers,<br> Wol<br> </div> Thu, 30 Jan 2020 11:30:28 +0000 A tiny Python called Snek https://lwn.net/Articles/810477/ https://lwn.net/Articles/810477/ keithp <div class="FormattedComment"> Sure! I've already used the esp8266 toolchain packaged in Debian as I tested the Picolibc port done by Jonathan McDowell.<br> </div> Fri, 24 Jan 2020 18:36:00 +0000 A tiny Python called Snek https://lwn.net/Articles/810451/ https://lwn.net/Articles/810451/ SEJeff <div class="FormattedComment"> If a little hardware fairy were to gift you an adafruit huzzah esp8266, would you consider porting to it?<br> </div> Fri, 24 Jan 2020 14:38:31 +0000 A tiny Python called Snek https://lwn.net/Articles/810430/ https://lwn.net/Articles/810430/ keithp <div class="FormattedComment"> There's lots of potentially interesting languages to teach new programmers, but our program focuses on building robots (with Lego components!), which means having hardware to connect the computer with motors and sensors. Finding hardware that can do that turns out to be non-trivial.<br> <p> When the old Macintosh machines stop working, the interface hardware will no longer have anything to connect to. Those use a proprietary serial protocol hooked up to the original Macintosh serial ports. Maybe those interfaces could be connected to a modern machine?<br> <p> For Snek, I had hoped to use existing Arduino-compatible hardware, but couldn't find any integrated boards capable of driving 9V motors and servos. So I ended up building my own, which has resulted in a Crowd Supply campaign... Somehow this feels a lot like yak shaving.<br> </div> Fri, 24 Jan 2020 06:06:59 +0000 A tiny Python called Snek https://lwn.net/Articles/810429/ https://lwn.net/Articles/810429/ keithp <p> Yeah, the ESP32 isn't exactly tiny. But, it's something I had lying around, so naturally I ported Snek to it. Somehow, I tend to collect tiny microcontroller boards. They're like coat hangers around here. </p> <p> MicroPython uses a couple hundred kB of ROM; which is amazingly small considering how much Python that includes. Snek is a much less capable language, but it can squeeze down to about 32kB of ROM if you leave out the math functions. </p> <p> Snek currently has ports for: </p> <ul> <li>Adafruit Crickit FeatherWing (Atmel SAMD21)</li> <li>Arduino Duemilanove (Atmel ATmega 328P)</li> <li>ESP32</li> <li>Adafruit Feather M0 Express (Atmel SAMD32)</li> <li>SiFive HiFive1 Revb (RISC-V)</li> <li>Adafruit ItsyBitsy (Atmel ATmega 32u4)</li> <li>Arduino Mega (Atmel ATmega 2560)</li> <li>Adafruit Metro M0 (Atmel SAMD21)</li> <li>Arduino Nano 33 IoT (Atmel SAMD21)</li> <li>Adafruit Circuit Playground Express (Atmel SAMD21)</li> <li>POSIX (for testing and debugging)</li> <li>QEMU for ARM (Cortex M3)</li> <li>QEMU for RISC-V (rv32imac)</li> <li>Arduino µduino from Crowd Supply (Atmel ATmega 32u4)</li> </ul> <p> These range from 32kB of ROM and 2kB of RAM all the way up to several hundred kB of ROM and a bunch of RAM. </p> Fri, 24 Jan 2020 05:56:26 +0000 Lost his magic Smoke... https://lwn.net/Articles/810425/ https://lwn.net/Articles/810425/ rahvin <div class="FormattedComment"> Even with the wonders of modern tech and the durability of old tech, Magic Smoke strikes again! I've heard those old Apple II's have a pretty limited amount of magic smoke. <br> </div> Fri, 24 Jan 2020 00:58:20 +0000 A tiny Python called Snek https://lwn.net/Articles/810419/ https://lwn.net/Articles/810419/ SEJeff <div class="FormattedComment"> I find it interesting that this is supposed to be smaller than micropython and works on the esp32, but not the smaller esp8266, which micropython works on.<br> </div> Thu, 23 Jan 2020 22:58:49 +0000 A tiny Python called Snek https://lwn.net/Articles/810415/ https://lwn.net/Articles/810415/ ceplm <div class="FormattedComment"> <font class="QuotedText">&gt; When the OS 9 Macs needed to run Logo are no longer available, we'll need to find something new...</font><br> <p> What’s wrong with UCB Logo? <a href="https://en.wikipedia.org/wiki/Logo_">https://en.wikipedia.org/wiki/Logo_</a>(programming_language)<br> </div> Thu, 23 Jan 2020 21:13:46 +0000 A tiny Python called Snek https://lwn.net/Articles/810411/ https://lwn.net/Articles/810411/ keithp <div class="FormattedComment"> The main goal of the Snek project was to build a small, easy to teach language that would be useful later on. To me, that meant doing something based on Python.<br> <p> My daughter took an introductory programming class as part of her geology degree. The class used Python, but most of the time was spent learning things also in Snek. Most of the examples and classwork would run (unchanged) using Snek instead of Python.<br> <p> A tiny Lua for Arduino-scale machines could be a fun project though. Our robotics program teaches students three languages (Snek, Logo and ROBOLAB) and lets them choose which language to use for further work. When the OS 9 Macs needed to run Logo are no longer available, we'll need to find something new...<br> <p> </div> Thu, 23 Jan 2020 20:53:43 +0000 A tiny Python called Snek https://lwn.net/Articles/810341/ https://lwn.net/Articles/810341/ dgm <div class="FormattedComment"> I'm not sure if Lua (or eLua) could be made to run on the target platform without reimplementing the interpreter.<br> </div> Thu, 23 Jan 2020 12:10:09 +0000 A tiny Python called Snek https://lwn.net/Articles/810339/ https://lwn.net/Articles/810339/ ceplm <div class="FormattedComment"> Hasn’t he just reinvented Lua? I mean for the small embedded hardware, that should be it, shoudln't it?<br> </div> Thu, 23 Jan 2020 11:20:48 +0000 A tiny Python called Snek https://lwn.net/Articles/810325/ https://lwn.net/Articles/810325/ keithp <div class="FormattedComment"> Thanks for the explanation; I was unaware of the call to serialEventRun. Useful bits!<br> <p> From a teaching perspective, I did have to explain the overall structure (setup called once, loop called again and again), but your comment about avoiding the need to teach for(;;) or while(1) resonates with my experience. It's faster to explain in words what the system does than get students to type the loop syntax in by hand.<br> </div> Wed, 22 Jan 2020 22:59:33 +0000 A tiny Python called Snek https://lwn.net/Articles/810324/ https://lwn.net/Articles/810324/ Cyberax <div class="FormattedComment"> It also saves a level of indentation, making code a bit more readable.<br> </div> Wed, 22 Jan 2020 22:08:28 +0000 A tiny Python called Snek https://lwn.net/Articles/810323/ https://lwn.net/Articles/810323/ vadim Finding out why Arduino uses two functions (setup() and loop()) is easy, just look in the code. You'll find this in main: <pre> setup(); for (;;) { loop(); if (serialEventRun) serialEventRun(); } </pre> <p> So, I take it that this situation has 4 reasons for existing: </p> <ol> <li>It saves the need to know how to make a loop. This is useful because near any Arduino program will need to loop, so that's one thing less to figure out before getting something that works.</li> <li>It avoids the rather obtuse syntaxes of "for(;;)" or "while(1)", which a new student won't yet understand, and would need additional explanation.</li> <li>It avoids the need for the user to call serialEventRun(), which is even more obscure to newbies, not to speak of the 'if' bit.</li> <li>It allows for more processing behind the scenes to be inserted if needed, without requiring existing code to be modified.</li> </ol> <p> So I would say on the balance it's a good thing. It allows getting down to business as quickly as possible, and does its best to avoid the student having to write arcane incantations that they don't understand the purpose of, and which they could screw up.</p> Wed, 22 Jan 2020 21:49:01 +0000