Home | Reviews | GUIpedia | Forum | Fun500
pharoah | GUIs with scripting languagesLately I'm interested in playing around with different scripting languages people have written and writing code in them. The only one I know of that's somewhat in development is Brandon Cornell's F5S script, but I'm getting frustrated with that because it lacks complex data types (lists, arrays, etc...). Anyway I'm interested to see what else is out there, so if your GUI has a working scripting language that I can play with post here. | 2009-03-07 | 10:24 AM |
Todd | Re:GUIs with scripting languagesMost people who try to make scripting languages use the harder ways of trying to have it interpret the code but there's a simple way to do it: read one character at a time. So if you have code like this, [code] a = mid(b, 5, 20) [/code] The interpreter would act something like this if programmed correctly: [code] (buf = ) a (buf = a) a = (var = a, buf = =) a = m (var = a, op = =, buf = m) a = mi (var = a, op = =, buf = mi) a = mid (var = a, op = =, buf = mid) a = mid( (var = a, op = =, func = mid, buf = () a = mid(b (var = a, op = =, func = mid, buf = b) a = mid(b, (var = a, op = =, func = mid, param1 = b, buf = ) a = mid(b, 5 (var = a, op = =, func = mid, param1 = b, buf = 5) a = mid(b, 5, (var = a, op = =, func = mid, param1 = b, param2 = 5, buf = ) a = mid(b, 5, 2 (var = a, op = =, func = mid, param1 = b, param2 = 5, buf = 2) a = mid(b, 5, 20 (var = a, op = =, func = mid, param1 = b, param2 = 5, buf = 20) a = mid(b, 5, 20) (var = a, op = =, func = mid, param1 = b, param2 = 5, param3 = 20, buf = ) [/code] | 2009-03-07 | 11:51 AM |
aguma | Re:GUIs with scripting languagesbut isn't that a little bit hard to do, and also a bit slow? | 2009-03-07 | 12:06 PM |
Todd | Re:GUIs with scripting languagesIt's slow if it isn't first compiled into some sort of byte-code. Because byte-code just tells the interpreter directly what to do instead of having to interpret the code all over again. Object code does the same except on a machine level to the CPU directly. | 2009-03-07 | 12:36 PM |
pharoah | Re:GUIs with scripting languagesYeah I tend to like the bytecode approach. Although a stack based language is also pretty easy to parse. Consider that [code]a = mid(b, 5, 20)[/code] might be written as [code] b fetch 5 20 mid a store [/code] where a and b are words that push a pointer to the variable on the stack. Since each word stands on its own, there is no syntax to worry about at all. By contrast, if you want to get infix operators like + - * / to work the way people expect, you have to implement the shunting yard algorithm. | 2009-03-07 | 2:37 PM |
Todd | Re:GUIs with scripting languagesYeah I am going to try to create a visual scripting engine based off of a stack engine. It seems more efficient than keeping a whole lot of code stored into memory. Instead of storing code, you store nodes instead. That's how I've seen most scripting languages developed. | 2009-03-07 | 5:37 PM |
pharoah | Re:GUIs with scripting languagesAnyway the purpose of this thread was actually to see what existing GUIs have scripting langauges. I want to try to code an office suite or something for different GUIS (expanding the influence of the great name of Atlas Software :)). | 2009-03-07 | 5:50 PM |
Brandon | Re:GUIs with scripting languagesWill you develop for NON-multi-scripting GUIs? | 2009-03-07 | 6:05 PM |
pharoah | Re:GUIs with scripting languagesIf the GUI works reliably I'd probably be willing to. | 2009-03-07 | 6:18 PM |
pharoah | Re:GUIs with scripting languagesWithout a doubt the easiest scripting language to implement would be BrainFuck. It has only 8 instructions and is turing complete, but runs fairly slowly. Tonight I whipped up 2 BF interpreters. The first one (which I call MiniFuck), counts back from the loop instruction ] to the do [ instruction and so runs somewhat more slowly, but doesn't require a stack. [code] dim mem(30000) as ubyte dim as string code, y dim as integer x, position, mempos open "lostking.b" for input as #1 while not eof(1) line input #1, y code = code + y wend close 1 position = 1 while position 0 then x = 1 do position = position - 1 select case mid(code, position, 1) case "]" x = x + 1 case "[" x = x - 1 end select if x = 0 then exit do loop end if end select position = position + 1 wend [/code] The second interpreter I've written (XtendedFuck (yes I'm enjoying naming these)) uses a call stack making loops and backward jumps much faster. [code] dim mem(30000) as ubyte redim stack(1 to 1) as integer dim as string code, y dim as integer x, position, mempos open "lostking.b" for input as #1 while not eof(1) line input #1, y code = code + y wend close 1 position = 1 while position 0 then position = stack(ubound(stack)) else redim preserve stack(1 to ubound(stack)-1) end if end select position = position + 1 wend [/code] Unfortunately I've found both of these run very slowly compared to Beef, a BF interpreter you can find in the Ubuntu repositories. One thing that's cool is that there are a few fairly involved programs written in BF, including a text adventure game called The Lost Kingdom. After writing fewer than 60 lines of FB code, I can use my interpreter to run a full length game. Kind of cool :). EDIT: I can't figure out why this post is displaying so strangely. Any help? | 2009-03-07 | 11:21 PM |
Todd | Re:GUIs with scripting languagesI'm not a big fan of Brainf*ck. Ever hear of Befunge? | 2009-03-07 | 11:39 PM |
pharoah | Re:GUIs with scripting languagesYes. The reason I like BF is that it's not intentionally obfuscated, just minimal (If you look at the instructions, they're actually sensibly named). Befunge has that insane wandering pointer that seems like it'd be difficult to both interpret and code. | 2009-03-07 | 11:56 PM |
Todd | Re:GUIs with scripting languagesBF is very simple (just one stack). lol I mean I prefer something object-oriented or at least with structure-like objects. | 2009-03-08 | 10:14 AM |
pharoah | Re:GUIs with scripting languagesActually there's no stack at all. It's more of a heap :). I wish it had procedures, mayb some constants or something. Still it's a proof of concept. | 2009-03-08 | 11:48 AM |
2021 Brandon Cornell