Script Languages: What are the basics?

Started by
5 comments, last by noNchaoTic 18 years, 8 months ago
I'm going to code a robot friendly script language, that is not designed for speed or great flexibility, but for sheer compiled size. In other words, I want the compiled programs to be small. I wanted to know how much you can reduce a language to it's basic constituints, before it becomes inpractical. I know we all need our if-then-elses, our gotos, etc... Where can I find info online regarding this subject? [ Visit My Journal ]
Advertisement
Assuming your robot runs it's own bytecode, then the more bytecodes you have the smaller your code can be. For example; you could implement an if else with jmp and cmp, in several instructions, or with a more specific single instruction.
http://www.muppetlabs.com/~breadbox/bf/
???
Quote:Original post by Anonymous Poster
http://www.muppetlabs.com/~breadbox/bf/
???
BF code has few instructions, but it isn't by any means small. At the very least, if you use BF, you should probably allow some kind of run-length encoding, such as having bit patterns 0000-0111 be the various instructions, and 1000-1111 be a instruction + repetition pair (4 bit instruction, 4 bit repetition count for counts of 0000=2 to 1111=17). Even then, I'm not sure it's optimal compared to more traditional instruction sets (especially if you make speed or flexibility secondary considerations instead of just forgetting them).
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Look into Forth, most implementations generate code smaller than Assembly. You can check out pbForth, an implementaion for Lego robots: http://www.hempeldesigngroup.com/lego/pbForth/homePage.html
if your interested in writing your own, then Alex Varenese's "Game Scripting Mastery" is an excellent introduction to the topic of both high-level and low-level compiler/assembler theory, as well as virtual machine design and implementation. That comes highly recommended from me for what thats worth :-) The obvious choices for "drag and drop" scripting languages that can be inserted into your existing project are probrably tcl, Python or Lua.
Steven ToveySPUify | Twitter
The best strategy seems to be to design an assembly sort of language that you can convert into byte code (via an assembler), and then write a high-level language compiler (optional) that can compile from high level constructs down to your low-level assembly language. This way you can get the option to write in high or low-level scripting language, and also if your not getting the speed you want from your compiler, you can always do it by hand :-) You can write out a byte per operation more than likely (you wont need more than 255?), with space for a few operands per operation which can be variable by writing out another byte. With regard to online reading, you can get e-books of the dragon book, which goes into compiler design, hash tables, etc. All the good stuff you'll definately need, but that book I mentioned is definately worth getting out the library or buying.
Steven ToveySPUify | Twitter

This topic is closed to new replies.

Advertisement