FoxLang Discussion
This is a discussion post for suggestions and feature requests of a yet to be fully implemented plugin called FoxLang.
What is FoxLang?
FoxLang is a JVM-based programming and scripting language all in one package.
This idea occurred because of FoxGuard and the proposed FoxEdit, both of which needed some ability to have basic scripts.
The point of this language is to provide a straight-forward, Minecraft oriented scripting/programming system. This language should be easy enough for anyone to write basic scripts in, while still having an advanced feature set for those who really want to do whatever they want.
One thing to note before continuing on, when I reference to scripts, I am talking about the files containing the code written in the language. I am referring to such files as scripts, because most of the time that is what the will be.
We originally had just been lexing, parsing, and running a very basic scripting setup directly in Java when the script was run. There was a huge downside about this method though, and that was the length of time it took to to do said tasks. We then decided that it would be better if the language could directly interface with regular game and plugin code.
This meant that we were going to have to do one of two things:
- Make it even slower and use a hell of a lot of reflection to allow access of regular objects into the scripts
- We could make the language compile down into Java bytecode, in which case we still might need a little bit reflection, but overall anything that you could do in regular Java, could also be done in the scripts.
We have, after much discussion, decided to have all scripts compile directly down to bytecode (this also allows JIT to optimize code, which means it should run at the same fast speeds that Java does).
As of right now, we do not have a syntax nailed down, and that is part of why I have decided to finally write this post, to gather peoples opinions on it.
There are currently only a few limitations for the syntax that we have decided on.
- There will be no indentation-based hierarchy. Sorry Python users. If people want to enter small scripts in the in-game chat, and we DID have an indentation-based syntax, it would be quite impossible to have anything more complex than a basic math expression.
- For the same reason listed above, there will be semicolons to end a statement.
While this language will optimally be able to do anything, it is targeting two specific features: Math/Expression scripting, and direct Minecraft interfacing.
Questions
Things I would like peoples opinions on (although please feel free to let me know if you have any other ideas or opinions)
- Nullability (Similar to Kotlin style)
- Strictly or Weakly variable types (Weakly: type of object can change)
- Inferred or defined variable types (Defined means you need to specify variable type)
- Closures/Lambdas
- Script argument handling
- Tuples, Data Classes, etc
- Compiled ahead of time, or at runtime
- Script caching
- Direct integration with plugins
- Piping into scripts or scripts output piping into other scripts
How to help
- Comment below with ideas, suggestions, and opinions (in regards to syntax, features, etc.).
- Test out the occasional release (once I actually get my act together and put things in a useable way.
- If your more into the development side, here is the GitHub; please feel free to make a PR or issue.
Current Stats
- Lexing 28900 tokens from raw code takes about 30 milliseconds.
- Compiling currently takes about 5 milliseconds (although this currently is only basic generation: things like the header, constant pool, various lists and such. This doesnāt include the actual code logic)
P.S. Not really sure if this is the correct category for the postā¦ Feel free to move it if itās in the wrong place
Snowie (d4rk)
FoxDenStudio