An Introduction to Dragon
Dragon is an innovative and practical general-purpose, multi-paradigm programming language. It supports multiple programming paradigms — imperative, object-oriented, functional, procedural, and declarative — with an expressive, readable syntax that is easy to pick up. Dragon is dynamically and weakly typed, is portable across Windows, Linux, and macOS, and can be used to build console applications.
Under the hood, Dragon source is tokenized by a lexer, parsed into an abstract syntax tree, compiled to bytecode, and executed by a register/stack-based virtual machine written in Rust. For advanced use cases, Dragon scripts can also be transpiled to C and compiled natively with the system's C compiler (gcc, clang, or MSVC), bundled into a single self-contained encrypted executable, or built as a shared library (.dll / .so / .dylib) for embedding in other applications.
Dragon ships with a batteries-included standard library covering math, JSON, the filesystem, the OS environment, dates and timers, HTTP networking, cryptography, ZIP archives, XML, UUIDs, PDF/font rendering, and native FFI interop — all available through a simple import statement. It also includes built-in support for async/await and a thread module for concurrent programming, an interactive REPL, a package-based project runner driven by package.json, and a terminal-based editor called the TurboDragon IDE.
Table of Contents
[edit | edit source]Getting Started
[edit | edit source]- Introduction
- History
- Features
- Installation and Building from Source
- Hello World
- Run the program
- The Interactive REPL
- Multi-Line literals
- Getting Input
- Writing Comments
Variables
[edit | edit source]- Variables
- Dynamic Typing
- Deep Copy
- Weakly Typed
- Constants
- typeof() and Type Conversions
- String Interpolation
- Formatting Output with format()
Operators
[edit | edit source]- Operators
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Ternary Operator
- Misc Operators
- Operator Precedence
Control Structures
[edit | edit source]- Control Structures
- Branching: if / elif / else
- Looping: while
- Do While Loop
- For-In Loop over Lists and Maps
- Break and Continue
- Switch / Case
Getting Input
[edit | edit source]Functions
[edit | edit source]- Functions
- Define Functions
- Call Functions
- Declare Parameters
- Default Parameter Values
- Rest Parameters
- Send Parameters
- Variables Scope
- Return Value
- Lambdas (Arrow Functions)
Collections
[edit | edit source]- Collections
- Lists
- List Methods: push, map, filter, reduce, sort
- Maps
- Map Methods: set, iteration
- String Methods: trim, upper, lower, split, contains, replace
Classes and Object-Oriented Programming
[edit | edit source]- Classes
- Defining a Class
- Constructors with init()
- The this Keyword
- Creating Instances with new
- Inheritance with extends
- Calling Parent Methods with super
- Method Overriding
Error Handling
[edit | edit source]Modules and the Standard Library
[edit | edit source]- Modules and import
- math — Numeric and Math Utilities
- json — Encoding and Decoding JSON
- file / path — Filesystem Access
- os — Environment and System Info
- time — Dates, Timers, and Sleeping
- net — HTTP Client and Server
- crypto — Hashing, HMAC, PBKDF2, AES-GCM
- zip, xml, and uuid
- pdf and font — Document and Text Rendering
- ffi / struct / mem — Native Interop
Concurrency
[edit | edit source]Compiling and Distribution
[edit | edit source]- Compiling and Distribution
- Bundling Self-Contained Executables
- Building Shared Libraries
- Native Compilation via C Transpiling
- Running Package Projects with package.json
