I messed up. I'm sorry.
Vložit
- čas přidán 27. 03. 2024
- Use code EASTER25 for 25% off any course, EASTER15 for 15% off any bundle or EASTER10 for 10 off your first year of Dometrain Pro on Dometrain: dometrain.com
Become a Patreon and get special perks: / nickchapsas
Hello, everybody, I'm Nick, and in this video I will address a mistake I did in my previous video regarding search values.
Workshops: bit.ly/nickworkshops
Don't forget to comment, like and subscribe :)
Social Media:
Follow me on GitHub: github.com/Elfocrash
Follow me on Twitter: / nickchapsas
Connect on LinkedIn: / nick-chapsas
Keep coding merch: keepcoding.shop
#csharp #dotnet
Bro was wrong and got a free video topic as a present. 10/10 business
accurately pinned ahh comment
Not free, he placed the ad in the middle of the video
There are only 2 types of people that "don't make mistakes". Those that don't do anything and those that won't admit them.
Viewers: "Come for the tech value, stay for the human value".
Keep up the good work Nick
I'm of the type that don't do anything. My record is spotless.
so true, I'm still reading last year's performance blog
A true cop would do a self review and find no wrong doing
Well said comrade
The Blizzard Entertainment way
@@AnsisPlepisdisco elysium vibes
@@nickchapsas horde or alliance?
Thats it Nick. I was going to introduce you to my beautiful daughter, but thats not happening now. Your loss.
Mistakes are fine, it's how you respond which matters. And this is the best way to do it.
Appreciate the transparency
I don't think you have messed up. I'm going through MS docs now, and they don't make any sense, and have no examples. Went to see a couple of articles, they also fail to deliver. Your videos showed a few real world use cases. But thanks for the follow up. Also Nick, would it be possible for you to add to the title "SearchValues" so it would be easier to find this video in the future? I like to use your videos as a point of reference from time to time, and descriptive title or/and tags greatly improve searchability. Thanks!
Seconding this. Maybe a name like "SearchValues on strings, part 2: IndexOfAny" when the "clickbait window" is closed?
I will always forgive you, brother Nick.
Given a mistake has been admitted in the first place ;)
4:54 hahaha this makes me laugh 😂 Good job, really impressive that he reached you and that you shared this with us 🔥
Same lol 😂
It's okay. At least you did not sing the apology.
To be honest I did not give so much attention to the previous video but I immediately recalled memories of learning about Aho-Corasick and other text searching algorithms, so I already knew where this would have been going. I would love to know more about what this algorithm is or what the structure behind it looks like. Perhaps it is the hashing-based searching too.
Curious about the algorithm. My best guess as many here is a modified version of Boyer-Moore or Boyer-Moore-Hoorspool algorithm, where the pre-processing combines all the search words into combined table(s). Edge cases that would challenge the performance would be high Unicode characters, many search strings that cover the whole alphabet, and search in texts with few characters (e.g. DNA sequences).
Ok, nice to heare. However in this case you should the simplest but worst possible way to do the computation as a base line. Therfor how would a Boyer-Moore string-search algorithm implementation stack up against search values or is it simmilar? It would be simmillar if search values uses it in the backend, however I haven't checked that.
It's all good Nick! I love the transparency and opportunities that come with doing so much in public. Keep that excellent content coming our way!
Thanks! That's why I trust you and your videos. You are so eager to do things correctly that you even evaluate your own videos. Fantastic!
Is there also a method to return the found value so one can e.g. switch over it from the different values one searched for?
We appreciate your transparency Nick. It's great you did a follow up on this. Nobody knows everything.
Hi nick, why did you reassign NeedleArray and Haystack to local variables inside the IndexOfFirstArray?
So it is for finding strings in a long paragraphs, not in a string array. Good point but are there any mentions about it on Docs?
Man, Stephen is legendary and I know that's where Nick is heading. I literally just watched a video with Stephen explaining how async/await works internally - epic! Thanks for sharing this with us Nick. I have even more confidence in you now that I know that you will not hesitate to call out yourself!
Transparency and integrity, nice to see. :)
A major lesson in public communication and audience control. Kudos Nick.
How does IndexOfAny work behind the scene? Why is it so performant?
Damn, I was just reading Stephen Toub's "Building Async Coordination Primitives" blog posts from 2012 today and now he gets mentioned.
I agree, this is a much better showcase for the benefits of that class, nice of you to come back with an update :)
This suggests that what this class does is to create a DFA or similar for use with an algorithm similar to Boyer-Moore, that instead of just blindly iterating one character at a time over the text to search, actually uses the knowledge of what it is searching for to be able to skip faster through the text. I say "similar" because I have not kept myself updated on such algorithms and undoubtedly there are even better algorithms these days.
For the example given (3 ASCII values), the implementation would currently use an algorithm called "Teddy" that lets us look for prefixes of multiple values in a vectorized manner
Recognizing errors makes you a great person. This kind of things are really motivating to follow your videos 🙂
That's it, I'm switching to Java now
"It hurt itself in its confusion".
Ironic because I'm a java dev that follows c# to see where we'll be in ~5 years
@@adambickford8720 the sneak eating it's on tale
We mainly use dotnet where I work, and during a board session, we had to assign tasks. One of them was upgrading dependencies in a Java plugin. When no one offered to take the task, scrum master shyly said “Java? Anyone?” as if to convince someone. That was the funniest and most awkward silence on the job, and sometimes when I see Java I realise just how glad I am to have moved past it
Now this makes much more sense. Great feature!
I wouldn’t say you messed up, I’d say you came with a part 2 video with even more detailed, in-depth and thorough information! Congrats!
It's a "messed" in a sense it didn't show anything. When I saw the original video I've immediately told myself, how is that better than a hashset with a case insensitive comparer. So happy how I get the answer.
Thanks foe clarification.
I was worried when I saw the title. You had me there worried for a couple of seconds Nick.
FrozenSet might be even more efficient
I am proud of you. Very few mere mortals gets humbled by Stephen Toub, you took it like a boss.
Keep coding.
Nobody is perfect Nick. The fact you deem an omission a mistake regardless the reason for the omission only makes me like this channel more. I’m sure most of us didn’t even notice.
Thanks for the “update”.
Title sounds like one for an influencer apology video. Thanks for the correction, tho. The feature looks pretty amazing.
You still smarter than I'll ever be and I'm a better engineer because of all your other content and courses. Keep coding brother ❤
Press F to pay respect
Nick title should include info about what it is. We search (lol) for these in the future,
"I owe you an apology" ...and money I'd add... My billion dollar startup just failed due to bad information from YT.
How does this compare with old school Regex?
Depends on your regex implementation. There are quite a lot. The Dotnet regex engine is quite a fast one, but also quite large in features, while in Rust you get basically the fastest implementation on the planet I believe, but with more limited features.
But still things like SearchValues may still win over all of these, since you dedicate it to very specific things to search for and not a whole regex engine has to sit behind it.
However, this is all my thoughts. the real way to know is just to benchmark it. Very simple.
It's great you made this video and did it so fast. Everyone makes mistakes, but it takes guts to admit it.
Do you have any reosurces that explain how this works behind the scenes?
Integrity move, brother
How long it takes to cast it to a searchValues?
Thank you for being honest and owning up. As long as you admit it, your cool.👍
That was nothing. You should see the mistake I made. Much respect Nick
You could call this "Code COP Me"
Very nice to admit your own mistakes, keep doing amazing work.
Were it possible for me to respect you more than I already do, sincerely apologizing for a legitimate mistake would have increased that respect further still.
awwwww Nick please dont cry...
Now this makes much more sense! Thank you! What’s still unclear to me is the use case scenario for search values on any type that is not a string/char.
Guess it should have been compared with FrozenSet not with HashSet? :D
We all human, thanks for making videos!
One of the best keep it up!
I thought you were going to reneg the episode where you trashed the byte backing field for enums, which I have done recently. I'll await your apology for that too.
lolno
Apology? Why tho
@@promant6458 tongue in cheek comment, since I used it before, it can't be bad, right? I do concede the video had good points.
Hey Nick, I really find your videos useful and I wish I could afford your dometrain courses and support you. I'm from Lebanon but I find them too expensive for us since our income is so low specially because of the economic crisis we've been in for almost 5 years now :(
Yeah, a course price specific based on the country might be a good idea for people of countries with less resources
Good job!
A small video bug. All good mate! Fix verified.
I guess it still wasn’t clear to me why this is better than a hash set or hash map. What is the summary here? Why would you use this over the hash set or map?
Could you talk about redis alternatives? please
It's called due diligence!
hi Stephen
Always nice to see someone admit mistakes and fix them. Mad respect!
Good follow up. On the last video I assumed this was the actual use case just because this is essentially what the previous characters one was doing (needless in a haystack type thing). But nice to see an actual benchmark showing the feature.
Thank you for clearing that up!
Keep up the good work, Nick. Thank you so much!
I thought he was going to apologize for talking badly about stored procedures
Never knew you are a Marvel fan
High standards, as always. Thanks.
You have to be the most genuine and honest CZcamsr I know. And your content is always amazing and informative. Keep it up
Nick should learn to see sharp this time.
Nick, kudos for making fix video. But if you truly "hold yourself to the standards", stop with cheap clickbait titles and name it properly.
Sure. But how does this compare to regex.
It’s just not good enough Nick
Good correction, we all make mistakes!
Haven't watched yet no idea what this is about just wanted you to know I don't forgive you and never will.
You should have Code Copped yourself... 😂
Phenomenal
Dang, now I don't have a valid use-case to use this feature.
Im rarely this early, minute 1?
thats it im switching to java
Have fun with that 😂
@@bikeindustryshill +1
Whats wrong with java? Its ok bro
@@xelesarc1680 It's ok, not great
I hate clickbait, why don’t you just sum up your mistake in video title ?
Don't watch Nick if you dislike clickbait
You must be new
@@nickchapsas I've watched all your videos for about 6 months. The content is wonderful, and the titles and thumbnails are complete clickbait style. Just what I like.
blazingly fast
Main take away: search values is insanely fast 😎
Ok we forgive you, but... what are you wearing??
What, if you would use "haystack.AsSpan().IndexOf(needle, StringComparison.OrdinalIgnoreCase)" ? (of course move aystack.AsSpan() outside the loop and do a Math.Min() over the sucessfull needle hits)
You should apologize for the clickbait title and thumbnail.
The thumbnail shouldn't used the cop cap😅
So you're not forgiven yet😂
That’s it, I’m unsubscribing
Yes, you ruined my entire career. Love your content btw.
Shame! Shame! Shame!
Sorry nick but this time you went too far. It’s too late to apologize 😔
Get a life!
This happens when you try to release video quickly just for the self promo...
How exactly is that range operator working? Doesn't that load the whole remainder of the string each time? Wouldn't it be better to use contains in that case, or just use the range appropriate to the length of the needle? I.e [i..(i-needle.length)]? What am I missing here?
The range operator on a span is NOT like Substring. It creates a Range which is like calling for a Slice. It's only a Substring if used on a string...
@@TheAceInfinity but isn't that slice still huge at the start of this loop? instead of just getting a smaller slice limited to the same length as the needle?
@@thefattysplace I'd say the size of the slice is irrelevant regardless because the entire point of span is to reduce memory allocations. Only the start and end indices are stored. You should learn about how spans work.
@@TheAceInfinity sorry I wasn't referring to the memory optimisation, the size of the span wouldn't affect this as it's just a reference to the start and end points within a string. I was referring to the speed. I guess it depends on what operations are done in startswith, and if it is affected by length. But then that brings me back to using contains instead on the full string. Just for fun I might do my own benchmarks and see using the same source string.
@@TheAceInfinity I ran the benchmarks with two new tests and the results show using a smaller slice gives a 0.89 ratio to using the full remaining span. Using contains was actually pretty close to using searchvalues. But using searchvaules still wins hands down. Results were:
| IndexOfFirstArray | 7,934.59 us | 1.00 | 22 B | 1.00 |
| BoolContainsArray | 164.78 us | 0.02 | 2 B | 0.09 |
| IndexOfFirstSmallSliceArray | 6,982.63 us | 0.89 | 110 B | 5.00 |
| IndexOfFirstSearchValues | 86.34 us | 0.01 | 2 B | 0.09 |
I memorised that code (dQw4w9WgXcQ) so I know exactly what it is every time I see it online or spray painted around town lol
The thumbnail shouldn't used the cop cap😅
So you're not forgiven yet😂