Jump to content

An Introduction to Dragon/Lessons/Features

From Wikibooks, open books for an open world

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), the this and super keywords, 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 / finally and raise.
  • String interpolation using backtick strings with ${expr} placeholders, plus a format() 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 const that cannot be reassigned after they are set.
  • Concurrency via async / await and a thread module for spawning worker threads.
  • Modules, imported with a simple import statement, 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 / .dylib for 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.json manifest with dragon run.