I messed up. I'm sorry.

2024 ж. 27 Нау.
57 931 Рет қаралды

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

    @IceQub3@IceQub3Ай бұрын
    • accurately pinned ahh comment

      @sammtanX@sammtanXАй бұрын
    • Not free, he placed the ad in the middle of the video

      @allanhouston22@allanhouston22Ай бұрын
  • 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

    @antonioamaral400@antonioamaral400Ай бұрын
    • I'm of the type that don't do anything. My record is spotless.

      @CrazyHorseInvincible@CrazyHorseInvincibleАй бұрын
  • Thats it Nick. I was going to introduce you to my beautiful daughter, but thats not happening now. Your loss.

    @margosdesarian@margosdesarianАй бұрын
  • so true, I'm still reading last year's performance blog

    @AdolfoFoliaco@AdolfoFoliacoАй бұрын
  • A true cop would do a self review and find no wrong doing

    @bogella2225@bogella2225Ай бұрын
    • Well said comrade

      @AnsisPlepis@AnsisPlepisАй бұрын
    • The Blizzard Entertainment way

      @nickchapsas@nickchapsasАй бұрын
    • ​@@AnsisPlepisdisco elysium vibes

      @hasmich@hasmichАй бұрын
    • @@nickchapsas horde or alliance?

      @renatogolia211@renatogolia211Ай бұрын
  • 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!

    @vitalydushkin@vitalydushkinАй бұрын
    • Seconding this. Maybe a name like "SearchValues on strings, part 2: IndexOfAny" when the "clickbait window" is closed?

      @nebuleon@nebuleonАй бұрын
  • Mistakes are fine, it's how you respond which matters. And this is the best way to do it. Appreciate the transparency

    @DevDunkStudio@DevDunkStudioАй бұрын
  • I will always forgive you, brother Nick.

    @Placeholderhandle1@Placeholderhandle1Ай бұрын
    • Given a mistake has been admitted in the first place ;)

      @hasmich@hasmichАй бұрын
  • 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.

    @ProfBits@ProfBitsАй бұрын
  • 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?

    @99MrX99@99MrX99Ай бұрын
  • 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).

    @gilroitto@gilroittoАй бұрын
  • 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!

    @CalebJenkinsOnGoogle@CalebJenkinsOnGoogleАй бұрын
  • Hi nick, why did you reassign NeedleArray and Haystack to local variables inside the IndexOfFirstArray?

    @superpcstation@superpcstationАй бұрын
  • 4:54 hahaha this makes me laugh 😂 Good job, really impressive that he reached you and that you shared this with us 🔥

    @Szwarcus15@Szwarcus15Ай бұрын
    • Same lol 😂

      @ChristofferLund@ChristofferLundАй бұрын
  • How does IndexOfAny work behind the scene? Why is it so performant?

    @genyalubin@genyalubinАй бұрын
  • 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.

    @IllidanS4@IllidanS4Ай бұрын
  • 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!

    @persehlin4379@persehlin4379Ай бұрын
  • 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?

    @leopoId@leopoIdАй бұрын
  • We appreciate your transparency Nick. It's great you did a follow up on this. Nobody knows everything.

    @bogdan.p@bogdan.pАй бұрын
  • Damn, I was just reading Stephen Toub's "Building Async Coordination Primitives" blog posts from 2012 today and now he gets mentioned.

    @tedchirvasiu@tedchirvasiuАй бұрын
  • 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.

    @LasseVagstherKarlsen@LasseVagstherKarlsenАй бұрын
    • 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

      @_mihazupan@_mihazupanАй бұрын
  • A major lesson in public communication and audience control. Kudos Nick.

    @vekzdran@vekzdranАй бұрын
  • 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!

    @paulecampbell@paulecampbellАй бұрын
  • Do you have any reosurces that explain how this works behind the scenes?

    @C00l-Game-Dev@C00l-Game-DevАй бұрын
  • "I owe you an apology" ...and money I'd add... My billion dollar startup just failed due to bad information from YT.

    @cocoscacao6102@cocoscacao6102Ай бұрын
  • Transparency and integrity, nice to see. :)

    @d347hm4n@d347hm4nАй бұрын
  • 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!

    @carlosalmeida2847@carlosalmeida2847Ай бұрын
    • 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.

      @jcmorin2007@jcmorin2007Ай бұрын
  • How does this compare with old school Regex?

    @vitalmarc@vitalmarcАй бұрын
    • 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.

      @jongeduard@jongeduardАй бұрын
  • How long it takes to cast it to a searchValues?

    @TonoNamnum@TonoNamnumАй бұрын
  • That's it, I'm switching to Java now

    @fusedqyou@fusedqyouАй бұрын
    • "It hurt itself in its confusion".

      @mikestiver9000@mikestiver9000Ай бұрын
    • Ironic because I'm a java dev that follows c# to see where we'll be in ~5 years

      @adambickford8720@adambickford8720Ай бұрын
    • @@adambickford8720 the sneak eating it's on tale

      @alissoncandatem1896@alissoncandatem1896Ай бұрын
    • 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

      @AnsisPlepis@AnsisPlepisАй бұрын
  • 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.

    @DotNetCookbook@DotNetCookbookАй бұрын
  • Recognizing errors makes you a great person. This kind of things are really motivating to follow your videos 🙂

    @jvquiles@jvquilesАй бұрын
  • FrozenSet might be even more efficient

    @RamonSmits@RamonSmitsАй бұрын
  • 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”.

    @tanglesites@tanglesitesАй бұрын
  • Press F to pay respect

    @GiovanniCostagliola@GiovanniCostagliolaАй бұрын
  • I am proud of you. Very few mere mortals gets humbled by Stephen Toub, you took it like a boss. Keep coding.

    @acedonk@acedonkАй бұрын
  • Now this makes much more sense. Great feature!

    @utubekade@utubekadeАй бұрын
  • I was worried when I saw the title. You had me there worried for a couple of seconds Nick.

    @muhamedkarajic@muhamedkarajicАй бұрын
  • Integrity move, brother

    @Bennevisie@BennevisieАй бұрын
  • 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 ❤

    @mrcarlpaton@mrcarlpatonАй бұрын
  • Title sounds like one for an influencer apology video. Thanks for the correction, tho. The feature looks pretty amazing.

    @SlackwareNVM@SlackwareNVMАй бұрын
  • Guess it should have been compared with FrozenSet not with HashSet? :D

    @nikolayzdravkov1378@nikolayzdravkov1378Ай бұрын
  • Thanks foe clarification.

    @krccmsitp2884@krccmsitp2884Ай бұрын
  • Nick title should include info about what it is. We search (lol) for these in the future,

    @JRyomaru@JRyomaruАй бұрын
  • 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?

    @robl39@robl39Ай бұрын
  • Could you talk about redis alternatives? please

    @RandalGJunior@RandalGJuniorАй бұрын
  • 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 :(

    @charlesaboujawdeh@charlesaboujawdehАй бұрын
    • Yeah, a course price specific based on the country might be a good idea for people of countries with less resources

      @hernanar3647@hernanar3647Ай бұрын
  • 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)

    @nertsch77@nertsch77Ай бұрын
  • 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.

    @CharlesBurnsPrime@CharlesBurnsPrimeАй бұрын
  • It's great you made this video and did it so fast. Everyone makes mistakes, but it takes guts to admit it.

    @hasmich@hasmichАй бұрын
  • 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.

    @pavlindrom@pavlindromАй бұрын
    • lolno

      @nickchapsas@nickchapsasАй бұрын
    • Apology? Why tho

      @promant6458@promant6458Ай бұрын
    • @@promant6458 tongue in cheek comment, since I used it before, it can't be bad, right? I do concede the video had good points.

      @pavlindrom@pavlindromАй бұрын
  • That was nothing. You should see the mistake I made. Much respect Nick

    @peterk4694@peterk4694Ай бұрын
  • Thank you for being honest and owning up. As long as you admit it, your cool.👍

    @C00l-Game-Dev@C00l-Game-DevАй бұрын
  • Very nice to admit your own mistakes, keep doing amazing work.

    @imavalverde@imavalverdeАй бұрын
  • 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.

    @reikooters@reikootersАй бұрын
  • awwwww Nick please dont cry...

    @o0ooCrossboneoo0o@o0ooCrossboneoo0oАй бұрын
  • A small video bug. All good mate! Fix verified.

    @queenstownswords@queenstownswordsАй бұрын
  • Good job!

    @cs96ai@cs96aiАй бұрын
  • It's called due diligence!

    @CarrigansGuitarClub@CarrigansGuitarClubАй бұрын
  • I thought he was going to apologize for talking badly about stored procedures

    @Pingouin583@Pingouin583Ай бұрын
  • hi Stephen

    @leknyzma@leknyzmaАй бұрын
  • Always nice to see someone admit mistakes and fix them. Mad respect!

    @comediehero@comedieheroАй бұрын
  • One of the best keep it up!

    @ichigoslayer84@ichigoslayer84Ай бұрын
  • Nick, kudos for making fix video. But if you truly "hold yourself to the standards", stop with cheap clickbait titles and name it properly.

    @rouensk@rouenskАй бұрын
  • We all human, thanks for making videos!

    @FroxerBBQ@FroxerBBQАй бұрын
  • 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?

    @thefattysplace@thefattysplaceАй бұрын
    • 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@TheAceInfinityАй бұрын
    • @@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@thefattysplaceАй бұрын
    • @@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@TheAceInfinityАй бұрын
    • @@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.

      @thefattysplace@thefattysplaceАй бұрын
    • @@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 |

      @thefattysplace@thefattysplaceАй бұрын
  • Sure. But how does this compare to regex.

    @JeremyPyne@JeremyPyneАй бұрын
  • Thank you for clearing that up! Keep up the good work, Nick. Thank you so much!

    @TheBlackNathaniel@TheBlackNathanielАй бұрын
  • Nick should learn to see sharp this time.

    @mintx1720@mintx1720Ай бұрын
  • High standards, as always. Thanks.

    @Fred-yq3fs@Fred-yq3fsАй бұрын
  • Never knew you are a Marvel fan

    @theprantadutta@theprantaduttaАй бұрын
  • You should have Code Copped yourself... 😂

    @pedrosilva1437@pedrosilva1437Ай бұрын
  • It’s just not good enough Nick

    @BlingPiece@BlingPieceАй бұрын
  • Haven't watched yet no idea what this is about just wanted you to know I don't forgive you and never will.

    @Robert-yw5ms@Robert-yw5msАй бұрын
  • Dang, now I don't have a valid use-case to use this feature.

    @Ristogod@RistogodАй бұрын
  • Ok we forgive you, but... what are you wearing??

    @StefanoTempesta@StefanoTempestaАй бұрын
  • Good correction, we all make mistakes!

    @JamyRyals@JamyRyalsАй бұрын
  • I hate clickbait, why don’t you just sum up your mistake in video title ?

    @Kangoo9@Kangoo9Ай бұрын
    • Don't watch Nick if you dislike clickbait

      @RainFerret@RainFerretАй бұрын
    • You must be new

      @nickchapsas@nickchapsasАй бұрын
    • @@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.

      @RainFerret@RainFerretАй бұрын
  • Phenomenal

    @PedroPabloCalvoMorcillo@PedroPabloCalvoMorcilloАй бұрын
  • thats it im switching to java

    @_Tangent_@_Tangent_Ай бұрын
    • Have fun with that 😂

      @bikeindustryshill@bikeindustryshillАй бұрын
    • @@bikeindustryshill +1

      @PankajNikam@PankajNikamАй бұрын
    • Whats wrong with java? Its ok bro

      @xelesarc1680@xelesarc1680Ай бұрын
    • @@xelesarc1680 It's ok, not great

      @tedchirvasiu@tedchirvasiuАй бұрын
  • Im rarely this early, minute 1?

    @dongler4589@dongler4589Ай бұрын
  • Main take away: search values is insanely fast 😎

    @ryan-heath@ryan-heathАй бұрын
  • The thumbnail shouldn't used the cop cap😅 So you're not forgiven yet😂

    @bloggrammer@bloggrammerАй бұрын
  • Yes, you ruined my entire career. Love your content btw.

    @Leon-ph7br@Leon-ph7brАй бұрын
  • You should apologize for the clickbait title and thumbnail.

    @VakkaHUN@VakkaHUNАй бұрын
  • blazingly fast

    @cvelebele18@cvelebele18Ай бұрын
  • That’s it, I’m unsubscribing

    @thedjtko@thedjtkoАй бұрын
  • You have to be the most genuine and honest KZheadr I know. And your content is always amazing and informative. Keep it up

    @AnsisPlepis@AnsisPlepisАй бұрын
  • Sorry nick but this time you went too far. It’s too late to apologize 😔

    @throwaway6288@throwaway6288Ай бұрын
  • Shame! Shame! Shame!

    @Knuckles2761@Knuckles2761Ай бұрын
  • This happens when you try to release video quickly just for the self promo...

    @user-yb8ck6cf2m@user-yb8ck6cf2mАй бұрын
  • Get a life!

    @johan_za@johan_zaАй бұрын
  • I memorised that code (dQw4w9WgXcQ) so I know exactly what it is every time I see it online or spray painted around town lol

    @MayronDev@MayronDevАй бұрын
  • The thumbnail shouldn't used the cop cap😅 So you're not forgiven yet😂

    @bloggrammer@bloggrammerАй бұрын
KZhead