Snek: A Python-inspired Language for Embedded Devices

Snek is a tiny embeddable language targeting processors with only a few kB of flash and ram. Think of something that would have been running BASIC years ago and you'll have the idea. These processors are too small to run MicroPython.

Snek borrows semantics and syntax from python, but only provides a tiny subset of that large language. The goal is to have Snek programs able to run in a full Python (version 3) implementation so that any knowledge gained in learning Snek will transfer directly to learning Python.

Current Status

Snek version 1.0 has been released.

Releases

I've got Snek packaged for generic Linux, Mac OS X and Windows machines. All three packages include a snek binary for the host operating system to experiment with, binaries for target devices, snekde (the Snek Development Environment) and documentation.

Packages are available in the dist directory here

Debian Packages

Pre-built Debian packages for Debian are available in my personal package archive. Instructions on how to set that up for your machine are available in the README in that directory.

There are two snek packages in the archive:

  • snek. The main 'snek' package includes source code for use in your own embedded environment, a binary for Duemilanove boards, the 'snekde' development environment and documentation.

  • snek-bin. The auxiliary 'snek-bin' package includes a 'snek' application compiled for the host machine, which can be useful to experiment with language features and functions that do not require access to the target hardware.

Snek and Lego

Snek and Lego make a great combination. Read about how to use them together here

Documentation

The Snek Manual includes a tutorial and full reference manual. HTML and PDF versions are available here:

I started documenting snek in my blog, here is a link to all snek-related blog posts.

There is also a Snek mailing list, which you are encouraged to subscribe to

Source Code

You can find Snek in either my git repository or github

Snek is licensed under the GPLv3 (or later)

Snek in NuttX

NuttX is a moderate-sized embedded RTOS that works on a variety of small systems. I've written the necessary glue-code and build instructions to make Snek available there. All of that code is licensed under the standard NuttX/BSD license, but because NuttX upstream is not willing to take code that references GPL code, I've created a fork of the NuttX app tree in my git repository..

NuttX has a good mechanism for adding code of this sort; there are no changes to existing NuttX files, just a new directory in app/interpreters/snek. When present, all of the necessary options become visible in the regular NuttX configuration tool.

This port doesn't interface to much of NuttX yet, it would be fun to see some experimentation here.