Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
It’s safe compared to most other languages.
I have a decent knowledge about it and if you like we can talk about the topics that you mentioned.
1. unwrapping is explicit and safer than implicit in java and c# for example.
2. this is uikit and storyboard, remnant of objc, not swift's fault.
3. fair. Reason is to avoid performance penalties.
4. that‘s not possible. Where did you get this one from?
5. not really sure about that but afaik not a problem of swift but the host runtime.
6. seriously? Swift has the best and most safe threading stuff. Other languages don’t even have actors.
7. well, what should happen on invalid type casts? Fatal error is the most safe approach. And you can do safe type conversions which evaluate to nil.
8. huh? Like what?
Also not sure what you mean with failed allocations. Swift has RAII and even failable initializers, which makes it more safe than any other language that I know in therms of allocation. -
@Lensflare how about the basics. When Swift fails to allocate memory, there is nothing to check, not like a null pointer to check or even a 1984 (OSError) MemError(void) function to call… things just go sideways; software crashes.
Accordingly it doesn’t sound like a good idea to use Swift in things like automobile software, medical ventilators, X-ray machines, CT scanners, aircraft software, navy ship software, nuclear missile software, drones, SpaceX rockets, and so on. -
@xcodesucks I literally never have encountered such a case. Can you give me an example? Does it happen when there is not enough space available?
-
To be fair, none of these issues are "unsafe". Crashing the program is fully memory safe
...probably not what you want, but at least not a vulnerability which can lead to exploitation -
"can't crash" isn't what "safe" means in common parlance with regard to language design because of the halting problem.
Related Rants
Swift: Have you ever noticed...
How many times the word "Safe" is used when describing Swift, yet there is no way to programmatically determine if a memory allocation failed?
How many ways this "Safe" system has a way of crashing:
1. Unwrapping a Nil Optional
2. Disconnected Outlets
3. Out-of-Range Array Access
4. Accessing Uninitialized Variables
5. EXC_BAD_ACCESS (Memory Access Errors)
6. Threading and Actor Isolation Issues
7. Type Casting Errors
8. Uncaught Language Exceptions
9. (fill in the blank?)
What frustrates me is that Swift lacks a language-level way to check if heap memory allocation succeeded. When you create an object like MyClass(), Swift assumes success—if allocation fails, the process dies instead of allowing your code to gracefully handle the failure.
And to avoid having pointers, it creates this horrendously random undocumenting syntax salad that is worse than ADA.
Swift, when you wanted a liter-bike and you get something else
rant
swift