by nicoburns · 9mo ago · 0 comments
Rust? Rust is basically a simpler Swift. The objective-c bindings are really nice too, and when you're working with obj-c you don't have have worry about lifetimes too much, because you can lean on the objective-c runtime's reference counting.
I think the way to think about it is that with Rust, it's as if all the goodness in Swift was implemented with in the "C" level, and the Objective-C but is still just library-level a runtime layer on top. Whereas Swift brings it's own runtime which greatly complicates things.
I get that there's a tradeoff. Rust requires you to be way more explicit about what you're intending upfront and that can, in the long term, lead to simpler code -- but there's no dimension (depth-wise or breadth-wise) that I'd call Rust simpler.
Swift already does have those things but unlike Rust, they are opt-in.
Not going to argue which language is simpler, but sorry, you don't seem like someone who knows Swift very well.
Swift is a nice language, and it's new support for the bare necessity of affine types is a good step forward, but it's not at all comparable with Rust.
* automated exclusivity with value types and value witness tables, classes as arc types (ie Arc<Mutex<T>>)
* automated interop with C/C++/Obj-C through the clang ast importer
Maybe they could have started with rust and added on what they needed, but why not build a new language at that point where things so fundamental are involved?
Source: I worked in lattners org at the time of swifts inception (on an unrelated backend) but that was the motivation. I also worked on the swift compiler for a little bit some years later on in my career.
Unlikely, I think, because of timelines. Swift’s first public release was in June 2014. Rust is a few years older (first public release in January 2012), but that wasn’t the rust we have today. It still had garbage collection, for example (https://en.wikipedia.org/wiki/Rust_(programming_language)#20...)
Since 1993, I only have used C when required to do for various reasons out of my control, or catching up with WG14 standards.
#include <print>
#include <map>
#include <string>
int main(int argc, char** argv)
{
using namespace std::literals;
std::string foo = "foo:";
foo += argv[0];
std::map<std::string, int> m{
{foo, 123}
, {"count: "s + std::to_string(argc), 456}
};
std::println("{}", m);
}
in C import std;
int main(int argc, char** argv)
{
using namespace std::literals;
auto foo = "foo:"s;
foo += argv[0];
std::map<std::string, int> m{
{foo, 123}
, {"count: "s + std::to_string(argc), 456}
};
std::println("{}", m);
}* rvalue references
* the difference between auto, decltype, typeof
* unreadable template monstrosities
* various different flavors of "smart" pointer
* the continued existence of footguns relating to UB, dangling pointers, unexpected temporary lifetimes, etc
* total absence of a build system or package management
* legacy APIs that still take raw pointers
* concepts, a half-assed attempt at generic constraints