4 ms·
It's been a while, but the one I remember with the most horror was dealing with Enums, and Enum payloads. Since Swift is statically-typed, many 'type union' sit
by thomassmith65 9mo ago
It's been a while, but the one I remember with the most horror was dealing with Enums, and Enum payloads. Since Swift is statically-typed, many 'type union' situations end up becoming difficult problems. The question usually boils down to thinking about choosing one of (a) Enum with Payload (b) Generic (c) Type erasure. Nearly anything technically is do-able, but I wasted many hours (ie: repeatedly, not until I figured out the 'right way' for every situation) deliberating over how!
- saagarjha 9mo agoLow level languages don’t even have those features.
- thomassmith65 9mo agoI didn't mean to suggest they do! When I used Swift, I frequently was surprised to find some simple part of a program actually required me to sit and plan for several hours. The exhausting amount of mental energy is the only part that reminds me of coding in Assembly.
- saagarjha 9mo agoI guess my perspective is that I usually have to plan out my programs regardless of what language they’re in so I don’t really view it as being similar?
- thomassmith65 9mo agoThat is a different issue than this: I frequently was surprised to find some simple part of a program actually required me to sit and plan for several hours. It's perfectly normal in programming to encounter domain problems that take longer than one predicted, or to plan ahead with pseudo code, proofs of concept, class diagrams, etc. What is abnormal is, over and over again, to find oneself utterly stumped on how best to implement something very basic. At least, it's abnormal when using a high-level language.
- whatis991 9mo agoI am not sure that I understand you correctly, and I find the subject interesting. Is it what the enum abstraction can model easily that is the issue? If so, I believe the Rust community has similar issues regarding error handling. There are multiple libraries like thiserror and anyhow. https://old.reddit.com/r/rust/comments/1mexsqr/the_way_rust_crates_tend_to_have_a_single_huge/ https://old.reddit.com/r/rust/comments/1mexsqr/the_way_rust_... https://old.reddit.com/r/rust/comments/1q3wb3l/stop_forwarding_errors_start_designing_them/ https://old.reddit.com/r/rust/comments/1q3wb3l/stop_forwardi...