• 0

Looking for a scriping language with a tiny footprint


Question

Hey guys. I'm currently looking for a scripting language with a tiny footprint (less than 3KB RAM and a binary that when compiled is less than 20/30KB).

All I need is the ability to evaluate statements similar to first order logic.

For example: !(x : X | x > 5)

Would mean that "for all x in the set X, return true if all xs are greater than 5, otherwise return false".

I need the ability to define functions that would return these sets (The ability to define X and pass parameters to that function that returns a set).

It would also need to be able to support a limited form of structures, where an attribute could be obtained on a certain variable (eg. x.count).

As for data types, integer, floating point and sets are about all I need. Anything else would probably be ripped out to save space.

It needs to be written in C and the ability to compile on old versions of GCC (3.4.x) would also be useful.

Anyone got any ideas? Ideally I don't want to have to write this myself.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Your requirements are quite strict and I'm not sure that this suggestion meets them completely, but it sounds like you are describing close to the ideal use case for bc, the arbitrary precision calculator language. You can download the source code for the latest version from the GNU Project Archives and read the man page on die.net.

Edit: Although BusyBox does not include bc, you could probably accomplish what you are looking for using the combination of sh, awk, and grep it includes, albeit much less elegantly. BusyBox also gives you the option of selecting features at compile time, so you could choose not to include features you don't need.

Link to comment
Share on other sites

  • 0

I'm using this on an embedded system, so it lacks anything like sh, awk or grep. There isn't really an OS... my code gets compiled when the OS code gets compiled.

This also means that there is no notion of running different executables, so no ability to run sh, awk or grep. (At least the platform gives support for proto-processes, or pseudo-processes or whatever it calls them)

Thanks for bc, I'll have a look into it.

Its a shame that if I do have to write it myself, I can't even use bison or flex because of code size issues.

Link to comment
Share on other sites

  • 0

If this is for a proprietary system where you can't use GPL'd code, you can try the FreeBSD implementation of bc instead of the GNU version I linked to in my last post. Its less featureful than the GNU version, but that may not matter, depending on how much of the functionality you actually need. (And, most importantly, its BSD licensed.)

PS: I feel your frusturation with limited ROM space for embedded development. I have hit the limit on the PIC18F242 and ATMEGA328P many times.

Link to comment
Share on other sites

  • 0

GPL code is perfectly fine for me, its all for academia so there shouldn't be an issue.

Anyway it looks like our team is just going to implement a small language. We've already got a small vm working, just need to finish the lexing, parsing and compiling.

Link to comment
Share on other sites

This topic is now closed to further replies.