4 ms·
The code snippet in this rant makes it pretty clear that it was programmer error. You took an obviously-optional value, forced-unwrapped it with no checking at
by makecheck 9y ago
The code snippet in this rant makes it pretty clear that it was programmer error. You took an obviously-optional value, forced-unwrapped it with no checking at all, then blame the language for this!?
- mpweiher 9y agoThat's Swift: turning benign non-errors into crashing programmer errors. "!" is a language mis-feature. As is crashing on potentially every arithmetic operation.
- kartickv 9y agoI knew it wouldn't be long before someone dismissed it as programmer error. But that's the whole promise of static typing — preventing programmer errors from causing runtime crashes. In this case, static typing failed at its task.
- makecheck 9y agoNo. "Static typing" means that the runtime type is known at compile time, and it was known: it was presented as being either a valid object or nil. The behavior was consistent with the two possibilities that were "promised" by the compiler. When your program overrides with "!", you are disabling the language's protections. You really can't blame the type system for failing to complain about something that you told it not to check!