8 ms·
Dictionary and Set Improvements in Swift 4.0
- dandr01d 9y agoI really wish Apple would focus more on getting Xcode up to par. It's in a truly horrid state, both performance and feature-wise. Developing an Objective-C app is worlds ahead of Swift right now.
- hellofunk 9y agoAre you aware that Xcode 9 just shipped last week and is a major rewrite of much of the IDE? It's one of the largest updates in Xcode's history.
- pavlov 9y agoSounds like a great reason to stick with v8 for at least six months.
- sho_hn 9y agoSo ... any good?
- dep_b 9y agoThe only that truly annoyed me was that CMD+click doesn't work immediately anymore but conjures some kind of intermediary menu. Haven't figured out if there's a new keystroke for it, but I'm still doing too much work in Xcode 8. To me it was nothing but progress compared to 8 apart from that. Everything faster and better.
- jclardy 9y agoThere is a checkbox in Xcode preferences to change it back. Not sure where as I’m on mobile, but that annoyed me to no end till I found the option. I agree on faster and better, but still buggy. Autocomplete still regularly dies for me and requires a restart (of Xcode.)
- rockshassa 9y agoPreferences > Navigation > "Command Click on Code"
- nnd 9y agoIt's CMD+Control
- nteunh34nteu 9y agoThe new key command for it is right there in the menu when it pops up. If you select the first item to do what the old command did, it's literally just to the right of the command!
- dep_b 9y agoYeah....but muscle memory....
- hellofunk 9y agoI haven't used it much yet myself, but I did notice that one annoyance I had was fixed, regarding zooming the font onscreen.
- sgt 9y agoI've used it for a couple of days now. I've seen some issues with the Simulator but I think that's not strictly related to the IDE. As far as Xcode and the editor is concerned - it's extremely quick now. Functionally also better in terms of the code editor.
- deleted 9y ago[deleted]
- nodamage 9y agoXcode 9 has been a lot less stable for me compared to previous versions. It will lock-up multiple times per day during simple text editing tasks, with SourceKitService going bananas until I force quit it.
- indemnity 9y agoIt boggles the mind that they just can’t seem to fix SourceKitService for three versions now, it’s such a massive part of making the Xcode experience suck. It’s worse than no completion, you never know when it’s actually going to work. I guess it does do something though, for eating up all those cycles.
- imron 9y ago> it’s such a massive part of making the Xcode experience suck. This. Whenever my fans start spinning up, I head on over to Activity Monitor and sure enough SourceKitService is sitting at 120% CPU draining battery like nothing else. I probably kill the service between 5-10 times a day when using Xcode. I've found that disabling 'live issues' in preferences helps somewhat, at the expense of not getting live updates to errors as I'm typing, but SourceKitService will still go off the deepend - usually while adding stuff that will not yet compile because I haven't included the appropriate headers yet or am still refactoring/moving about code.
- ramensea 9y agoXCode 9 is unsurprisingly terrible for me. Between it and the Swift tool chain, they use over 10 gbs of memory and constantly using 100% of my CPU. XCode 9 seems like an improvement over 8 in some cases, but its way less stable, uses an insane amount of resources, and crashes more often.
- mmargerum 9y agoIt’s been so bad that I actually installed Jetbrains AppCode. It’s working great . I finally just bought the entire subscription since I already use IntelliJ, datagrip, gogland, and webstorm
- hellofunk 9y agoI really wish Swift could find a way to be useful on platforms other than Apple. I'd be willing to commit more to it if I could write truly portable code in it. It's got a good start on Linux, but Windows and Android would be cool too. Though Kotlin won out over Swift for Android (very similar languages but I like Swift a bit better there).
- pjmlp 9y agoAny language that wishes first class support on Android needs to support a painless way to interoperate with Java APIs on their compiler toolchain. Otherwise developers are going to have lots of pain manually writting JNI wrappers to 90% of Android APIs. Likewise on Windows with COM support.
- Stanleyc23 9y agolet's say android or windows adopted swift. I don't think that would eliminate the biggest learning curve of dealing with the frameworks. in my experience, learning UIKit stuff was way trickier than swift. I imagine the same experience developing for other OS'.
- dep_b 9y agoThe language definitely feels like it has matured as the change from 3.0 to 4.0 was pretty much painless. The big issue with programming in Swift is no longer swift itself but the libraries around it. A lot of the API's you use in day to day Cocoa programming are based on Objective-C and often stringly typed and not very compile safe. For example NSNotificationCenter, setting attributed strings, core data or fetching resources. Also the whole MVC ViewController lifecycle is full of optionals. A lot of people abandon using Storyboards just to have ViewControllers that have everything set up compile safe, don't use prepareForSegue to pass in variables and so on. But that means doing everything in code, which is inefficient for complicated one-off layouts.
- favorited 9y agoAttributed Strings got better type information in Swift 4 (it got what Notification keys got in Swift 3), but like notifications it's an open-ended API so I don't know what else you can do... You can't use an enum for the keys because it supports custom attributes (at least you can't without exposing a `.custom(name: String)` case, which would defeat the purpose). And the values can be different types (enums for underline styles, URLs for links, [NS|UI]Color for foreground colors, etc.). I think the `NSAttributedStringKey` box type is a good compromise. Maybe I'm biased (the Cocoa text system is one of my favorite APIs, and NSAttributedString is at the top), but I'm really happy with the state of attributed strings in Swift 4 myself.
- dep_b 9y agoTrue, but that's exactly the kind of change to the API required to make it more compile-safe. I still managed to crash this API by not providing a .rawValue somewhere. I don't think applications need to crash on key-value errors. An enum wouldn't be so bad if it also would use the associated value. Would make it impossible to set the wrong value at least.
- favorited 9y agoAhh right, NSUnderlineStyle... I totally thought that was improved in Swift 4, what a bummer. I have some unit tests in my apps that make sure I'm setting the .rawValue instead of the enum case itself, because that one does suck. I'm gonna file a bug.
- potlee 9y agoSome nice improvements but could have really used a syntax for anonymous functions that makes. Why did they choose this wierd { parameter in doSomething(parameter) } syntax?
- thedjinn 9y agoLooks fine to me. What's wrong about that syntax?
- BillinghamJ 9y agoWell, for starters, what does it mean? I haven’t seen that in any other language.
- pjmlp 9y agoIt is similar to let var=..... in exp from ML languages.
- sizeofchar 9y agoHaskell have let-in expressions, I think it is the inspiration for swift in this case.
- Groxx 9y agoFeels backwards to me, at least as a gut feel. groceriesByDepartment.mapValues { items in items.count } vs e.g. Ruby (or at least close, it has been a while): groceriesByDepartment.map { |item| item.count } The "in" makes it feel like you're calling "items.count" on...? and then getting the "items" from it (since it sorta implies that items are in items.count, which seems like nonsense). E.g. this reads more naturally to me: groceriesByDepartment.mapValues { item.count in item } otherStuff.do { a.value + b.value in a, b } which would also move the "what it does" further to the left, rather than having to skip over the argument names (which are frequently obvious in context, and/or something trivial like "it" or "item" or "x"). --- That said, if you consider it as "use 'items' in [a block of code]" it basically makes sense, and I could probably learn to stop worrying, and love the syntax.
- pbarnes_1 9y agoPlease give us concurrent collections.
- azinman2 9y agoThe emojis are cute in this description of language changes, but I’m worried some programming newbies will look at this as an example of “pros” / Apple endorsing it and will start using them in real programs.
- edejong 9y agoWhy stop at identifiers when you can have C++ #defines? http://lallouslab.net/tag/emoji/ http://lallouslab.net/tag/emoji/
- mikestew 9y agoOne of the many reasons you have code reviews. A formal review isn’t even necessary, since the first time anyone but the author sees the code, the ensuing ridicule will ensure that it never happens again. OTOH, one of things hammered into me at Microsoft was “sample code becomes production code”.
- bsaul 9y agoI was a bit disappointed at the string api in swift4 recently. They removed the need to access characters every time, but they kept the Index type, which adds an intermediate step every time you want to build a range, without providing any more safety than just using integers: it still crashes on index out of bounds, so you still need to manually bound check, only you have to compare to startIndex and endIndex. I still don’t get the benefit..