4 ms·
Lots of misunderstanding of how optionals are designed to work in this comment!
by tommymachine 7y ago
Lots of misunderstanding of how optionals are designed to work in this comment!
- hu3 7y agoIs it only the developers fault when critical parts of a programming language are hard to grasp? I suspect that might be a sympton of excessive complexity and parent's example of C++ seems spot on.
- mamcx 7y agoBut optional is very simple concept. However, break from the old habits is hard. I was there moving to f# and the first month or so I try to bend the rules. Same now with rust. I try to mold it as a OO language, and get SUPER annoyed with how rust is so different. But you embrace algebraic types and pattern matching and suddenly a lot of other hidden problem simple disappear forever.
- kitsunesoba 7y agoProper optional use is indeed a habitual thing. When I was first transitioning from ObjC to Swift I found them to be an annoyance, but after using Swift for the past few years I find myself wondering how my ObjC code ever ran as well as it did without them. I’m now reluctant to use languages that lack option types.
- eyerishcoffee 7y agoWhether there is misunderstanding by the grandparent post or not, in practice there are a lot of people who do just play with ?/! until they manage to get code to compile and then hope for the best. You can see it all over the place in code people write, posts on Stack Overflow, etc. The Apple Swift book does a poor job explaining the rationale and benefit of using option types.
- christoph 7y agoGenuine question - does this not highlight a problem with the language on some level?
- shaggyfrog 7y agoIf a developer is just fiddling with optional-related operators until the compiler is happy -- in any language, not just Swift, e.g. Kotlin -- instead of actually understanding what they are doing at any fundamental level, that's not a language problem. I wouldn't want to work with someone like that I doubt anyone else would, either.
- geofft 7y agoI would believe it's an education problem, in that we teach things like recursion and local variables (the fact that the same variable can have different values in a nested call to a function) in intro CS classes but we don't really teach how post-NULL languages handle optionals (Option, Maybe, etc.). But it's something that should be part of an effective programmer's knowledge. It's not too unlike buffer overflows—all the people writing UNIX until 1988 were skilled, educated, experienced people, but at the time none of them were really aware just how bad buffer overflows were.
- shaggyfrog 7y agoI never learned those in university, so I don’t think that’s a sufficient excuse. Any developer should understand, or want to understand, the fundamentals of the language they are using.
- millstone 7y agoIt highlights some of challenges of bridging Swift with ObjC APIs.
- kitsunesoba 7y agoFully Swifty UIKit or whatever it is that eventually replaces UIKit can’t come soon enough. As Swift has matured, UIKit/AppKit has quickly become the weakest link in the Apple platform dev experience.