r/Forth • u/[deleted] • Oct 20 '17
A javascript forth I'm working on
I play a competitive hacking video called hackmud where you try to outhack each other with javascript. There is a character limit and you have to get a more powerful character with more money to increase the character limit. You start out with around 500 characters so I try to fit more and more into 500 characters as I can.
https://hastebin.com/ekizilacaf.php
This is my current version of a forth runtime. I have not tested this one yet but it should be able to do just about everything that I need it to be able to do.
It's important to be able to run your own version of forth here because it lets you break the character limit by running code from strings, but because you can't trust that another person's forth is not logging what you do in it in their in game database.
The secret to this particular forth is you have to implement a mockup version of the colon compiler without the colon compiler. Also it will have to be handed functions from other programs in order to do certain tasks.
This is not meant to be a particularly fast forth. Just one with as few characters as possible.
edit: most current version https://hastebin.com/utoxecoxen.pl
6
u/dlyund Oct 20 '17
It would be really great if you could at least try to run the code before you declare this as anything. Judging by the state of your code it looks like you spent all of 5 minutes thinking about this.
2
1
u/petrus4 Oct 20 '17
I'm not sure why this has received so many downvotes. I upvoted, if it means anything.
1
Oct 20 '17
You working on any programming projects these days Petrus?
2
u/petrus4 Oct 20 '17
Nothing specific, but I'm currently reading Chuck Moore's book, Programming a Problem Oriented Language. I'd started reading it before, but didn't go that far into it. I'm surprised how much I can understand, but in most languages even doing relatively basic things like checking if each character is a space is beyond me. I'd know how to do that in shell script, yes; but not in something like C or Java.
5
u/_crc Oct 20 '17
Can you provide an example of how to call this?