SWAG

SWAG Programming Language

A sophisticated toy

Swag is a system programming language made for fun because, let's be honest, C++ is now an horrible and ugly beast !

This is my third compiler (the other ones were developed for AAA game engines), but that one is by far the most advanced.

Native or interpreted

The Swag compiler can generate fast native code with a custom x64 backend or with LLVM. It can also act as an interpreter for a scripting language.

Imagine C++, but where everything could be constexpr.

Modern

Swag has full compile-time evaluation, type reflection at both runtime and compile time, meta programming, generics, a powerful macro system...

Enjoy.

To take a look at an explained implementation of the Flappy Bird game in one single little script file.

Warning

We haven't officially launched anything yet! Everything, even this website, is still a work in progress. So, the rules of the game can change anytime until we hit version 1.0.0. Let's keep the fun going!

// The 'IsSet' generic struct is generated as a mirror of the user input struct. // Each field has the same name as the original one, but with a 'bool' type. // It will indicate, after the command line parsing, that the corresponding argument has been // specified or not by the user. struct(T) IsSet { #ast { var str = StrConv.StringBuilder{} let typeof = @typeof(T) visit f: typeof.fields str.appendFormat("%: bool\n", f.name) return str.toString() } }
#test { const N = 4 const PowerOfTwo: [N] s32 = #run { var arr: [N] s32 loop i: arr arr[i] = 1 << cast(u32) i return arr } #assert PowerOfTwo[0] == 1 #assert PowerOfTwo[1] == 2 #assert PowerOfTwo[2] == 4 #assert PowerOfTwo[3] == 8 }

Swag is open source and released under the MIT license. You will find the compiler source code on GitHub. You can also visit the YouTube channel to see some little coding sessions.

Warning

The language evolves, and those videos can show out of date syntax. But the corresponding scripts on GitHub are always up to date and running.

Note

The pages of this web site and all the related documentations have been generated with Swag, as the compiler can also produce HTML based on markdown files and source code.

Generated on 14-05-2024 with swag 0.32.0