News for hackers. Stuff that matters.
Re:Objective-Rust by smabie on Friday August 28, 2020 @10:11PM (#24312706)
Apps don't need to be in Rust. And maybe they even shouldn't be programmed in Rust.

If your application or backend or whatever can tolerate GC, I would strongly recommend that you use it. While Rust has made manual memory management easier than either C++ or C, it still requires more work than a GC'd language.

Rust has a lot of things going for it, but this obsession with writing everything in Rust that has taken HN by storm is a little confusing.

Swift is unequivocally a higher-level language than Rust and definitely should be used for iOS development unless you have a very good reason to use Rust.

Re:Objective-Rust by zozbot234 on Saturday August 29, 2020 @12:57AM (#24313678)
Swift does not do cycle-collecting GC, either. Not really any "higher-level" than Rust, when you look at a comprehensive view of the problem space. And obligate ARC ala Swift has all kinds of performance pitfalls, to the point where it can be even worse than obligate tracing GC.
Re:Objective-Rust by jmull on Saturday August 29, 2020 @09:21AM (#24315877)
Yes. It might help to can think of it this way:

Rust, with the borrow-checker, strong-arms the developer into using memory patterns that the compiler manage handle without the overhead of reference counting or other runtime mechanism.

Those same memory patterns are available in Swift as well, which the compiler can then optimize as well (in theory -- as far as I'm aware there are various unimplemented optimization opportunities in Swift).

So in a sense, in Swift you can opt-in or out of rust-level memory management.

Of course, a big difference is that Rust tells you up-front when you've got it right, but in Swift it's not at all clear. You need to profile. Swift does have a clear delineation between reference types (which use ARC) and values types, so you can get on the right path by choosing value types. Value types in Swift are very rich and powerful so it's not a hard path to follow.

Re:Objective-Rust by smabie on Saturday August 29, 2020 @03:47AM (#24314462)
ARC is GC, and anyone who says otherwise is crazy.
Re:Objective-Rust by saagarjha on Saturday August 29, 2020 @05:45AM (#24314949)
Usually on Apple’s platforms ARC and GC are treated separately because Objective-C has shipped with a conventional garbage collector as well as reference counting and it’s difficult to tell them apart otherwise.
Re:Objective-Rust by drran on Saturday August 29, 2020 @03:27AM (#24314375)
Swift language by definition is at the same level as Rust. "Higher Level" means that developer is order of magnitude more productive in language X than in language Y. This is not a case for Swift vs Rust.
Re:Objective-Rust by pornel on Saturday August 29, 2020 @07:46AM (#24315419)
Swift does implicit allocations, doesn't have explicit monomorphisation, requires a non-trivial runtime. Language functionality like ARC and ivars compiles to a lot of "magic" (compared to Rust's focus on zero-cost abstractions). Swift's standard library is full of dynamic dispatch (e.g. Swift strings are a collection of classes with abstracted-away and variable in-memory representation. Rust's strings are dumb pointer+length).

Swift is much higher-level than Rust. It's at best at Go's level. You'd expect Swift's performance to be good, but in low-level tasks Swift is actually closer to JS/TypeScript than anything else: https://github.com/ixy-languages/ixy-languages

Re:Objective-Rust by jmull on Saturday August 29, 2020 @09:35AM (#24315966)
I'd be careful about drawing general conclusions from https://github.com/ixy-languages/ixy-languages

It's using some non-optimal patterns that you would not normally use in Swift for code if you wanted it to perform well. (There's a nice performance analysis if you click in, showing that it's using ARC in an inner loop, which is taking 3/4th of the time. That's not something you need to do.)