Live data from Hacker News

Oops, I Wrote a C++ Compiler

praeclarum.org

41–42 of 42 posts

Re: Oops, I Wrote a C++ Compiler

#42
post #12
post #6

Earlier quoted context omitted.

It is very well explained? GCC and Clang would be nightmares to integrate into an app that runs on many platforms including iOS, and even once you did, you'd still need to implement an interpreter, because you're not allowed to JIT on the app store. Compiling a toolchain for a desktop platform is easy. Cross compiling a toolchain is moderately easy. But embedding a toolchain into an iOS app, where you have to get it…

For Clang/LLVM, it wouldn’t be that hard. It’s one source tree to build (Clang is in a separate repo from LLVM core, but you check it out into a specific subdirectory and they build together), all C++, no external dependencies, and the result is a set of static libraries you can easily link into an iOS app. As for interpreting — there are a few options. The simplest approach would be to use LLVM‘s built-in IR interpr…

Honestly, Clang does seem like it would be pretty easy to embed in comparison. They do mention their app is written in C#, and integrating C++ code with it on every platform may carry its own challenges. I know it's relatively easy to do with desktop platforms with Mono and Microsoft .NET just using normal PInvoke, but have no idea about iOS; code signing looks complicated on iOS, though I'm sure you know it inside and out. Either way... yeah, if you consider Clang, it really does appear like a waste of time to write your own C++ compiler, even for just a subset.
Post reply on HN