4 ms·
>Swift is an applications programming language where the runtime is non-optional (at least AFAICT) and memory is managed dynamically. No, it's optional if you
by JeffKilborn 11y ago
>Swift is an applications programming language where the runtime is non-optional (at least AFAICT) and memory is managed dynamically.
No, it's optional if you don't need to interact with Obj-C frameworks (ie. Cocoa). And memory is not managed dynamically. Swift uses ARC.
Like I said, I just don't see Rust sticking around for long. Swift will suck all the developers out of it since you'll be able to actually get a job programming in Swift.
- Manishearth 11y agoARC is dynamic memory management. Is the decision to run destructors in an if block at run time? If so, that's dynamic. Rust provides dynamic memory management too, but you aren't forced to use it and most use it for a few variables only. So far nothing I've seen about Swift tells me that it will be able to be used for things like Servo and other perf-critical applications. Yes, it might edge out Rust webdev, but not much more. "You cam get a job in swift" is largely due to its iOS backing. I'm not so sure how that's going to apply to other OSs especially if Cocoa and co aren't made open source.
- Gankro 11y agoAll destructors in Rust are also decided at runtime, fwiw. Even without any allocation or anything: let foo = Moves::new(); if condition { mem::drop(foo) } // should foo be dropped here? In practice many destructors can probably be scheduled statically at compile time.
- Manishearth 11y agoDynamic drop is something that will go away for all but the strange deferred-let case (It's not a language restriction). So that's okay.
- kibwen 11y agoWe'll need to see how useful Swift is without Cocoa (still waiting for details on what's actually being open-sourced), but GCD is a runtime component as well. And as Manish has said, ARC is dynamic memory management, just like shared_ptr in C++ and Rc in Rust, though pervasive and implicit. If you'd like to convince me that Swift is suitable as a systems programming language, then you'll first have to show me an example of Swift code that can be compiled into a standalone binary that can be called from C, and then describe how many features of the language and standard library this disables. After that you can demonstrate how to run Swift code on a memory-constrained platform that doesn't allow dynamic memory allocation whatsoever. If anything, Rust is the only modern language that's not threatened by Swift, by virtue of existing at a level of the stack that's so low as to be out of Swift's reach. I agree that Swift is going to be huge, but you're mistaken as to who its competitors are. :P
- Manishearth 11y agoC++14 isn't a modern language? Aw, you killed a dream there :P
- pcwalton 11y agoSwift is fully garbage-collected. Reference counting is a form of garbage collection. It's in a different space. (And I like Swift and think their development team is really cool.)