I have an mbed microcontroller which has a small ARM Cortex M3 on it. Basically, my effective resources for the project are ~25 KB of RAM and ~400 KB of Flash. For I/O I'll have a PS/2 keyboard, a VGA framebuffer (with character output), and an SD card for saving/loading programs (up to a couple of MB maybe).

I ask because I'm trying to figure out what programming language to implement on the thing. I'm looking for an interpreted language that's easy for me to implement and won't break the bank on my resources. I also intend for this to be at least possible to write on the device itself, though the editor can be interpreted (yay, bootstrapping).

Anyway, I've looked at a few simple languages. Some nice candidates:

Has anyone done something like this or know of any languages that can fit this bill or have comments about my three candidates so far?

closed as off-topic by Thomas Owens Mar 24 '14 at 18:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – Thomas Owens
If this question can be reworded to fit the rules in the help center, please edit the question.

  • If your scale is too small to fit LUA, you may just be stuck with C, and your own implementation of a language in it. If you can get scheme to fit then it's a great candidate for writing your own simple scripting language in. – Jimmy Hoffa Sep 18 '12 at 3:52
  • @JimmyHoffa you're saying I should implement scheme on my device and then from there implement a scripting language in scheme? double interpretation? lol – Earlz Sep 18 '12 at 4:04
  • No, I'm referring to writing an interpreter in scheme, then compiling that interpreter to native. Though I'm sure there are better compilers for scheme than this, but here's the first google pop for compiled scheme: matt.might.net/articles/compiling-scheme-to-c – Jimmy Hoffa Sep 18 '12 at 4:07
  • I'd like to add that the eLua project also has a port to ARM M3, I think it will be useful to you. – Machado Sep 18 '12 at 15:16
  • There are several Tiny Basic interpreters (some written in C), where the total memory footprint can be as little as 16kB (even less for the ones written in ASM). – hotpaw2 Jul 8 '16 at 2:28

For what you have described, FORTH is probably ideal. FORTH routinely runs on much smaller platforms than yours. (16K total is a big machine for FORTH.) There is going to be some serious learning curve involved, if you've never looked at FORTH before.

There's a Scheme implementation called TinyScheme (as I recall), that might be worth a look. I first heard about it from a piece on Slashdot, about a guy who used it as the core of his malware engine. (Yeah, that's right: His job was writing malware, for something or other, and doing it in TinyScheme meant their payload could be a lot smaller.)

  • I looked at TinyScheme. I think it would work, but I don't know Scheme at all.. So, I figured Forth would be easier to wrap my head around(which it is). I wouldn't consider Forth to have an absolutely huge learning curve, I've worked with stack machines before though, so that's probably why it comes fairly natural to me heh. Forth is excellent for this though because it's trivial to extend later to do a crude form of JIT and such... and implementation consists of a stack, a dictionary, and a few built in words – Earlz Sep 19 '12 at 14:35
  • So, in summary. I ended up going with writing my own (non-compliant) Forth interpreter. – Earlz Sep 19 '12 at 14:36
  • Leo Brodie's classic "Starting FORTH" is by far the best introduction to FORTH I have ever found, even if it does describe a very old version of the language and environment (16-bit polyFORTH, from FORTH Inc.). If you can find a copy, Loeliger's "Threaded Interpretive Languages" does a very good job of explaining how to implement FORTH on a Zilog Z80 microprocessor. – John R. Strohm Sep 19 '12 at 15:01

I'm going to make the case that Lua is by far your best bet. You can compile Lua anywhere that C can run and it's one of the lightest scripting languages out there. It's massively flexible as a language and the skills are quite transferable as well. There's even a specifically embedded version of Lua.

Addendum: It is apparently possible to get the memory footprint down to just over 25K.

Addendum 2 - Things get nutty: There is an option brought up by this SO question. Squirrel is a language that I've heard of but never used. It's apparently even smaller than Lua due to use of reference counting.

  • There is eLua but it's out of my range for resources. Basically 32K of RAM is required for anything useful – Earlz Sep 18 '12 at 1:09
  • 1
    Lua won't ever be able to compete with Forth in footprint. – SK-logic Sep 18 '12 at 8:39
  • NEver said it could. Lua isn't as alien to most programmers though. – World Engineer Sep 18 '12 at 10:36
  • +1 for Lua and eLua. – Machado Sep 18 '12 at 14:48
  • If my processor had a bit more RAM, I'd use eLua, but unfortunately it doesn't, so I'm writing a small Forth compiler – Earlz Sep 21 '12 at 5:21

Regarding embeddable scripting languages, the 2 I'm familiar with are LUA and PAWN .

I think there are versions of Python & other such languages ported to embedded systems, but they tend to be the embedded Linux variety. Depending on your platform (no idea if it's a little MCU with 8K ROM or an embedded PC) that might be an option.


I remember reading some time ago about Tcl/Tk and its use in routers.

Excerpt from the "Embedded Development" paragraph found at http://www.tcl.tk/about/uses.html:

Because Tcl is a very compact language, and is easily integrated with special hardware, it is a popular choice for embedded development. You'll find Tcl hidden away on many devices, including many networking products from Cisco and others, and set-top boxes including Tivo. Embedding Tcl within other software projects is of course also hugely popular, and has become the dominant control language in some industries, such as in electronic design automation (EDA) and computer-aided design (CAD) applications.

Not the answer you're looking for? Browse other questions tagged or ask your own question.