Skip to content

Proposal: support using the compiler as a zig.zon package #18834

Closed as not planned

Description

@theoparis

Use Cases

  1. Use the native zig backends (once they are ready, of course) as an alternative to using libLLVM*.a
  2. Use the compiler as a library

Use case 2 is what I'm in need of since I want to make an alternative to Nix flakes but with a flake.zig. A build.zig does not fit my use case since I want to have a nix-like CLI with a zix develop similar to nix devShells. This would mean using the compiler to parse the flake.zig, checking types and running the outputs function to extract devShells.default.

Activity

  1. Arnau478 commented on Feb 6, 2024

    @Arnau478
    Contributor

    The parser and lexer are already on the std. Maybe what we should do is move the other stages to the std as well.

  2. VisenDev commented on Feb 6, 2024

    @VisenDev

    +1

    Related to this, a similar idea I had was being able to use the zig compiler as a library, such that one could use zig as a scripting language.

    You would be able to embed the compiler as a library, then have it compile different zig files at runtime into dylibs. This would allow you to use zig for the same purposes as one currently uses scripting languages like lua.

    The advantage to this would be that there would not be any complex interfacing functions or anything required. Zig can easily interface with other zig code since it's the same language.

    The use case for this would be things that need to be easily user extensible, such as games and text editors.

  3. nektro commented on Feb 6, 2024

    @nektro
    Contributor

    yeah the solution to this is to get the compiler in the std.zig namespace not expose it with zon imo. but its a ways out and easier to do once development isnt as rapid (thus making movements cause a wave of merge conflicts)

  4. VisenDev commented on May 12, 2024

    @VisenDev

    @theoparis has this been implemented?

  5. theoparis commented on May 13, 2024

    @theoparis
    Author

    No. I have given up on using zig after what happened on the Zig discord. Additionally, there is nowhere else for me to go because it is the only active Zig community.

    I have moved to rust and c++ and I do not intend on coming back until the Zig community deals with these horrible moderators/contributors.

  6. sin-ack commented on May 13, 2024

    @sin-ack
    Contributor

    Regardless of your feelings about the Zig community, it would still be worthwhile to keep the issue open because it allows the Zig developers (distinct from the community) to track it. You can re-open and then click "Unsubscribe" on the sidebar to not receive notifications about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions