Just so you know, what you say about performance is only valid for lookup. There are many use-cases where an array is the better solution, even if you scan through the whole thing. Keyword, cache locality . And if you order the array, you will have awesome performance also with search, and the other set operation you showed. I would suggest you change the title of the video (but for the youtube algo, that one might be good, also to raise engagement, so maybe leave it for clicks 😁 )
I’m experimenting with playing the “TH-cam Game”. It feels a little dirty, but my past 2 videos have gotten 3x my typical views in the first 24 hours. It sucks, but the game works. 🤷🏻♂️
@@seanallen If you're that at least include the more nuanced truth in the video itself. This is bordering on spreading misinformation and is making me feel like I ought to double check stuff I've seen in your videos. In this case my experience with C++ arrays made it so I already knew. In fact, I was waiting for you to explain that the truth is more complicated… but I never saw it in the video. Disappointing. If you click bait (I understand you gotta play the game), you have *got* to include the nunaced truth in the video somewhere.
@@torb-no It's even more complicated in Swift though, it's best to avoid mentioning performance at all. I'd focus on videos about cool features not everyone might have noticed, or things Swift can express more clearly than other languages. Writing performant code in any language requires deep understanding of memory and how code is compiled rather than memorising which features are "faster" and when.
@@TeamPuzel My understanding is that if your structs are small enough they have some of the C++ aspects. But I suppose Copy-on-Write can make it more complicated too.
Hey Sean, nice video! You mentioned that Arrays in swift have an O(N) lookup complexity. Arrays actually conform to the RandomAccessCollection protocol, which buys us back the O(1) complexity for a lot of the array's functionality.
You’re both correct. I believe he was referring to when you don’t know where the item you’re looking for is stored. Then it’s O(N) complexity but if you do know the index that it’s stored in, then it’s O(1) complexity
Fair point, but I disagree that you often have the index. Most of the time I’ve worked with arrays the data is dynamic and I don’t know the index of an item ahead of time.
Hey Sean! Great content as always! Got to know about the practical use of the set operators. Excited to use them from now on 😃 Also wanted to let you know that your fingers might have slipped during demonstrating the union example. 😄 But that's completely understandable... Looking forward to your next video 😃
It's really great and helpful video, and I just give one suggestion, pls add subtitle if possible, because, TH-cam CC is not accurate and my English not fluent, so it's really hard for me to understand you Said, I hope you are getting my point. Anyway very helpful video ❤ 😍
Can you make a video about these methods as well ? lexicographicallyPrecedes withContiguousStorageIfAvailable makeIterator reserveCapacity underestimatedCount withUnsafeBufferPointer partition Maybe there are some more.
Since as Swift devs we're probably doing UI, we should generally be using FetchRequests instead of Arrays or Sets to populate UI. FetchRequests get automatic updates when the database changes and has a sort function built in.
This name example is a terrible sample case. For example, if you're using Sets to determine permissions, anyone in the company with the same first name will all have the same access to whatever the software is in control of, which could be very undesirable if there was a Sean who was a Jr. Dev and another Sean who was at the C-level.
This is not an appropriate title for this video, sorry. Valid uses of `Array` outweigh those of `Set` in a typical codebase by several orders of magnitude. The clickbait title isn’t worth the misinformation.
@@seanallen appreciate that. I rarely put comments on TH-cam, but when i read the title and thought there must be some performance issues related to Arrays. But it’s mostly related to using correct data structure.
Just so you know, what you say about performance is only valid for lookup. There are many use-cases where an array is the better solution, even if you scan through the whole thing. Keyword, cache locality . And if you order the array, you will have awesome performance also with search, and the other set operation you showed.
I would suggest you change the title of the video (but for the youtube algo, that one might be good, also to raise engagement, so maybe leave it for clicks 😁 )
I’m experimenting with playing the “TH-cam Game”. It feels a little dirty, but my past 2 videos have gotten 3x my typical views in the first 24 hours. It sucks, but the game works. 🤷🏻♂️
Can you give us a real-life example of using Set instead of a array?
@@seanallen If you're that at least include the more nuanced truth in the video itself. This is bordering on spreading misinformation and is making me feel like I ought to double check stuff I've seen in your videos.
In this case my experience with C++ arrays made it so I already knew. In fact, I was waiting for you to explain that the truth is more complicated… but I never saw it in the video. Disappointing.
If you click bait (I understand you gotta play the game), you have *got* to include the nunaced truth in the video somewhere.
@@torb-no It's even more complicated in Swift though, it's best to avoid mentioning performance at all.
I'd focus on videos about cool features not everyone might have noticed, or things Swift can express more clearly than other languages. Writing performant code in any language requires deep understanding of memory and how code is compiled rather than memorising which features are "faster" and when.
@@TeamPuzel My understanding is that if your structs are small enough they have some of the C++ aspects.
But I suppose Copy-on-Write can make it more complicated too.
Hey Sean, nice video!
You mentioned that Arrays in swift have an O(N) lookup complexity.
Arrays actually conform to the RandomAccessCollection protocol, which buys us back the O(1) complexity for a lot of the array's functionality.
You’re both correct. I believe he was referring to when you don’t know where the item you’re looking for is stored. Then it’s O(N) complexity but if you do know the index that it’s stored in, then it’s O(1) complexity
Thanks a lot for this video! It’s was very useful!
Glad you enjoyed it, Ruslan!
Never Knew about Sets. I've been using Arrays all this time. Thanks, sean. Valuable video, and I learned something new today.
Great video!
Thanks!
nice video!
Thanks!
Thank you Sean
I love Sets! Good shout Sean!
I love arrays, back from the old days. But sets are awesome!
I think you mistakenly union the same sets instead swiftUIDevs + SwiftDevs.
And then you convert sets to arrays anyway to store in Core Data.
...and not just Array but NSArray. I am hoping for more native Swift support from CoreData this WWDC but I am not holding my breath.
Actually reading from an Array (if you have the index) is O(1) which is often the case...
Fair point, but I disagree that you often have the index. Most of the time I’ve worked with arrays the data is dynamic and I don’t know the index of an item ahead of time.
Hey Sean! Great content as always!
Got to know about the practical use of the set operators.
Excited to use them from now on 😃
Also wanted to let you know that your fingers might have slipped during demonstrating the union example. 😄
But that's completely understandable...
Looking forward to your next video 😃
Solid info here! Sets have been a rare encounter in all my development days but they are pretty awesome.
Great video, but what will you say about pagination and order? How can I avoid an array?
It's really great and helpful video, and I just give one suggestion, pls add subtitle if possible, because, TH-cam CC is not accurate and my English not fluent, so it's really hard for me to understand you Said, I hope you are getting my point. Anyway very helpful video ❤ 😍
Hey Sean, while I agree with you, I use Sets when I wanna store exclusive values like say an Order Number for a Product that is sold, which is unique.
Sean: When you need a collection of something in Swift, you instinctively reach for an array. Don't you?
Me: 👀 .............nooooooooooooo?
Lol, we all do it :)
@@seanallen So true 😂
What if there are two students with the same name?
Can you make a video about these methods as well ?
lexicographicallyPrecedes
withContiguousStorageIfAvailable
makeIterator
reserveCapacity
underestimatedCount
withUnsafeBufferPointer
partition
Maybe there are some more.
Can you give real life example not using set, say can we use it in tableview or anything similar
Since as Swift devs we're probably doing UI, we should generally be using FetchRequests instead of Arrays or Sets to populate UI. FetchRequests get automatic updates when the database changes and has a sort function built in.
Is the performance difference something you've seen in your apps? Since it's all in memory, I wouldn't think it mattered that much.
Oh... the date?
nice
Hi sir.
I need pubg mobile redeem code of testflight please help please 🙏
Set don't work well with SwiftUI though.
I’m not agree Array is not Set and Set could not be Array
No...I can't take this. Stop this, eat that, 10 fucking ways of doing a "10 fucking ways to do something". You won't miss me, I gotta bail.
Guilty 😳
This name example is a terrible sample case. For example, if you're using Sets to determine permissions, anyone in the company with the same first name will all have the same access to whatever the software is in control of, which could be very undesirable if there was a Sean who was a Jr. Dev and another Sean who was at the C-level.
This is not an appropriate title for this video, sorry. Valid uses of `Array` outweigh those of `Set` in a typical codebase by several orders of magnitude. The clickbait title isn’t worth the misinformation.
Click bait. 👎
Fair. Title and thumbnail change coming soon.
@@seanallen appreciate that. I rarely put comments on TH-cam, but when i read the title and thought there must be some performance issues related to Arrays. But it’s mostly related to using correct data structure.