5 ms·
> So Zig is as expressive as C++. but not only safer, but also much simpler, and compiles faster Tbh syntax-wise Zig feels more cryptic[1] at first than C++.
by pRusya 1y ago
> So Zig is as expressive as C++. but not only safer, but also much simpler, and compiles faster
Tbh syntax-wise Zig feels more cryptic[1] at first than C++.
[1] e.g. `extern "user32" fn MessageBoxA(?win.HWND, [*:0]const u8, [*:0]const u8, u32) callconv(win.WINAPI) i32;` from https://ziglang.org/learn/samples/ https://ziglang.org/learn/samples/
- pron 1y agoI think that's just a matter of syntax habits, presumably because you're already familiar with C++ syntax. The syntax in your example is especially "cryptic" simply because it's an FFI signature (of a function that's not written in Zig and doesn't use the normal Zig data representations).
- tredre3 1y agoTo be clear the equivalent C++ code is: #include <windows.h> extern "C" __declspec(dllimport) int __stdcall MessageBoxA(HWND, LPCSTR, LPCSTR, UINT); // or extern "C" __declspec(dllimport) int __stdcall MessageBoxA(void *, const char[], const char[], unsigned int); It's not exactly a stellar improvement.
- npalli 1y agoLol, no this is the equivalent #include <windows.h> int main() { MessageBoxA(NULL, "world!", "Hello", 0); return 0; }
- deleted 1y ago[deleted]