7. Tutorials

This section provides hands-on tutorials organized by topic:

  • Language Tutorials — learn daslang syntax and standard library features

  • C Integration Tutorials — embed daslang in a C host using the daScriptC.h API

  • C++ Integration Tutorials — embed daslang in a C++ host using the native daScript.h API

  • Macro Tutorials — write compile-time code transformations using the daslang macro system

  • Module Tutorials — dasHV (HTTP), dasPUGIXML (XML), dasStbImage, dasAudio, dasPEG (parser generator)

7.1. Language Tutorials

These tutorials introduce daslang’s core features step by step. Each comes with a companion .das file in tutorials/language/ that you can run directly:

daslang.exe tutorials/language/01_hello_world.das

The tutorials are designed to be followed in order. Each one builds on concepts introduced in earlier tutorials.

7.2. Building from the Installed SDK

Once daslang is installed, you can build the integration tutorials — or your own projects — against the SDK using CMake’s find_package(DAS).

7.3. C Integration Tutorials

These tutorials show how to embed daslang in a C application using the daScriptC.h API. Each tutorial comes with a .c source file and a companion .das script in tutorials/integration/c/.

The installed SDK ships with a standalone CMakeLists.txt that lets you build all C tutorials directly against the SDK — see Building Projects Against the Installed SDK.

7.4. C++ Integration Tutorials

These tutorials show how to embed daslang in a C++ application using the native daScript.h API. Each tutorial comes with a .cpp source file and a companion .das script in tutorials/integration/cpp/.

The installed SDK ships with a standalone CMakeLists.txt that lets you build all C++ tutorials directly against the SDK — see Building Projects Against the Installed SDK.

7.5. Macro Tutorials

These tutorials teach daslang’s compile-time macro system: call macros, reader macros, function macros, and AST manipulation. Each tutorial has two source files — a module (.das) that defines the macros and a usage file that exercises them — because macros cannot be used in the same module that defines them.

Run any tutorial from the project root:

daslang.exe tutorials/macros/01_call_macro.das

7.6. dasHV (HTTP / WebSocket) Tutorials

These tutorials cover the dashv module — HTTP client and server bindings built on libhv. The companion .das files are in tutorials/dasHV/.

Run any tutorial from the project root:

daslang.exe tutorials/dasHV/01_http_requests.das

7.7. dasPUGIXML (XML) Tutorials

These tutorials cover the dasPUGIXML module — XML parsing, building, XPath queries, and automatic struct serialization using pugixml. The companion .das files are in tutorials/dasPUGIXML/.

Run any tutorial from the project root:

daslang.exe tutorials/dasPUGIXML/01_parsing_and_navigation.das

7.8. dasStbImage (Image I/O) Tutorials

These tutorials cover the stbimage_boost module — image loading, saving, format conversion, and pixel manipulation using stb_image. The companion .das files are in tutorials/dasStbImage/.

Run any tutorial from the project root:

daslang.exe tutorials/dasStbImage/01_loading_images.das

7.9. dasSQLITE (SQL) Tutorials

These tutorials cover the daslib/sql + sqlite/sqlite_boost API — RAII connection handling, the [sql_table] structure macro, and the typed CRUD helpers built on top of it. The companion .das files are in tutorials/sql/.

Run any tutorial from the project root:

daslang.exe tutorials/sql/01-version.das

7.10. dasAudio (Audio) Tutorials

These tutorials cover the audio_boost module — audio playback, 3D spatial audio, effects, WAV I/O, and MIDI. The companion .das files are in tutorials/dasAudio/.

Run any tutorial from the project root:

daslang.exe tutorials/dasAudio/01_hello_sound.das

7.11. daStrudel (Live-Coding) Tutorials

These tutorials cover the strudel module — pattern-based live-coding music with mini-notation, time algebra, per-voice effects, samples, SF2 soundfonts, MIDI playback, and live-reload. Companion .das files are in tutorials/daStrudel/.

Run any tutorial from the project root:

daslang.exe tutorials/daStrudel/daStrudel_01_hello_pattern.das

For the strudel-to-strudel.cc feature comparison, see daslang strudel vs strudel.cc — Feature Comparison.

7.12. dasPEG (Parser Generator) Tutorials

These tutorials cover the peg module — daslang’s built-in PEG (Parsing Expression Grammar) parser generator. Define grammars directly in daslang using the parse macro; the compiler generates a packrat parser at compile time.

The companion .das files are in tutorials/dasPEG/.

Run any tutorial from the project root:

daslang.exe tutorials/dasPEG/01_hello_parser.das