views:

941

answers:

10

I am looking for general purpose programming languages that

  • have an interactive (live coding) prompt
  • work in 32 KB of RAM by itself or 8 KB when the compiler is hosted on a separate machine
  • run on a microcontroller with as little as 8-32 KB RAM total (without an MMU).

Below is my list so far, what am I missing?

  • Python: The PyMite VM needs 64K flash, 8K RAM. Targets LPC, SAM7 and ATmegas with 8K or more. Hosted.
  • Lua: The eLua FAQ recommends 256K flash, 64K RAM.
  • FORTH: amforth needs 8K flash, 150 bytes RAM, 30 bytes EEPROM on an ATmega.
  • Scheme: armpit Scheme The smallest target is the LPC2103 with 32K Flash, 4K SRAM.
  • C: Interactive C runs on 68HC11 with no flash and 32K SRAM. Hosted.
  • C: picoc an open source, cross-compiling, interactive C system. When compiled for AVR, it takes 63K flash, 8K RAM. The RAM could be reduced with effort to keep tables in flash.
  • Tcl: TinyTCL runs on DOS, 60K binary. Looks easy to port.
  • BASIC: TinyBasic: Initializes with a 64K heap, might be adjustable.
  • Lisp
  • PostScript: (I haven't found a FOSS implementation for low memory yet)
  • Shell: bitlash: An interactive command shell for Arduino (ATmega). See also AVRSH.
A: 

Have you considered simply using the /bin/sh supplied by busybox? Or on of the smaller scripting languages they recommend?

dmckee
I'm looking for languages that run on microcontrollers with no MMU and have such small RAM (8K-32K) that an OS is unreasonable. I will edit the question to make this more clear.
dwhall
ucLinux doesn't have an MMU and runs on microcontrollers. It uses busybox.
DoxaLogos
@DoxaLogos: Thanks for coming to my defense and all, but I don't think that ucLinix will run in this small a memory footprint. (I didn't read at first. Leaving the answer because it might be useful to someone else coming by.) ANyone know how small an OS you can write that will support BB?
dmckee
A: 

I have been using in my previous work busybox on a BlackFin.

we compiled perl + php for it, after changing s/fork/vfork/g it worked pretty good... more or less. Not having an MMU is not a good idea. The memory fragmentation will kill the server pretty easily. All I did was:

for i in `seq 1 100`; do wget http://black-fin-ip/test.php; done

It died while I was walking to my boss and telling him that the server is going to die in production :)

elcuco
This answer is not accepted because Perl and PHP don't run in less than 32 KB of RAM. Having no MMU is a requirement. I'm working on deeply embedded systems; 32 KB is the *total* amount of RAM in the system.
dwhall
+1  A: 

A homebrew Forth runtime can be implemented in very little memory indeed. I know someone who made one on a Cosmac in the 1970s. The core runtime was just 30 bytes.

ConcernedOfTunbridgeWells
FORTH was already listed. This is a comment, not an answer.
dwhall
+3  A: 

There are a number of versions of Tcl for embedded programming:

http://wiki.tcl.tk/1363

ars
Ettcl is too big for the 32 KB limit, but the link you gave has other smaller implementations that come close. Thank you.
dwhall
You're right, my mistake. I edited my answer to remove that link after I realized the same thing.
ars
+2  A: 

I would recommend LUA (or eLUA http://www.eluaproject.net/ ). I've "ported" LUA to a Cortex-M3 a while back. From the top of my head it had a flash size of 60~100KB and needed about 20KB RAM to run. I did strip down to the bare essentials, but depending on your application, that might be enough. There's still room for optimization, especially about RAM requirements, but I doubt you can run it comfortable in 8KB.

Ron
Thanks, but the eLua project was already on my list (see the second bullet in the question).
dwhall
+1  A: 

Have you considered a port in C of Tiny Basic? Or, perhaps rewriting the UCSD Pascal p-machine to your architecture from Z-80?

Seriously, though, JavaScript would make a good embedded scripting language, but I've no clue what the minimum memory requirements are for the VM + GC, nor how difficult to remove OS dependencies. I played with NJS a while back, which could possibly fit your needs. This one is interesting in that the compiler is written in JavaScript (self hosting).

James Hugard
A: 

Prolog - http://www.gprolog.org/

According to a google search "prolog small" the size of the executable can be made quite small by avoiding linking the built-in predicates.

Larry Watanabe
+3  A: 

I hear that CHIP-8, XPL0, PicoC, and Objective Caml have been ported to graphing calculators. The Wikipedia "Lego Mindstorms" article lists a bunch of programming languages that allegedly run on the Lego RCX or Lego NXT platform. Do any of them meet your "live coding" criteria?

You might want to check out the other microcontroller Forths at the Forth wiki . It lists at least 4 Forths for the Atmel AVR: amforth (which you already mention), PFAVR, avrforth, and ByteForth.
(Links to those interpreters, as well as this StackOverflow question, are included in the "Embedded Systems" wikibook).

David Cary
A: 

You can take a look at very powerful AvrCo Multitasking Pascal for AVR. You can try it at http://www.e-lab.de. MEGA8/88 version is free. There are tons of drivers and simulator with JTAG debugger and nice live or simulated visualizations of all standard devices (LCDCHAR, LCDGRAPH, 7SEG, 14SEG, LEDDOT, KEYBOARD, RC5, SERVO, STEPPER...).

avra