156 points · by tambourine_man · 3y ago · 70 comments
"Introducing a Memory-Safe Successor Language in Large C++ Code Bases"
"Emergency recovery can be handled by a supervisor process" - this sounds a lot like Elixir to me, but I can't find any example in Swift.
Also, https://github.com/swiftwasm shows how the modularity pays off. Comparing it to the other languages that got stuck with incompatible frame conversion (Golang) or JIT memory management problems (JVM) it's not bad at all.
swift-foundation is the newest and most likely the future. However, it's unclear when or if it will ever be production ready. Apple doesn't appear to be dedicating that much engineering effort towards it right now.
I agree with you the various forks are confusing, but disagree that Apple isn’t putting effort towards the new one - it was only announced earlier this year, and is looking like it will be ready for WWDC is 2024. Which, given the sheer scope of the project (completely rewriting everything from the ground up in Swift), would be quite a fast turnaround time.
You're absolutely right, because the Swift Standard Library is a separate thing. It contains only the absolute essentials such as Int, String or Array:
https://developer.apple.com/documentation/swift/swift-standa...
Is that why they're splitting the newer one into further SPM modules? There seems to be "FoundationEssentials" listed in that package.
> but disagree that Apple isn’t putting effort towards the new one - it was only announced earlier this year, and is looking like it will be ready for WWDC is 2024
Oh, interesting, where did you find this information? I follow the project on Github and got the impression it had slowed down since its announcement.
And while it’s syntactically similar to Swift, I find it to be overall less ergonomic in various ways.
.. seems heavy handed..
May have something to do with Swift’s original author.
llvm is probably one of the most important inventions in decades.
""" SWIFT stands for the Society for Worldwide Interbank Financial Telecommunication. It is a global messaging network used by banks and financial institutions to securely and efficiently exchange information, particularly for international money transfers and transactions. SWIFT codes are used to identify banks and facilitate the transfer of funds between them. It plays a crucial role in international banking and financial communication. """
I didn't know SWIFT was involved at all in crypto stuff, at least not directly. I guess finance is the world's most interconnected network, however, so I shouldn't be too surprised.
SWIFT’s relevance to cryptocurrency is most likely the cryptocurrency community’s aspirations of creating an alternate method for transferring wealth that is not limited by international borders or implicitly required to respect international sanctions. Legally, citizens in countries respecting the international law can still be liable for violating sanctions regardless of the method they use to transfer assets, so I don’t completely understand the how cryptocurrency is a superior way to launder money when the transactions occur on a public block chain.
The flip side though is that once you have to build a raw C API/ABI for your shared object written in Rust, it becomes usable with any other language that has good FFI with C, which is most of them.
Swift's approach is that you only need to provide a header (which you likely already have), and the compiler does all the rest to handle the bridging for you. cxx.rs' approach is that you use this crate to write a bridging file and so long as you follow the type set that cxx.rs understands you have a bridge (int, char, std::string, std::unique_ptr etc).
They're both good approaches but the Swift approach is definitely much more ambitious and more user-friendly to the programmer.
So far that doesn't seem to have really happened and in the meantime I've switched to Typescript and more recently Dart (for Flutter), which currently both have much better cross platform stories.
Interoperable means a lot even inside Apple ecosystem, bringing all those C, Objective-C and now C++ code with ease into Swift projects.
Using Metal from Swift, althought implemented in Objective-C and C++, is already a productivity boost compared to anything that Microsoft has ever produced for .NET in regards to DirectX, not even XNA.
I think for mobile apps Flutter is a better tech stack than React Native though and can survive if Google doesn’t give up on it.
I have projects using Swift on AWS Lambda and on Arduino.
* https://github.com/swift-server/swift-aws-lambda-runtime
And it turns out...
"Instead, Swift embeds a copy of clang, the C and C++ compiler,"
...well gosh, you can brute force "interoperability" by simply creating the union of all the languages you "interoperate" with.
https://www.youtube.com/watch?v=XqUgUgiToNs
"The F4 Phantom, America's proof to the world that with a big enough engine, even a brick can fly"
Would you recommend they wait for some weird Java-esque 100% Pure implementation within the compiler itself before they can begin that work?
The ideal you’re suggesting is actually made more reachable by this work. One can imagine a Swift LLVM/Clang now.
That’s not what they do. To efficiently use C and C++ structs and classes from another language you have to know their layout and calling conventions.
With C and C++, you have to run the preprocessor and (e.g. for C++ templates) large parts of the compiler to reliably do that. How else are you going to figure out what foo_t and bar_t in header files mean?
If you need to run a compiler, using an existing compiler is the wise thing to do.
Processing C and C++ header files means using a C/C++ compiler. It would hardly make sense to write a new one if there was a good one already available.
> Instead, Swift embeds a copy of clang, the C and C++ compiler...
Ah... interoperability through a non-swappable fork of a behemoth piece of software just for your project. I don't see what could go wrong?