daneelsan/WolframLanguageRuntimeZigDemo
WolframLanguageRuntime demo in Zig
A demo of the new Wolfram Language Runtime written in Zig.
I wrote a Wolfram community post expanding on the details Wolfram Language Runtime (SDK) demo in Zig.
We will create two standalone executables that run the Transliterate function from Wolfram Language. The executables are written in C and Zig.
The zig build
command will build both the C and the Zig executables:
$ zig build --summary all
Build Summary: 5/5 steps succeeded
install success
├─ install transliterate-zig success
│ └─ zig build-exe transliterate-zig Debug native cached 45ms MaxRSS:36M
└─ install transliterate-c success
└─ zig build-exe transliterate-c Debug native cached 45ms MaxRSS:36M
By default, the executables are stored in zig-out/bin
:
$ ls zig-out/bin ─╯
transliterate-c transliterate-zig
Now that the executable is compiled, see the usage:
$ ./zig-out/bin/transliterate-c
Usage: ./transliterate-c "input"
Use the executable:
$ ./zig-out/bin/transliterate-c 'しんばし'
shinbashi
Instead of specifying where the C header library is (see build.zig), we are using a handwritten Zig package: WolframLanguageRuntime.zig.
Now that the executable is compiled, see the usage:
$ ./zig-out/bin/transliterate-zig
Usage: ./transliterate-zig "input"
Use the executable:
$ ./zig-out/bin/transliterate-zig 'しんばし'
shinbashi
Tested on:
$ uname -a
Darwin mac.lan 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec 6 19:03:40 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6041 arm64
Tested on:
In[]:= $Version
Out[]= "14.3.0 for Mac OS X ARM (64-bit) (March 26, 2025)"
Tested on:
$ zig version
0.14.0
Zig is not on version 1.0. The language is in constant development and some things might break in the future.