A powerful scripting language for creating Minecraft servers, built on the Minestom library. SwoftLang combines the flexibility of a scripting language with the performance benefits of C++ and Java interoperability, making it ideal for developing custom Minecraft server experiences.
SwoftLang is a dedicated scripting language designed specifically for Minecraft server development. It leverages both Java and C++ through JNI, allowing server developers to write efficient code that interacts seamlessly with the Minestom ecosystem. This approach provides the ease of use of a scripting language while maintaining high performance for server operations.
Releases are auto deployed on push onto the GitHub releases page which can be found here. Updates are also periodically sent within my discord server located at discord.gg/paper.
-
C++ Parser Layer
- Lexical Analysis: C++ code tokenizes SwoftLang script files (
.sw
files) using a custom lexer - Parsing: Tokens are parsed into an Abstract Syntax Tree (AST) representing commands, variables, control flow, and expressions
- Type Checking: Variable types and command arguments are validated during the parsing phase
- Lexical Analysis: C++ code tokenizes SwoftLang script files (
-
JNI Bridge Layer
- Parsed C++ objects are converted to Java representations via JNI
- Each C++ AST node has a corresponding Java class in the
nativebridge.representation
andnativebridge.execution
packages - Commands, expressions, and statements are serialized across the language boundary
-
Java Execution Layer
- Executes block statements that can manipulate game state, send messages, teleport players, etc.
- Parse-time Optimization: Complex parsing logic runs in optimized C++
- Runtime Efficiency: Java objects are pre-validated and structured for fast execution
- Memory Management: JNI handles object lifecycle across language boundaries
Thanks to:
- The contributors to this project, which can be viewed on this Git page.