4 ms·
Slight derail but I find it interesting that the Swift team is tackling the fragile ABI problem with v3... Something C++ could have done at any time, enabling p
by xenadu02 11y ago
Slight derail but I find it interesting that the Swift team is tackling the fragile ABI problem with v3... Something C++ could have done at any time, enabling portable and interoperable C++ interfaces.
(There's no reason clang importer couldn't surface C++ or any other language to Swift for that matter)
- saurik 11y agoYeah. As much as I absolutely love C++11, and use its features constantly, if I had to make the hard call: "do I get lambdas, or do I get some extern ABI marker I can use to opt-in to a non-fragile ABI, with field and vtable offsets linked as symbols and return types mangled into function names", I would have made the (incredibly depressing) choice for the latter, as it makes C++ suddenly able to be used in ways that are otherwise insane to contemplate.
- rayiner 11y agoEven if you can easily parse C++,[1] there are a lot of practical impediments to binding to C++ libraries. If an API exposes templates, or relies on constructors/destructors, it's very hard to call that from non-C++ code. For example, SpiderMonkey wraps JS pointers in C++ objects and uses RAII to register roots being held by C++ code with the JS garbage collector. Handy, but more or less impossible to call from non-C++ code without writing a shim by hand. [1] You young-uns and your Clang. I did a C++ binding generator for my GSoC project, and back then ('05) GCC was the only open-source thing that could parse C++, and you could only get at the parse tree by patching it to dump XML.
- X-Istence 11y agoClang and LLVM could have been a GCC project instead, but Stallman decided against it. Also, the reason you could only get the AST as a XML dump was because of the same shortsighted mindset.
- vetinari 11y agoStallman also had a reason for that. If he wouldn't insist on respecting GPL for GCC, there would be no GPL licensed Objective-C compiler, because Jobs would simply never free-source it.
- X-Istence 11y agoExcept that clang is free, under a completely open license, which completely and utterly negates your second sentence.
- rayiner 11y agoSwift was unfree until recently. That couldn't have happened with GCC.
- netheril96 11y agoSwift probably would never exist, much less free, if LLVM were not a thing and GCC were the only choice.
- vetinari 11y agoExcept that at the time Jobs fought FSF, so he wouldn't need to open the ObjC sources. He lost that fight. It's called knowing history. Just because two decades later Apple decided to fund open-licensed clang does not negate my second sentence. Clang was no longer considered competitive advantage, like ObjC was at the beginning of 90s.
- nly 11y ago> Something C++ could have done at any time It could have, but a standardised ABI is a terrible idea. Once you commit to an ABI you're stuck with the tradeoffs you make. If C++ had specified a stable ABI 20 years ago, we'd all be using setjmp and longjmp for exceptions, and small string optimisations and such would be impossible. I don't really see the big deal tbh. C++ code compiled with GCC was ABI stable between GCC 3.4 (Apr 2004) and GCC 4.9 (Apr 2014), and you can still use use the -fabi-version switch today to generate code against older ABIs. Hell, libstdc++v5 (shipped with GCC 3.3) is still packaged for most distributions.