An Introduction to Dragon/Lessons/Features
Appearance
Features
[edit | edit source]Dragon aims to give a scripting-language "feel" — quick to write, nothing to configure — while still offering the constructs needed for larger programs.
Language features
[edit | edit source]- Simple, readable syntax — spend less time fighting the language, more time solving problems.
- Dynamic and weak typing — variables need no type declaration and are checked at run time.
- First-class functions and closures, including arrow-function lambdas.
- Classes with constructors (
init), inheritance (extends), thethisandsuperkeywords, and method overriding. - Familiar control flow:
if/elif/else,while,do/while,for ... in,switch/case, and a ternary operator. - Structured error handling with
try/catch/finallyandraise. - String interpolation using backtick strings with
${expr}placeholders, plus aformat()function for fine-grained output control (padding, decimal precision, and so on). - Built-in collections: dynamically sized lists and ordered maps, each with a rich set of methods (
push,map,filter,reduce,sort,set, and more). - Constants declared with
constthat cannot be reassigned after they are set. - Concurrency via
async/awaitand athreadmodule for spawning worker threads. - Modules, imported with a simple
importstatement, covering everything from math to networking to cryptography.
Tooling and distribution features
[edit | edit source]- Portable across Windows, Linux, and macOS.
- An interactive REPL (
dragon --repl) for exploring the language line by line. - Native compilation (experimental) — transpile Dragon source to C and build it with the system C compiler.
- Self-contained executables — bundle a script and its dependencies into a single encrypted, distributable binary with
dragon -c. - Shared library builds — compile Dragon scripts into a
.dll/.so/.dylibfor embedding in other applications. - The TurboDragon IDE — a built-in terminal UI editor/runner, launched with
dragon --ide. - Package-based projects — run a project directly from a
package.jsonmanifest withdragon run.