FASTER JavaScript In 2025 With Sets

  Рет қаралды 18,819

Jack Herrington

Jack Herrington

Күн бұрын

Пікірлер: 68
@pawel_890
@pawel_890 2 күн бұрын
The set is great only under few conditions: - you don't do frequent addition, because each element has a calculated index - you can't update existed elements - just use Map - you can't refer after index `array[index]` - just use Array Set is something like an object `{}` with built in an iterator
@yobebill1234
@yobebill1234 Күн бұрын
everything is an object jerry.
@designerjehovah4453
@designerjehovah4453 3 күн бұрын
Glad to have you back Jack!!
@jherr
@jherr 3 күн бұрын
Nice to be back from vacation.
@mounis
@mounis 3 күн бұрын
Wake up babe, new Jack Herrington video just dropped.
@acrosstundras
@acrosstundras 2 күн бұрын
When it comes to performance, the answer is, more often than not, "it depends". For example, in some situations, array lookup will use CPU cache, whereas set will not, resulting in worse performance counterintuitively.
@mahmoud-d22
@mahmoud-d22 3 күн бұрын
Happy new year Jack :)
@rogerscript
@rogerscript Күн бұрын
New Year, but the same awesome quality of your videos Jack! Thank you to be back!
@NaserPapi-x7z
@NaserPapi-x7z 2 күн бұрын
Excellent Exploration; I really appreciate your technique for teaching this fascinating topic. Personally, I enjoyed the performance part and your demo of the O-one vs. O-N lookup. Thanks for this great sharing.
@ahoy1
@ahoy1 2 күн бұрын
I used Sets for the first time a few month ago, they're great. Having union/difference/etc methods built right in is great
@RossOlsonDotCom
@RossOlsonDotCom 3 күн бұрын
Great tight overview of this! The one thing I’m missing is the types that are returned. It looks like some of the set operations will return arrays, but some could return sets. It would be great to know which is coming back.
@shinebayar
@shinebayar 2 күн бұрын
Btw performance difference is negligible if you're working with small data set like under a thousand or something. Because of the array values are stored next to each other in the memory and it's faster to lookup them if the entire array can fit in the cpu cache.
@yamelamadorfernandez7416
@yamelamadorfernandez7416 2 күн бұрын
Honestly I've used 30% of the Set features, watching this video reformatted my brain, now I realize that Set is very powerful and closer to Array functionality than Map.
@JoshMarom-zx9mv
@JoshMarom-zx9mv 2 күн бұрын
Great content as usual
@dkazmer2
@dkazmer2 3 күн бұрын
Best video on Set I've seen
@alexlohr7366
@alexlohr7366 2 күн бұрын
The Set in JS is a hash set with fast collision handling under the hood. By the way, there is a solid-primitive for a reactive Set that you'll like.
@MohammedWaseemAnjum
@MohammedWaseemAnjum 2 күн бұрын
Thank you sir you are awesome as usual!
@aaronstarling9837
@aaronstarling9837 3 күн бұрын
Awesome information!
@reneheijdens8444
@reneheijdens8444 Күн бұрын
Great video! I've been using Set to generate arrays with unique values, but I never realized its full potential until now. 😅 Quick question: How do you use Set effectively with objects? Since the uniqueness constraint relies on object references, does that mean it only works if the objects reference the exact same memory location? Also, is it possible to extend Set functionality to perform operations like union, intersection, and difference when dealing with objects? Would love to hear your thoughts or see examples!
@jherr
@jherr Күн бұрын
You can just do something like: const keysA = new Set(Object.keys(a)); const keysB = new Set(Object.keys(b)); keysA.union(keysB); keysA.symmetricDifference(keysB); // etc. You could do the same thing with Object.values(). Depends on your use case.
@josersleal
@josersleal 2 күн бұрын
even I could understand that at first at 1.5x speed. well done Sir. On notebooks, there's also microsoft new offering: polyglot notebooks extension. you can use multiple languages in the same notebook and share variables between them. create diagrams and more. no typescript yet though.
@jherr
@jherr 2 күн бұрын
Ooof, that last sentence is a killer. No TypeScript? From Microsoft? Booo... Otherwise, sign me up!
@lastink444
@lastink444 5 сағат бұрын
I'm actually more surprised/impressed by the jupyter notebook here
@daxdivv
@daxdivv 3 күн бұрын
How do you get those auto completions at 0:41?
@lakshmanshankar
@lakshmanshankar 3 күн бұрын
I'm not sure what that was but it looks like warp terminal.
@dannrcstr
@dannrcstr 3 күн бұрын
First you must have a MacOS, then install the ZSH terminal (version 5.8 or greater), then install and configure the zsh-autocomplete plugin
@sikritidakua
@sikritidakua 3 күн бұрын
I think it was something called `fig sh` I used it in the past but I removed it later, it was very annoying for me
@dannrcstr
@dannrcstr 3 күн бұрын
@@sikritidakua Fig has been discontinued
@sikritidakua
@sikritidakua 3 күн бұрын
@ yeah its Amazon Q cli or something i dont remember correctly but if u search fig sh it will come
@adrian34234
@adrian34234 3 күн бұрын
Great video I really like Set a lot! Can it be used in js already?
@jherr
@jherr 3 күн бұрын
100%.
@youarethecssformyhtml
@youarethecssformyhtml 3 күн бұрын
They're so old actually (released before 2016) so yeah
@adrian34234
@adrian34234 2 күн бұрын
@@youarethecssformyhtml So why is there more noise about it now? I'm curious
@youarethecssformyhtml
@youarethecssformyhtml 2 күн бұрын
@@adrian34234 no idea
@dkazmer2
@dkazmer2 2 күн бұрын
@@adrian34234 cuz clearly nobody knows about it still
@mannuelf
@mannuelf 3 күн бұрын
Great great great 🤘🚀
@Mizax22
@Mizax22 Сағат бұрын
The translation in French is truly top-notch 🎉
@MrJettann
@MrJettann 3 күн бұрын
Do we need use usecallback on functions passed to set?
@jherr
@jherr 3 күн бұрын
Yes. You want references to functions in React to be controlled, which is what useCallback does, regardless of where you store them. And in particular with Set, you are using the memory location of the function as the unique key, so, yes, use useCallback.
@Ivan-wm6gm
@Ivan-wm6gm 2 күн бұрын
javascript team should really add priority queue
@deatho0ne587
@deatho0ne587 3 күн бұрын
O(1) is not always faster than O(N) since you need to care about things like creation, deletion, etc... times. The testing of the speed is kind of bad to be fair. Data is normally never in such a simple order or just number. I do like the examples of some set comparisons to be honest.
@codehan
@codehan 3 күн бұрын
Thanks! 🎉
@flydown1940
@flydown1940 19 сағат бұрын
name of vscode theme?
@jherr
@jherr 19 сағат бұрын
Night Wolf (black)
@bryson2662
@bryson2662 Күн бұрын
What is the point of Set.entries?
@jherr
@jherr Күн бұрын
Compatability with a family of data structures. Map, Set and arrays all support `entries` directly. And Object.entries gets you entries for an object.
@nuwanthuduwage6869
@nuwanthuduwage6869 3 күн бұрын
Cool!
@ggnova8581
@ggnova8581 3 күн бұрын
Theme?
@jherr
@jherr 3 күн бұрын
Night Wolf (black). Always listed in the description.
@ggnova8581
@ggnova8581 3 күн бұрын
@@jherrmy bad I didn’t see that
@jherr
@jherr 3 күн бұрын
@@ggnova8581 No worries. Just referencing it for future commenters. (Actually I shouldn't, more comments is good. Hahahah.)
@danser_theplayer01
@danser_theplayer01 Күн бұрын
A few notes if you care about performance (maybe you're doing servers or science): - Sets are bad at iteration as they use generators which is actually very slow compared to a *for* loop. The same can be said about any object that let's you use *for of* or spread *...* of values, because those are also generators (... isn't always though). Generators and callback methods like forEach() are inefficient (at least generators bring some neat special functionality), and fall off hard after a certain point. It's especially true when generators yield other generators.
@ryosukekureha4873
@ryosukekureha4873 3 күн бұрын
잭형님❤
@ryankdavidson
@ryankdavidson 3 күн бұрын
Monday morning Jack Attack 💥. TIL Jupyter can be used with JS via Deno, great side takeaway from this.
@nro337
@nro337 2 күн бұрын
Great video for performance!
@M1a2n3o43
@M1a2n3o43 2 күн бұрын
Wtf you can run javascript code in a ipynb file?
@SrAzion
@SrAzion Күн бұрын
so normally it depends on the algorithms
@nathanalberg
@nathanalberg Күн бұрын
who comes up with these names?.... `set.difference` should be `set.without` and `set.symmetricDifference` should be `set.difference`... i mean... wtf. symmetricDifference?
@jherr
@jherr Күн бұрын
Mathematicians. Difference and Symmetric Difference are well defined terms in Set Theory.
@LutherDePapier
@LutherDePapier Күн бұрын
At 8:36, when a developer accidentally creates an array of 300000 values, JavaScript as a language should have a built-in mechanism to turn that insanity into a Set. ECMA team if you're listening.
@jherr
@jherr Күн бұрын
Hahaha. That would be terrifying. There are key semantic differences between the two.
@WCanyon
@WCanyon 3 күн бұрын
good video -- you're talking kinda fast in here though
@thearcticmonkey
@thearcticmonkey 3 күн бұрын
Decrease video speed
@jherr
@jherr 3 күн бұрын
And here I think I'm always talking too slow. Hahaha. Yes, decrease (or increase) playback speed to suit.
The Biggest Mistake Intermediate React Developers Make
18:32
Cosden Solutions
Рет қаралды 38 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 220 М.
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН
She wanted to set me up #shorts by Tsuriki Show
0:56
Tsuriki Show
Рет қаралды 8 МЛН
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 10 М.
What's Actually Happening With JS Frameworks
8:59
Awesome
Рет қаралды 56 М.
I Tested Node.js and Express.js and Found Out What Works BEST #11
21:56
Programming Elements
Рет қаралды 145
Retro MS-DOS Coding - Recreating the Iconic Award BIOS Screen
18:16
NCOT Technology
Рет қаралды 72 М.
AI Is Not Designed for You
8:29
No Boilerplate
Рет қаралды 290 М.
You Should Use Maps and Sets in JS
14:28
Syntax
Рет қаралды 13 М.
“use cache” NextJS’s latest take on data caching
17:27
Jack Herrington
Рет қаралды 11 М.
Learn TypeScript Generics In 13 Minutes
12:52
Web Dev Simplified
Рет қаралды 295 М.
7 Design Patterns EVERY Developer Should Know
23:09
ForrestKnight
Рет қаралды 193 М.
Inertia 2.0: It's like Next but better (and you can use React!)
19:02
Theo - t3․gg
Рет қаралды 55 М.
КОНЦЕРТЫ:  2 сезон | 1 выпуск | Камызяки
46:36
ТНТ Смотри еще!
Рет қаралды 3,7 МЛН