dragonstone v0.1.1-PreAlpha
What is Dragonstone?
Dragonstone is a general purpose, high-level, object-oriented programming language. It is both an interpreted and compiled language, inspired by Ruby and Crystal but designed for programmer happiness, productivity, and choice.
This language is a work in progress. At this stage, much can still be changed.
Project Setup
Requirements
- The Crystal Programming Language needs to be installed. (1.17.1 or higher are the only versions verified)
Building from Source using Bash (All Platforms)
- Clone this repository.
- Change directory to this project.
- Run
shards buildto build (this gets placed in./bin).
Building from Source using Terminal or Powershell (Windows Only)
- Clone this repository.
- Change directory to this project.
- Run
shards buildto build (this gets placed in./bin). - Run
.\bin\dragonstone.bat --rebuild-exe(this rebuilds the project with the--releaseflag and adds the dragonstone icon). - (Optional) Run
.\bin\dragonstone.batto add.\binto your users PATH environmental variable, allowing you to rundragonstonefrom anywhere. Restart your terminal after this step.
Note: You can also just use shards build on Windows for a standard build but this will not use the --release flag unless specified otherwise, this will make dragonstone compile/interpret usage significantly slower.
Note: Also on Windows you can just use the installer listed in releases.
Usage
Run Files via Interpreter.
dragonstone run examples/hello_world.ds
./bin/dragonstone.exe run examples/hello_world.ds
Select Backend (for now this is a temporary flag).
# Select between native (interpreter) or core (compiler) backends.
dragonstone run --backend native examples/hello_world.ds
dragonstone run --backend core examples/hello_world.ds
# By default, dragonstone will use native (interpreter),
# However, you can change it anytime.
DRAGONSTONE_BACKEND=core dragonstone run examples/hello_world.ds
# Or export the flag once for the CLI:
export DRAGONSTONE_BACKEND=core
Build and Run Files via the Compiler with a target.
# Supported Target Flags: bytecode, llvm, c, crystal, and ruby
dragonstone build --target bytecode examples/hello_world.ds
# Build and immediately execute the produced artifacts.
dragonstone build-run --target bytecode examples/hello_world.ds
Run Test/Spec (still building out unit tests).
crystal spec
# helper script that runs spec for just a specific backend.
./scripts/backend_ci.sh spec --backend native
./scripts/backend_ci.sh spec --backend core
Benchmark Information
- When using
--releaseflag. - <2% overhead at scale.
- Near identical for loops vs single.
You can run these yourself from the ./scripts directory.
1 Billion Single Loop Iteration Benchmark (Interpreter)
~4.47 million iterations/second
~0.224 microseconds per iteration
Iterations: 223,712 ms
Actual Time: 223.71 seconds (3.73 minutes)
1 Billion Nested Loop Iteration Benchmark (Interpreter)
~4.43 million iterations/second
~0.226 microseconds per iteration
Iterations: 225,810 ms
Actual Time: 225.81 seconds (3.76 minutes)
Comparison Context
For 1 billion iterations of this benchmark:
Ruby v2.X.X = ~15-30 minutes (varies by version)
Python v3.X.X = ~5-15 minutes (varies by version)
-> Dragonstone = ~3.7 minutes
Lua = ~1-2 minutes
JavaScript = ~10-30 seconds (using V8)
Examples
Example of output using echo:
echo "Hello World!"
Example of comments/block comments using # and #[ ]#:
# This is a Single Line Comment.
#[
This is a Multi-Line Comment.
]#
message = "Hello!" # Trailing Comment.
#[ Multi-Line Comment on same line. ]# numbers = 10 #[ Inside or outside. ]#
Some Examples:
Example of a String.
name = "Ringo"
echo name
Example of a def Method and String Interpolation.
def greet(name)
echo "Hello, #{name}!"
end
greet("Jules")
Example of a Class.
class Person
happy = true
def greet
if happy
echo "Hello!"
end
end
end
person = Person.new
person.greet
Also Ascii and Unicode are supported.
class 🔥
あ = true
def 道
if あ
echo "Hello!"
end
end
end
🔥.道
Example of a Module with con, an immutable constant, and :: for scope resolution.
module Grades
con Score = 100
class Greeting
def greet
"Hello! I got a #{Grades::Score}%!"
end
end
end
echo Grades::Score
echo Grades::Greeting.greet
Example of a Map literal with key -> value pairs.
ages = { "Jules" -> 32, "Ringo" -> 29, "Peet" -> 35 }
echo ages["Jules"]
ages["Ringo"] = 30
echo ages["Ringo"]
ages.each do |name, age|
echo "#{name} is #{age}"
end
e! ages.keys
e! ages.values
Some More Examples but with Optional Types:
Example of a String with types.
name: str = "Peet"
echo name
Example of some math/integers with types.
a: int = 10
b: int = 10
numbers = a + b
echo numbers
Two examples of a Class with types.
def 😱(name: str) -> str
echo "Hello, #{name}!"
end
😱("V")
class Person
property name: str
def initialize(name: str)
self.name = name
end
def greet
echo "Hello, my name is #{self.name}"
end
end
person = Person.new("Jules")
person.greet
Two examples of struct.
struct Point
property x: int
property y: int
def initialize(@x: int, @y: int)
end
end
point = Point.new(10, 20)
echo "x: #{point.x}, y: #{point.y}"
struct Point
property x: int
property y: int
end
point = Point.new(x: 1, y: 2)
with point
echo x
echo y
end
Example of using other files with use.
(from ./examples/test_use.ds)
con magic = 42
def add(a, b)
a + b
end
(from ./examples/use.ds)
use "test_use.ds"
echo add(magic, 8)
Two examples of para, the Dragonstone version of a Proc.
For any {} used within Dragonstone, these can also be split between lines or placed on the same line.
greet = ->(name: str) {
"Hello, #{name}!"
}
echo greet.call("Alice")
square: para(int, int) = ->(x: int) { x * x }
echo square.call(6)
Examples the interop (some done but still a work in progress).
This calling convention will change when I expand the FFI.
# Call puts from Ruby
ffi.call_ruby("puts", ["Hello from Ruby!"])
# Call puts from Crystal
ffi.call_crystal("puts", ["Hello from Crystal!"])
# Call printf from C
ffi.call_c("printf", ["Hello from C!"])
See the examples/ directory for more sample .ds files.
Contact
Project:
www.github.com/vallereya
License
© 2025 Vallereya
All rights reserved.
Code and Contributions have Apache-2.0 License agreed upon by all copyright holders.
See LICENSE for more information.
dragonstone
- 1
- 1
- 0
- 0
- 0
- 2 days ago
- October 24, 2025
Apache License 2.0
Wed, 10 Dec 2025 23:08:23 GMT