Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

An Introduction to Dragon

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

An introduction to 200px|center|The Dragon programming language logo The Dragon Programming Language 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 Getting Started Introduction History Features Installation and Building from Source Hello World Run the program The Interactive REPL Multi-Line literals Getting Input Writing Comments Variables Variables Dynamic Typing Deep Copy Weakly Typed Constants typeof() and Type Conversions String Interpolation Formatting Output with format() Operators Operators Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Assignment Operators Ternary Operator Misc Operators Operator Precedence Control Structures 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 Getting Input readln function Command Line Arguments (argv) Functions Functions Define Functions Call Functions Declare Parameters Default Parameter Values Rest Parameters Send Parameters Variables Scope Return Value Lambdas (Arrow Functions) Collections 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 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 Error Handling try / catch / finally Raising Errors with raise Scope of try/catch Modules and the Standard Library 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 Concurrency async / await The thread Module Compiling and Distribution Compiling and Distribution Bundling Self-Contained Executables Building Shared Libraries Native Compilation via C Transpiling Running Package Projects with package.json Tooling Tooling The TurboDragon Terminal IDE Using the REPL Effectively Appendices Standard Library Reference Command Line Reference Glossary Computer programming languages 25% __NOTOC__