Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

vixcpp/vixc

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vix++

Vix++ is a thin language layer for Vix-powered C++ applications.

It keeps your code close to standard C++, but removes some of the friction around includes, build flow, and runtime usage.

use vix.core;
use std.iostream;

int main()
{
  std::cout << "Hello from Vix++\n";
  return 0;
}

Vix++ transpiles .vix files into standard C++ files, then delegates the build and execution to the existing vix CLI.

main.vix
  ↓
vix++ transpiler
  ↓
.vix/build/vixc/main.generated.cpp
  ↓
vix run/build/check
  ↓
binary

Why Vix++ exists

C++ is powerful, fast, and explicit. But the developer experience around includes, build systems, compiler flags, dependency wiring, and project setup can become heavy very quickly.

Vix already makes C++ easier to run:

vix run main.cpp

Vix++ adds a small language layer on top:

vix++ run main.vix

The goal is simple: cleaner source, standard C++ output, Vix-powered build.

Vix++ does not replace C++. It improves the way you write and run C++ applications with Vix.

Vix vs Vix++

Vix and Vix++ have separate responsibilities.

Vix     = runtime and build engine for standard C++
Vix++   = language frontend for .vix files

Vix++ depends on the vix command being installed and available in your PATH. It does not link against the internal Vix CLI code.

Example

Create main.vix:

use std.iostream;

int main()
{
  std::cout << "Hello from Vix++\n";
  return 0;
}

Run it:

vixc run main.vix

Vix++ generates:

// Generated by Vix++. Do not edit directly.
#include <iostream>

int main()
{
  std::cout << "Hello from Vix++\n";
  return 0;
}

Then it calls:

vix run .vix/build/vixc/main.generated.cpp

Imports

Vix++ uses use declarations:

use vix.core;
use vix.json;
use std.vector;
use local.config;

They are converted to C++ includes:

#include <vix/core.hpp>
#include <vix/json.hpp>
#include <vector>
#include "config.hpp"

Vix imports

use vix.core;         // → #include <vix/core.hpp>
use vix.http.server;  // → #include <vix/http/server.hpp>

Standard library imports

use std.iostream;  // → #include <iostream>
use std.vector;    // → #include <vector>
use std.string;    // → #include <string>

Local imports

use local.config;         // → #include "config.hpp"
use local.services.user;  // → #include "services/user.hpp"

Basic syntax

A .vix file is mostly normal C++. Only use declarations are special in the MVP.

use vix.core;
use std.string;

int main()
{
  vix::App app;
  return app.run();
}

Rules:

  • use declarations must appear before regular C++ code
  • blank lines are allowed
  • // comments are allowed before and between imports
  • duplicate imports are emitted only once
  • the rest of the file remains standard C++

CLI

vixc run main.vix        # run a .vix file
vixc main.vix            # shortcut for run
vixc build main.vix      # build a .vix file
vixc check main.vix      # check a .vix file
vixc help                # show help
vixc version             # show version

Use a custom Vix binary:

vixc run main.vix --vix /usr/local/bin/vix

Use a custom generated output directory:

vixc run main.vix --build-dir .vix/generated

Forward arguments to Vix:

vixc build main.vix --out app

Build from source

git clone https://github.com/vixcpp/vixc
cd vixc

vix build --build-target all -v
vix tests

The binary is generated as build/vixc. Run an example:

vix run ./build/vixc run examples/hello.vix

Examples

Hello world

use std.iostream;

int main()
{
  std::cout << "Hello from Vix++\n";
  return 0;
}

JSON

use vix.json;
use std.iostream;

int main()
{
  using namespace vix::json;

  auto user = o(
      "id", 42,
      "name", "Ada",
      "tags", a("pro", "admin"));

  std::cout << dumps(user, 2) << "\n";
  return 0;
}

HTTP

use vix.core;

int main()
{
  vix::App app;

  app.get("/", [](vix::Request &, vix::Response &res){
    res.json({"message", "Hello from Vix++"});
  });

  app.run(8080);
  return 0;
}

Project status

Vix++ is experimental. The first version focuses on:

  • .vix files
  • use imports
  • portable transpilation
  • diagnostics
  • generated standard C++
  • delegation to Vix
  • basic tests

It does not try to become a full new language yet.

What Vix++ does not do yet

  • fn syntax
  • let syntax
  • automatic package imports
  • C++20 module generation
  • project import maps
  • formatting / linting
  • watch mode
  • REPL

Architecture

vixc/
├── include/vixc/
│   ├── Diagnostic.hpp
│   ├── ImportResolver.hpp
│   ├── SourceFile.hpp
│   ├── Transpiler.hpp
│   ├── Runner.hpp
│   └── Version.hpp
│
├── src/
│   ├── Diagnostic.cpp
│   ├── ImportResolver.cpp
│   ├── SourceFile.cpp
│   ├── Transpiler.cpp
│   ├── Runner.cpp
│   └── main.cpp
│
├── examples/
├── tests/
├── docs/
└── cmake/

Core parts: SourceFile loads .vix files, ImportResolver maps use declarations to C++ includes, Transpiler generates standard C++, Runner calls the installed vix CLI, and Diagnostics reports clear errors.

Design principles

  • Stay close to C++
  • Generate readable C++
  • Do not hide the runtime
  • Do not replace Vix
  • Keep imports predictable
  • Make the build flow simpler

The developer should always be able to understand what Vix++ generates. Vix++ should make C++ easier to write without making it mysterious.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Created by Gaspard Kirira
Vix.cpp: [https://github.com/vixcpp/vixc]

About

Vix++ is a thin language layer for Vix-powered C++ applications.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.