Earlier quoted context omitted.
Feels 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 naturall…
I prefer Ruby's syntax too, but Swift also has a shorthand version which is, IMO, usually nicer. groceriesByDepartment.mapValues { $0.count }
Dictionary and Set Improvements in Swift 4.0
61–70 of 71 posts
Re: Dictionary and Set Improvements in Swift 4.0
#62I still don’t get the benefit..
Re: Dictionary and Set Improvements in Swift 4.0
#63Earlier quoted context omitted.
I prefer Ruby's syntax too, but Swift also has a shorthand version which is, IMO, usually nicer. groceriesByDepartment.mapValues { $0.count }
The shorthand version doesn‘t let you specify argumen types (only works when they can be inferred)
Re: Dictionary and Set Improvements in Swift 4.0
#64The 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.
Re: Dictionary and Set Improvements in Swift 4.0
#65The 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…
Storyboards kind of suck for any team bigger than 1 as far as I’m concerned. They also lock you into a visual binding style development pattern the doesn’t scale as your app grows. Don’t get me wrong, they’re great for fast prototyping or teaching someone how to write code as it helps with a ton of boilerplate.
The following things should be improved to make storyboards more useful in teams:
* No more bullshit changes of 0.5px just by looking at the storyboard alone
* Compile time check for connected outlets and actions, allowing to set them without the ! or ?
* Constructable view controllers that always require you to init them in some kind of way, so you don't end up with optionals everywhere
* Reusable constants for colors, sizes etcetera. I want to simply state cellSpacing as a value for the constant of a constraint where cellSpacing is something I can change in one place.
* Reusable components / controls, like .xibs but immediately visible
* Less flaky IBDesignable performance
Re: Dictionary and Set Improvements in Swift 4.0
#66I 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).
https://github.com/apple/swift/blob/master/docs/Android.md This is a good start, at least for Android hardware..
Re: Dictionary and Set Improvements in Swift 4.0
#67Earlier quoted context omitted.
I wish Rust had such fantastic support you claim. There is no support for integrated debugging, across languages on Android Studio and Visual Studio. No support for COM or UWP and Win32 is WIP. Not sure how much NDK APIs are actually wrapped.
I hate to be a bit blunt but you're really barking up the wrong tree. VSCode debugger works fine on both msvc and mingw targets. Asking for COM or UWP is like saying that Javascript has a horrible interop story with COM/UWP. You're picking Rust to build something fast and/or low memory. Leave building a UI to the right tools. C# has a fantastic FFI and works just fine with Rust. I actually have a project using UWP an…
Picking up your example,how do you expose and debug UWP components?
Re: Dictionary and Set Improvements in Swift 4.0
#68Earlier quoted context omitted.
I wish Rust had such fantastic support you claim. There is no support for integrated debugging, across languages on Android Studio and Visual Studio. No support for COM or UWP and Win32 is WIP. Not sure how much NDK APIs are actually wrapped.
Those are probably what the parent means by "UI framework." The Rust toolchain does integrate seamlessly with those platforms' native toolchains, using the same binary and debug info formats. Perhaps this is perception is just caused by e.g. the extremely low bar set by MinGW, which doesn't do any of that despite "supporting" Windows.
For example since Longhorn failure, COM has become the major way to introduce Windows APIs, since Vista Win32 doesn't get much love.
Re: Dictionary and Set Improvements in Swift 4.0
#69The 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.
OTOH, one of things hammered into me at Microsoft was “sample code becomes production code”.
Re: Dictionary and Set Improvements in Swift 4.0
#70Earlier quoted context omitted.
Attributed 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 unde…
I see Swift supports generics so could they let you define subclasses of string enums that support custom string values?
However, you can't (at least currently) add new cases to someone else's enum (the way you can add methods). So if I decided I wanted my own custom text attributes (which isn't uncommon), we're back to type-unsafe land. We'd need the original enum to have an extra attribute case, like this[1].
[0]https://pastebin.com/L1xPcueu [1]https://pastebin.com/h8Rp3Ajy