3 ms·
> Like, could I have a traditionally C++ app (Qt app) but have most of my code be in another LLVM-compatible language It is possible! I mix Swift and Rust in m
by ratww 6y ago
> Like, could I have a traditionally C++ app (Qt app) but have most of my code be in another LLVM-compatible language
It is possible! I mix Swift and Rust in my day job. I use the C ABI to interface between the two. The Swift layer is very thin and pretty much just a bridge between Rust and Cocoa/UIKit/Metal, but there's nothing stopping you from doing the opposite.
If you're going to bridge Swift with Qt, the sanest way is to use Objective-C++ to wrap Qt calls and call it from Swift.
However keep in mind that the Swift experience in other Operating Systems might not be as good as in Macs. That's why I went with Rust for this project. But things might have changed in the meantime!
- hajimemash 6y agoThat sounds really cool. I did some searching to see people's experiences substituting other languages for C++ through LLVM, and didn't find much other than samples of translated calls. Given that there would be a big benefit to this (not having to learn a new language, less manual memory management), are there good reasons this isn't way more common?
- ratww 6y agoI thought it was pretty common? If you use the C ABI you can just link a bunch of object files together. Rust people are doing it a lot for graphics/game stuff, and there's lots of production MacOS apps mixing ObjC/Swift (because they're transitioning), or consuming C/C++. Of course in this case it's mostly Xcode doing the magic, but behind the scenes it's just calling clang.