6 ms·
Swift has way too many shorthand syntaxes. It feels nice from a language design perspective but when teaching Swift, you can see how confusing it is for the stu
by msoad 5y ago
Swift has way too many shorthand syntaxes. It feels nice from a language design perspective but when teaching Swift, you can see how confusing it is for the students. In larger codebases a lot of shorthands are forbidden by the organizations for consistency. So I'm not sure who's the real beneficiary for all those shorthands?
- bsaul 5y agoi think there's a growing concern about the language complexity. I hope next releases are going to be about trimming down the language, and consolidating the not-so-sexy but very important other aspects (multiplatform, compilation speed, spm, tooling, etc) following golang's example.
- deleted 5y ago[deleted]
- diskzero 5y agoThe shorthands mystify me as well. I have taught a few courses using Swift and the shorthand notation, as well as implicit variables like oldValue and newValue in setters, are confusing. You can try to ignore them, but eventually a student will find them. In my experience, teaching courses using Racket have had better outcomes. At the end of the Racket courses, I can quickly transition students to other languages, including Swift. It hasn't worked out so well with Swift. I am still gathering data so I can come to a better conclusion as to why.
- throwdecro 5y ago> Swift has way too man shorthand syntaxes. It feels nice from a language design perspective but when teaching Swift, you can see how confusing it is for the students. 100% agree. As a late adopter of Swift, I spent a lot of time looking at code that was so stingy with information that it was challenging to even formulate a Google-able question from it.
- SV_BubbleTime 5y ago> So I'm not sure who's the real beneficiary for all those shorthands? Coffee shop and college project app developers who are chasing the cool (be it tricks or frameworks). That’s not a knock, but that’s who I see using these things. We were hiring a guy for a Flutter app that had no previous experience in Dart, but turned us down because Dart lacked some whiz bang feature he had too grown accustomed to. I did not see this as a loss.
- skavi 5y agoCould I ask what feature they were looking for? I haven't used Flutter in a while, but it left a good impression. I remember being far less annoyed using Flutter than I am using other declarative frameworks like SwiftUI.
- SV_BubbleTime 5y agoI’m an embedded C guy, so you’ll have to forgive my ignorance on this. All this high level stuff is magic to me. But I want to say it was something larger than a conditional style or pattern matching and probably a state management framework. IDK, I had a good laugh about it and moved on. EDIT: As to good impression, yes, we’re very happy with Flutter.
- kyralis 5y agoVery much this. The original discussions around Swift talked about the value of being explicit rather than implicit and reducing surface area (for instance, no ++/-- increment/decrement operators). That goal appears to have been completely lost recently.
- bsaul 5y agoMy impression following swift forums is that original core team members were very concerned about relying a lot on first principles, whereas the new generation is more about building powerful constructs, in a fast paced way.
- selcuka 5y agoThe new generation doesn't seem to have a need for extracting substrings from strings then. The existing Swift syntax for slicing strings [1] is horrible. [1] https://www.cocoaphile.com/posts/string-slicing-in-swift https://www.cocoaphile.com/posts/string-slicing-in-swift
- kitten_mittens_ 5y agoThis is a product of UTF-8 encoding, isn’t it? What’s the third index of “Füß”?
- selcuka 5y agoThere is no reason they can't come up with a more readable API that works. Python says it's 'ß' and I'm fine with it as long as it's consistent: >>> "Füß"[2] 'ß'
- bsaul 5y agoYou can find a few extensions on stackoverflow that makes subscripting work with integers on strings. I'm still unsure why this isn't part of the stdlib..
- fingerlocks 5y ago