Interoperability: Swift’s Super Power
browsercompany.substack.com
browsercompany.substack.com
"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.
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.
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...
How exactly do you consider it a big disadvantage?
Maybe things have changed in the last few years but - having to ship a huge file tree alongside the actual binary (or binaries because JARs are also a nightmare), and the slow startup time due to the need to interpret/compile bytecode instead of just running machine code, make Java really unpleasant to use in many common use cases.
Also the Startup depends on how much memory you allocate, but much of it is due to verifying class security, a feature that other runtimes don't even have. Or badly used reflection, another feature others don't have.
In any case I really never found it an issue if a server takes 3 seconds to start and I never understood why people complained about Java startup. My guess is they complain about clunky desktop application with a million classes written in it.
Regarding the bytecode: the interpretation and just in time recompilation gives Java sometimes better than native performance.
It also allows you to hook into the code on the fly and transform it with agents. Can native do that?
In any case, if Java works for you then that’s great. I’m just relating my own experience, where I found that the need for a JVM was less of a blessing than a curse.
As a former C developer who has been using Java for 20+ years, moving to Go was like lifting a weight off my shoulders. (I suspect I’d have felt the same with Rust, Swift or any other modern AOT language). It’s so refreshing to just have a binary, and be able to execute it, and not worry about a pile of irrelevant external factors.
Any company building their business on flutter is setting themselves up for disaster and an expensive double-rewrite to native, while having a useless engineering team because they skilled up previously mentioned dead-end.
I’m relatively confident that they used a device frame around their actual screenshots, which leads back to those issues you mentioned. You can tell that they’ve used different device frames in their current store listings compared to the realistic looking ones on the aforementioned Flutter showcase page.
This whole process can even be automated. I’m talking about a CI/CD workflow that takes screenshots of specific pages, and adding device frames around them etc. See this tool for example: https://docs.fastlane.tools/actions/frameit/
And while it’s syntactically similar to Swift, I find it to be overall less ergonomic in various ways.
Further as others have mentioned Java's 6 month release cycle and ton of changes at language/VM/library layers will make it difficult for Kotlin to choose between complying to latest JVM or chart an independent path.
Which is also the reason why kotlin is so popular there. Using extensions function and concise syntax you can build clutches around this terrible abomination of an SDK.
.. 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.
If you failed to make Swift + Metal perform better than JavaScript, there is something really horrible with your code.
The code I ported wasn't Swift+Metal, it was just Swift. It certainly wasn't optimized in any way, but the Javascript one wasn't either. Javascript data structures are just faster, because they are fully imperative, the Swift ones are more expensive, despite some copy-on-write tricks. And remember, carefully written Javascript is just as fast as C.
V8 JIT is hardly as fast as C, almost there yeah, there is still a speed bump.
For many many things, you won't, and then the ability to target Apple/Windows/Linux with exactly the same code, pain-free GPU access etc, that's just great. The other day I checked if I can access from the browser the 3D coordinates of my space mouse, and it just works, based on a standard Web API (GamePad API). While from Swift, it would be a hassle to setup and maintain.
But that was for 'js library backed by C++' shaped cases whereas for performance critical app-specific code you probably want 'C++ library that presents a JS interface at the top level.'
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.
Another big "no" factor with Flutter for me is that it's its own ecosystem and language; React Native ties in with the greater React ecosystem and the even greater Node ecosystem, which gives you a lot of libraries, code examples, maintenance and improvements. Second, hiring is a major factor. You can assign most current-day web developers onto a RN project with little problems, whereas Flutter is a new language and skill set.
I always found RN very easy to get started with but over time as features get added and dependencies evolve RN apps become increasingly difficult to update and maintain.
Also React is one of those easy to learn but difficult to master technologies. I’ve interviewed a lot of people claiming to know React that I wouldn’t trust to build anything complex. There are just so many footguns.
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.
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.
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.
> 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?