What do you think of my scripting language?
I'm developing an interpreted programming/scripting language for doing AI and other things. My goal is to have a simple language where I (or other people) can develop tools (like level editors) or do scripting for games.
I'm working on the documentation for this language, which I call "Anaphase". Here's the link:
www.gameboxsoftware.com/files/Anaphase.zip
Do you think the language is too primitive? I want to maximize development time b using it, so I want it to be simple and have things like garbage collection. It's like a combination of C++ and C# but stripped down a lot.
And I know what you're thinking: Steph, this is WAY complex. Dude, it'll take you forever to make this! Well I've already made an IDE for it, and I have a few ideas for the compiler (the source code is converted to bytecode, which is faster to interpret).
The way i see it, if Python is really successful, maybe I could do something similar and simpler (but this is mostly for me). I guess it could be a great learning/teaching tool too.
Oh, and here's the IDE I've been working on. Please note that it doesn't compile yet...obviously. Do you think the direction I'm heading with this is good?
www.gameboxsoftware.com/files/Anaphase IDE.zip
The repeat keyword is nifty. Other than that, it looks like C# on sleep pills. What use cases were you aiming at when you designed it?
Quote:Original post by ouraqt
And I know what you're thinking: Steph, this is WAY complex. Dude, it'll take you forever to make this!
I think it's quite all right. I've written compiler for a language of similar complexity, and it's taken me about 2 months. If you have a bit of knowledge of how C++ code is compiled, then you'll have no huge problems with all this.
As for your design document, I understand that it is pre-preliminary. You've got to cover a lot of issues before writing the compiler, even before writing parser - all to spot potential logic errors within the language and change its syntax accoordingly.
(are functions virtual? are members hold by reference or by value? are arguments being passed by ref or by value? how are variables declared within function scope? what model of GC are you using? what's the connection between destructors and GC?, etc.)
Also, I didn't like the design decision to access object members via accessor functions only. It seems to me like an overuse of OO, an irritiating feature, expecially that this is supposed to be for scripts, not for any larger projects that could benefit from this tactic, wrt. rationale you've given.
Good luck!
~def
Ah, it is preliminary but it's mostly a programming guide, not a technical reference to how the language works underneath the shell.
Also, I just realized that there isn't really any way to implement strings with this. At first I figured I could use character arrays (like in C) but then I found out that there isn't a way to pass an array to a function. Grr...I don't want to implement pointers.
Also, I was thinking about taking out the repeat statement. The same effect can easily be accomplished by using a for loop...what do you think? I don't want redundancies in the language, but I do want convenience.
And to answer more questions...
Functions are not virtual. Everything is by value, not by reference. (references and pointers can get yucky, I'm trying to keep it simple) Variables can be declared anywhere, but will only last until the scope ends (as documented). And by GC, you mean garbage collection, right? Any memory allocated with the new keyword will automatically be freed when the scope that contains the declaration of the variable (not the allocation) ends.
What do you think of the IDE? I guess I should change the font to Courier New..10 pt. Maybe add syntax highlighting if I ever figure out how...
Also, I just realized that there isn't really any way to implement strings with this. At first I figured I could use character arrays (like in C) but then I found out that there isn't a way to pass an array to a function. Grr...I don't want to implement pointers.
Also, I was thinking about taking out the repeat statement. The same effect can easily be accomplished by using a for loop...what do you think? I don't want redundancies in the language, but I do want convenience.
And to answer more questions...
Functions are not virtual. Everything is by value, not by reference. (references and pointers can get yucky, I'm trying to keep it simple) Variables can be declared anywhere, but will only last until the scope ends (as documented). And by GC, you mean garbage collection, right? Any memory allocated with the new keyword will automatically be freed when the scope that contains the declaration of the variable (not the allocation) ends.
What do you think of the IDE? I guess I should change the font to Courier New..10 pt. Maybe add syntax highlighting if I ever figure out how...
I think the repeat keyword is a good idea.
something like that as opposed to:
it would definitely increase performance if it's used often.
i'm not sure how accurate my asm was-i haven't used it in a while, but you get the general idea.
[Edited by - F-Kop on July 8, 2006 2:33:27 PM]
repeat(10){ // stuff here} mov ecx, 10loopbegin: test ecx jz loopend ; stuff here dec ecx jmp loopbeginloopend:
something like that as opposed to:
for( i = 0; i < 10; i++ ){ // stuff here} mov dword ptr , 0loopbegin: mov eax, dword ptr cmp eax, 10 jge loopend ; stuff here mov eax, dword ptr add eax, 1 mov dword ptr , eax jmp loopbeginloopend:
it would definitely increase performance if it's used often.
i'm not sure how accurate my asm was-i haven't used it in a while, but you get the general idea.
[Edited by - F-Kop on July 8, 2006 2:33:27 PM]
Increased performance? Not likely. Any half-decent compiler would emit assembler that basically is identical to your first version; that second monstrosity (while possibly technically correct) is a lot more complicated than what a modern compiler would generate.
I think he was referring to coding efficiency, but I may be mistaken.
And, yes, I have to agree that repeat() is a nice feature. I'd like a way to access which number it's on, though.
And, yes, I have to agree that repeat() is a nice feature. I'd like a way to access which number it's on, though.
Quote:Original post by ApochPiQ
Increased performance? Not likely. Any half-decent compiler would emit assembler that basically is identical to your first version; that second monstrosity (while possibly technically correct) is a lot more complicated than what a modern compiler would generate.
for( i = 0; i < 10; i++ )0041A359 mov dword ptr ,0 0041A360 jmp main+1Bh (41A36Bh) 0041A362 mov eax,dword ptr 0041A365 add eax,1 0041A368 mov dword ptr ,eax 0041A36B cmp dword ptr ,0Ah 0041A36F jae main+23h (41A373h) { // }0041A371 jmp main+12h (41A362h)
this was compiled and disassembled with VC8. i wasn't exact, but i was pretty close. if an operation has to be done more than once without a counter variable, a repeat keyword would generate fewer assembly instructions, and it would look nicer.
Using what compiler settings? I had trouble getting VC8 to not unroll or simplify any of my test loops radically, when using full optimizations.
[edit] I fell back to VC6 because I already had a project set up for something similar. Here's my input code:
Stripping out the cin stuff, the generated assembly boils down to:
Well gee, what do you know about that - and that's VC6. I know for a fact VC8's optimizer is even smarter [smile]
[edit 2] Actually... my IA32ASM is rusty, but I believe that npad is excessive as well (I *think* it's related to cin also). Which means the final result, less the "stuff", is all of three instructions. That's actually shorter than your by-hand version by two instructions - and will have significantly less chance of borking branch prediction in the CPU.
[edit 3] It's a compiler directive from VC; just pads with NOPs to ensure the jump address is aligned nicely. So it can indeed be ignored.
[edit] I fell back to VC6 because I already had a project set up for something similar. Here's my input code:
int x; int i; for(i = 0; i < 10; ++i) { // Foo cin >> x; // Blah } cout << x << endl;
Stripping out the cin stuff, the generated assembly boils down to:
mov esi, 10 ; 0000000aH npad 8$L8546: dec esi jne SHORT $L8546
Well gee, what do you know about that - and that's VC6. I know for a fact VC8's optimizer is even smarter [smile]
[edit 2] Actually... my IA32ASM is rusty, but I believe that npad is excessive as well (I *think* it's related to cin also). Which means the final result, less the "stuff", is all of three instructions. That's actually shorter than your by-hand version by two instructions - and will have significantly less chance of borking branch prediction in the CPU.
[edit 3] It's a compiler directive from VC; just pads with NOPs to ensure the jump address is aligned nicely. So it can indeed be ignored.
Funny..this is what I got with VC6:
6: for( i = 0; i < 10; i++ )00401028 C7 45 FC 00 00 00 00 mov dword ptr [ebp-4],00040102F EB 09 jmp main+2Ah (0040103a)00401031 8B 45 FC mov eax,dword ptr [ebp-4]00401034 83 C0 01 add eax,100401037 89 45 FC mov dword ptr [ebp-4],eax0040103A 83 7D FC 0A cmp dword ptr [ebp-4],0Ah0040103E 7D 02 jge main+32h (00401042)7: {8: // stuff9: }00401040 EB EF jmp main+21h (00401031)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement