3 ms·
Why use a custom compiler for one specific target when you could have a single compiler that support any target you want? It doesn’t look like emscripten has an
by audunw 3y ago
Why use a custom compiler for one specific target when you could have a single compiler that support any target you want? It doesn’t look like emscripten has an integrated build system either?
I think that’s the genius of Zig.. one of the main goals is to build a better and faster C compiler. It might end up being the only C compiler with really solid hot-swapping support. And then if you’re already using the compiler you might as well start using the language too.
- pjmlp 3y agoclang also supports cross compiling. Sometimes I wonder how much people nowadays actually bother to learn about compiled languages.
- throwaway2046 3y agoThe Zig compiler bundles the SDKs of supported targets while Clang does not, so you can cross compile out of the box without any extra steps. It also defines targets for various GLIBC versions which AFAICT Clang does not.
- pjmlp 3y agoIt is so hard to install additional OS packages.
- flohofwoe 3y agoDid you actually try it? Across Windows, Linux and macOS? Setting up a vanilla Clang toolchain for cross-compilation is by far not as trivial as you make it sound.
- pjmlp 3y agoYou mean like cross compiling from Windows to Symbian, Windows CE/Pocket PC, Palm, Android, PlayStation, Nintendo, XBox? It is not a walk in the park, but it hardly a task only worthy of Hercules.
- IshKebab 3y agoNobody said it was a task only worthy of Hercules. Just that it is a royal pain, and Zig removes that pain. You asked "why zig?". That's your answer.
- flohofwoe 3y agoAnd then did you try the same on Linux and macOS? That's what the Zig toolchain gives you, it doesn't lock you into a specific OS.
- txdv 3y agoYeah, and zig solves that. Instead of installing, trying the right header files, you just untar 70mb and you are good to go.
- rcxdude 3y agoThere is a heck of a lot to be said for making it a painless process. Yes, you can cross compile C and C++. No, it is not at all simple to set up. I've used rust for projects for similar reasons: if I want to cross compile from windows to linux it is ridiculously less painful to compile pure rust than C or C++ (especially if I want to set up a new machine for it).