7. Tutorials

This section provides hands-on tutorials organized into four groups:

  • 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

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 tutorial_building_from_sdk.

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. 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