I didn't include this, bind, type coercion, let dead zones, or any typical "i hate js." I also didn't include Dates because I am convinced that when it was conceived it was considered the best way to handle dates (have you seen other languages in the mid 90s? It was a literal copy of another library at tha time) But the items I included are truly awful items that are not found in other languages (that i know of)
@oskrm2 жыл бұрын
This list is a unique one. Not just using the same broken CD.
@itspravas2 жыл бұрын
Hello Mr @ThePrimeagent, Big Fan of your twitch stream. What is the green that you're using ? Or it is your wall painted in that color.
@DBZM1k32 жыл бұрын
I think the forEach case is acceptable because sometimes you just want to iterate over the value in some iterable type. So having it value, key allows for key to be ignored entirely giving (val) => {}; Doing it the other way is more complicated to solve for.
@beriu35122 жыл бұрын
I just read up on `let dead zones` what a peculiar thing, I've never stumbled upon it, and I'm still confused on how someone might reach that edgecase
@moodynoob2 жыл бұрын
Thank you for not using the same lame examples people often use!
@alangamer50 Жыл бұрын
as Fireship once said: 'JS is a language used exclusively to build things it's not supposed to'
@AEStolfo Жыл бұрын
48 likes and 0 comments? lemme fix it. ...btw fireship rules
@dannyarcher63708 ай бұрын
Right from the very beginning.
@munaq-jp2 жыл бұрын
“Any application that can be written in JavaScript will, eventually, be written in JavaScript.” - Jeff Atwood, founder of Stack Overflow, in 2007
@j-wenning2 жыл бұрын
My "favorite" bit about JS is the fact that you can still manage to create memory leaks in a GCed language, and because of the nature of the language, you're not meant to be actively thinking about that sort of thing, so you don't notice it til your program is whoring an abnormal amount of memory.
@j-wenning2 жыл бұрын
Oh yeah and good luck finding it. Especially if it's an installed dependency and not your own code.
@theodorealenas31712 жыл бұрын
Ouch. Is that common? I'm not familiar with web dev but it sounds strangely stupid
@j-wenning2 жыл бұрын
For simple applications, no. If you ever start trying to do something clever "just because the compiler/interpreter allows it", that likelihood definitely shoots up, though. Likewise when dealing with lower level data structures and such.
@pxh61292 жыл бұрын
"whoring an abnormal amount of memory" lmao. I like your phrasing
@DFPercush2 жыл бұрын
I imagine it tends to happen when you have a huge stack of async functions all holding "temporary" named variables full of references to other large structures.
@GeekMasher2 жыл бұрын
"The lords language Rust" made me laugh and started wondering... Are we all created in Rust? Are we all at heart Rustaceans? Are we all... Blazingly fast?
@theondono2 жыл бұрын
Light is a wave and a particle, Rust doesn’t allow this nonsense. If God had used Rust, quantum physics would make sense
@caerphoto2 жыл бұрын
If we are then I must be running in debug mode or something then :(
@tokiomutex41482 жыл бұрын
I for sure am
@raffimolero642 жыл бұрын
we’re all unsafe code and use garbage collection. somehow at the same time.
@tokiomutex41482 жыл бұрын
@@raffimolero64 speak for yourself
@leetaeryeo52692 жыл бұрын
5:36 This leads to one of my hot takes. Javascript is just the BASIC of the 2010-2020s. It's an approachable entry point for new programmers and people want to use it for everything, but that leads to it being used for things it has no business being used for. And everyone and their grandmother has their own library/way of doing things/dialect for any given task, which stretches the language beyond its comfortable limits
@hamm89342 жыл бұрын
Exactly
@aryandeora66312 жыл бұрын
But isn't that the BEAUTY of it? It can be bent forwards, backwards and upside down and it still works amazingly! Sure there are caveats but which language doesn't?
@leetaeryeo52692 жыл бұрын
@@aryandeora6631 I mean, it’s convenient, but I don’t think it’s ideal. Different tools/languages are appropriate for different tasks and trying to fit every task to JavaScript just feels like trying to turn a wrench into a hammer-sure, you can probably get to the same place eventually, but you’d have a way easier and better time if you just stopped and grabbed a hammer. Like, I wouldn’t use JS for systems programming, just as I wouldn’t use C for web ui programming and I wouldn’t develop an operating system APL.
@aryandeora66312 жыл бұрын
@@leetaeryeo5269 fair critique I take your point
@leetaeryeo52692 жыл бұрын
@@aryandeora6631 and I 100% see your standpoint as well. I’m a bit of a hypocrite because I work in C# which has libraries and frameworks for pretty much everything under the sun.
@reo1012 жыл бұрын
Only 5? You must've limited yourself pretty harshly :D
@ThePrimeagen2 жыл бұрын
have to draw the line somewhere ;)
@DMWatchesYoutube2 жыл бұрын
Just spreading the content, don't want people to be overwhelmed
@abrahamsimonramirez293310 ай бұрын
( ); much better @@ThePrimeagen
@RedStone5762 жыл бұрын
this is actually a really great video, talking about stuff that most people will overlook instead of complaining about it's quirks that basically everyone already know
@BuyMyBeard Жыл бұрын
I remember once making a procedural generation algorithm with a string sequence composed of a combinations of the characters ‘0123’. I wasn’t understanding why it was returning ‘ddeefinnu0123’. Turns out *undefined* was getting cast into a string and then sorted by characters in my algorithm. That had me stumped for a bit.
@peteryates3082 жыл бұрын
I enjoy working in JS from time to time, 0 indexed months get me every time. Every single time.
@user-lb1ib8rz4h2 жыл бұрын
sure, but that's not js-specific. it seems to have been copied from another language with java in the name...
@error.418 Жыл бұрын
@@user-lb1ib8rz4h Correct. Also we have a new system coming soon, the TC-39 Temporal proposal which is now in Stage 3.
@Yous0147 Жыл бұрын
@@user-lb1ib8rz4h That's true, but it's been a literal decade since dates have been a problem in Java, if not more. In JS, it's still the same.
@wlockuz44672 жыл бұрын
The regex one has actually screwed me over during my live exams, Luckily I was able to write a shitty function to replace what it was doing, but after the exam when I looked at why it was doing it what it was doing I had the same question, WHY?
@ThePrimeagen2 жыл бұрын
too clever by half of course
@error.418 Жыл бұрын
Why were you using a global flag in a test function, though? If you're just doing a boolean test, I can't think of a good example where you actually want the global flag. Without the global flag, this isn't an issue. If you are reaching for the global flag, you're probably intending to use a different regex function, not test.
@blt_r2 жыл бұрын
callback to Map.prototype.forEach takes (value, key, map) to be in line with Array.prototype.forEach which passes (value, index, array) to its callback. Because indexes for arrays are same thing as keys for maps
@claytonmarshall85642 жыл бұрын
Was about to comment the same thing. It would have been much worse had they changed the definition of the forEach callback for a single type.
@raffimolero642 жыл бұрын
for consistency the whole thing should just be for v,k if they want to go the route of “you iterate over values but can optionally get the index/key” unless there’s some design philosophy i’m missing, which is likely
@falias42 жыл бұрын
thats actually programming 101... In simple for-loops you work with index and in foreach you work with values. (same thing in other languages too) ... and the second parameter is simply optional
@AnalyticMinded2 жыл бұрын
I just started learning a bit of JavaScript a couple of days ago, so most of this video just flew over my head. But the important thing is that I watched it. :P
@ThePrimeagen2 жыл бұрын
agreed. its like a boomerang, it flew over, but its coming back.
@eventslooped2 жыл бұрын
@@ThePrimeagen Deep. And when it comes back it hits you in the back of the head
@travispulley52882 жыл бұрын
to answer "why?" @3:43 - because the key value isn't used sometimes in forEach blocks and it makes the code tidier to ignore a var/arg in this way, but also it's available when/if you need it. Madness? Perhaps, but there is a method to it
@GiveMeSomeMeshuggah Жыл бұрын
That’s what we get for not enforcing function arity
@mister-zen84919 ай бұрын
So, we are all trusting the JavaScript based on 'Maybe we need it, but maybe we don't'?
@Kriszzzful2 жыл бұрын
I was sure when I clicked that this is gonna be just another rant about implicit type conversion. Pleasantly surprised! I wasn’t aware of any of these issues lol
@ThePrimeagen2 жыл бұрын
Yeah! I tried to be original
@robainscough2 ай бұрын
Sadly that major issue with JS got corrupted into C# also with “var” … ugh, if you don’t know your type, just don’t code, go make coffee at a coffee shop or something.
@dealloc2 жыл бұрын
One could argue that forEach taking value first would make other functions easier to reuse for both Map/forEach and Array/forEach. Although, I personally never use forEach for either, since for loops allows for control flow and doesn't make it more unreadable.
@ry4nolson2 жыл бұрын
it also matches the usage of Array.forEach( (value, index) => { })
@weeb32772 жыл бұрын
Atwood’s Law: “Any application that can be written in JavaScript, will eventually be written in JavaScript.”
@fearmear2 жыл бұрын
Here's my suggestion for JavaScript future. Implement TypeScript as a new JavaScript spec and let browsers implement it. I'm tired of having to do "builds" in a scripting language.
@ThePrimeagen2 жыл бұрын
i effing hate the eco system.
@theodorealenas31712 жыл бұрын
But you also want browsers to pack files for you? And minify? I don't see why or how the browser could build for you.
@hacktor_922 жыл бұрын
@@theodorealenas3171 main problem is, doing a simple web ui is waaay more complex nowadays. you don't need angular for a(ny thing) simple blog website. you don't need to build anything complex for a simple task. and nodejs makes you feel like you're in hell.
@hacktor_922 жыл бұрын
i'd suggest some sort of apk-like, but for web apps, where you bundle your typescript files, along with assets and whatnot, and the rest is right there, in a single package file.
@theodorealenas31712 жыл бұрын
@@hacktor_92 sorry I don't have the experience to understand, but APK is a package format apparently. So, you wish to send like a tarball with the dir tree to the browser? You don't like doing the same, but fragmented?
@nicholaswood32502 жыл бұрын
I feel like most regex issues are really, “people not admitting that their input is not actually regular” problems. Email addresses are the classic example of something that seems regular but is actually not. The only reliable way to test that an email address is valid is to send an email to it and see if it works.
@KnThSelf2ThSelfBTrue2 жыл бұрын
This isn't a JavaScript but a node issue. If you spawn a child process in node, and that node process logs so much that it crashes due to running out of memory, the callback in the parent process gets passed an exit code of - not a number - but the JS value `null`... which JSers will know is dangerously close to 0. So anyway Jest hurts sometimes.... Don't log a bunch of stuff in your unit tests.
@circulardep6 ай бұрын
I encountered this problem recently. Jest crashed due to some API call I was making that was spamming warning logs.
@Rudxain2 жыл бұрын
2:55 actually, any kind of array of primitives will be shallow-copied, it's just that doing a deep-copy behaves exactly the same, because primitives aren't objects. Buffers are part of NodeJS. It seems the slice method does a pointer-copy (pass by reference) on Buffers. You should blame NodeJS, not ECMAScript
@wilfridtaylor2 жыл бұрын
Yeah my rule for javascript is contain it on the front end. Don't let it get into cicd to much or you end up with a really flaky build system.
@ThePrimeagen2 жыл бұрын
yep
@ethernet76411 ай бұрын
1. Regex 2. Buffer/Uint8Array slice 3. Map forEach 4. Bitwise casting to 32 bit signed 5. Community
@brunocmesquita2 жыл бұрын
I knew about your channel a few days ago. What a good content man. Really cool to watch. Contratz!
@niles_50032 жыл бұрын
One time I used an object as a lookup table rather than using a Map. Turns out you can index it with the names of the members of the built-in `Object` and TypeScript won't save you. It was kind of a funny bug because it's one of those things where you can know the codebase inside and out and then you see the output being a stringified method of `Object` and if you never realized this fact before you'll think to yourself, "Where on earth could we possibly have any code that could produce such a result?" Luckily I realized pretty quickly what was going on, but I could imagine that someone could have taken many hours to figure that one out.
@ThePrimeagen2 жыл бұрын
yikes
@error.418 Жыл бұрын
For example you used "entries" as a key?
@niles_5003 Жыл бұрын
@@error.418 The issue was not the data that was stored inside the object. The issue was doing a lookup in the object with an arbitrary string, and expecting it to return one of the values in the object or undefined.
@error.418 Жыл бұрын
@@niles_5003 Yeah, unless you set the object `as const` or use the `` prefix then it doesn't try to protect you, gotcha.
@EvanBurnetteMusic2 жыл бұрын
Having the user name multiple implicit return variables is the root of the k v mixup. I'm surprised more people don't talk about this! Fundamentally, if programmers cannot easily see how data is being transformed, they will not be able to find and fix problems.
@error.418 Жыл бұрын
It's not even really a mixup. Array functions like forEach, map, and filter all have consistent parameter order and in a sensible order since often for those functions the user just wants to use the value and not the index. That you can destructure the array returned by an Object.entries into [key,value] is a language feature that came much later and has a very different context. I didn't see this one as an issue at all.
@Yous0147 Жыл бұрын
@@error.418 The implementation detail of it is logical enough, the problem comes when you use it. Logically you'd always expect key, then value, as in key-value pair. Suddenly having to deal with turning that idea around because of an implementation detail is not only problematic, it's incredibly limiting. It's not the worst here , but this aspect has bitten me numerous times when using JS libraries.
@keatonhatch62132 жыл бұрын
With css at the stage it’s at and faster backend languages, JavaScript should be limited to web carousels and scroll loading.
@ThePrimeagen2 жыл бұрын
love this idea
@Prod-23 Жыл бұрын
@@ThePrimeagen To be fair, that was the intended use case ... THE ONLY INTENDED USE CASE I might add ... ;)
@inakiarias7465 Жыл бұрын
So how would you manage components and application state inside a browser app without JS? Go back to template engines? PHP? Lol
@keatonhatch6213 Жыл бұрын
@@inakiarias7465 you laugh but there’s a reason the largest of web apps still use them.
@inakiarias7465 Жыл бұрын
@@keatonhatch6213 Yea, the reason being their code foundation is already built on that...
@arsereg2 жыл бұрын
Principal Fullstack Lead developer here, 18 years of experience. I found your top things to hate about javascript really interesting and curious! Thanks for sharing! I think, in my personal opinion, that yes, this things can be really cumbersome, and it can lead to really messy situations where you face an additional layer of complexity. And of course, this things can leave you spending hours debugging your code for a piece of code that can be really difficult to find (Like the 'g' operator in the regex). However, the most I hate from Javascript it's a big portion of the community. Don't get me wrong. I've found many many many developers that create a really diverse and collaboratively community that ends up being helpful, thoughtful, and really really good educators about the perks and quirks of Javascript. However, particularly in Javascript and Python, I've also found the most toxic, irreverent and excruciating members I've faced. A few days ago, I found a video in a spanish-speaking channel focused on Javascript developers. The Video title was: "STOP using for cicles". That catched my attention and I went to watch the video. During the video, the presenter mentioned that instead of using "For" to iterate over a cycle, we should do it using a Array.map function, the reason: Legibility. However, during the video, the presenter also mentioned that the use of Array.map function allows you to "execute your code in a immutable way", which seemed kinda odd, because the very fact that you don't modify something during your code execution doesn't make it immutable. In the comments section, I saw one person mentioning how he disagreed with the video, because of multiple things. I added my support to this comment by also mentioning that the video was referring to Immutability when he wasn't actually doing immutability, as well as an improper use of the Array.map function. Not 5 minutes later, I got attacked by one of the people involved on the conversation saying that "Clearly I was just a junior developer that was scared of the Array.map function", and I just mentioned that even that you could achieve the same result using a for or an Array.map function, the Array.map function has much worse performance in terms of memory usage and time complexity. Long story short, I wrote a piece of code to demonstrate how using Array.map performed 28 times slower and could only manage arrays the 1/11 the size in comparison to use a for cicle, not to mention that the Array.map function semantical purpose is to map an object from one type to another, so using a map instead of a for would make the code "harder to read" because the semantics of the code itself. The next day, the youtube channel published a video that was titled: "Do not optimize your code" and pretty much what the video talked about is how nowadays, computers are so powerful that "small" optimizations are unnecessary, using the code I provided in the previous video. To finish up, I just decided to stop wasting my time with someone who's motto is: "Dont optimize your code". The person kept attacking me for around 3 days, trying to pull me into arguments. And although I've found amazing people that makes a great great great community around Javascript, these kinds of interactions are not rare.
@talhaakram2 жыл бұрын
There is this strange culture of putting people on pedestals and treating their opinions as facts or the only right way of doing things. If someone disagrees with it, they are treated as lesser skilled developers who simply 'don't get it'.
@arsereg2 жыл бұрын
@@talhaakram Absolutely agree! Also, quite interesting is that as a response for being confronted, he decided to attack me as a person rather than discuss on the technology. This is something we shouldn't do at all when discussing about best methods
@upcomingweeb1362 жыл бұрын
I actually faced similar experience when I tried explaining to some of my colleagues why typescript is better than JavaScript.
@arsereg2 жыл бұрын
@Upcoming Weeb! So sorry to hear that. People are afraid of facing new things or not knowing about something. Honestly and personally, I'm glad when I found something I don't know so that I can study it, and I believe that being so aggressive against such scenarios is definitely a lost opportunity to grow. Sometimes, I think that languages get followers that treat said languages with religious fervour. And are willing to negate reality itself just to attach themselves to their point. This person I was talking about before insisted that the use of Map was better, despite the fact that it performed much, much worse, could handle much fewer data and at the cost of code semantics. His words: "This is the javascript way", reveals this religious fervour I'm talking about. For some reason, he thinks that Javascript existed in a separate realm, where code-optimizations, design patterns, algorithms and data structures don't apply to Javascript because "that's just how javascript works". And he's not willing to accept that he's wrong. That also shows a bit of immaturity in the developer as well. In my personal case, I really love and enjoy working with Java/Kotlin. However, I know that Java/Kotlin have their perks and that sometimes it is not the best fit for all. I'm willing to accept that it is "not the best language", but I do not think such a thing exists. Once again, I'm sorry that you had to pass through that trying to educate your colleagues about typescript. However, you are one clear example of how a community around Javascript can also be a really nice place. Let's keep it that way :D
@talhaakram2 жыл бұрын
@@arsereg 💯 agreed.
@__idan__2 жыл бұрын
Modern life as we know it is standing on the thin legs of JS, I'm scared.
@ThePrimeagen2 жыл бұрын
hahaha
@scottiedoesno2 жыл бұрын
Silly footgun (and one that does somewhat fall into your type coercion moratorium), but checking whether a variable is undefined vs truthy or falsy as a practice (e.g. foo && ... ) has just caused no end of headaches for my applications in the past. Probably more of a best practices thing and goes back to the community being the problem, but it's still unbelievably aggravating.
@ThePrimeagen2 жыл бұрын
yeah, i really hate that one.
@bigmistqke2 жыл бұрын
I ve written a lil package for it. Rn it's pretty dumb, it just checks if the falsey is not 0 or "", cause those are the situations that i came across that really tripped me up.
@kevinbatdorf2 жыл бұрын
This is a React concern. As a policy, always check item?.length > 0 and use a ternary
@hakooplayplay32122 жыл бұрын
@@kevinbatdorf yea, ?. I a nice one, but im workin on aws lambda and we have node12 here ... So damn tired of this && checks
@niles_50032 жыл бұрын
Could you give an example of a situation that trips people up? And were you using TypeScript at all?
@earthling_parth2 жыл бұрын
Yayy! We will finally get to learn the history behind the name - Primeagen when this channel hits 100K subs. My theory is that it's something related to the 'next-gen(eration)' of the Optimus prime and/or maybe gaming.
@ThePrimeagen2 жыл бұрын
not even close
@xBZZZZyt2 жыл бұрын
02:58 you can use Uint8Array.prototype.slice.call(buffer,start,end) to always deep copy
@jazzochannel2 ай бұрын
deep
@kelvindecosta53502 жыл бұрын
I don't necessarily hate this about JS / Web ecosystem, but I don't like it either; there are so many different tools that can combine to do the same / almost the same task. When I started, I was introduced to tools like ES Lint, TypeScript, Webpack, etc. A while back I had to deploy a no longer maintained project ("fbctf" for those that are curious) and I was introduced to a relic called Grunt. Now everyone is hyped about Deno, Bun, Vite, Snowpack. It's nice that the community is building on each other's work but I can't help but feel like everyone is reinventing the wheel. I can't imagine how new developers feel about this. The same can be said for Python's dependency management solution. I don't remember the XKCD strip that discusses this obsession with creating new tools that do pretty much the same thing.
@charlesselrachski342 жыл бұрын
nim/go/zig/phix-lang/vlang bro , problems solved... use the better languages
@FADHsquared2 жыл бұрын
The xkcd is something like this: There are 14 competing solutions, ha, we have to make a solution that works for everyone! Now there are 15 competing solutions.
@dealloc2 жыл бұрын
Not unique to JS. C/C++ has how many compilers and tools for building C/C++ source code? The thing is that as languages evolved, so does the tools; As things become more standardized, tools tend to follow the good standards that makes it easier for developers to provide good UX. First DX was at the front, now it's the UX and the tools we have allows for better UX while also providing good DX (in terms of not having to configure everything from bottom up to provide good UX) by being more opinionated.
@SimonBuchanNz2 жыл бұрын
As someone who is currently sitting on an internal custom task runner script that's grown into an entire library with a plugin system, variable expansion, config file validation, dry run, caching, etc....? It's because it's so easy to get the 80% you care about done when you hit some case that doesn't work well with the existing tools, and it's so easy to add features after that. Bundling is a great example of this, where your internal crappy tool can get thrown together in an afternoon and be useful, and the existing tools are good at one thing but bad at others. Even then, there are only really two "real" bundlers out there right now: webpack and rollup, and the rest are all written on top of that (though the awesome swc project is working on one too, which should be amazing for my build times!)
@SchneiderRob2 жыл бұрын
I wasn't subscribed. I thought I was a subscriber. But I was not. Now I am. I hope you hit 100k soon dude. Love the videos. Awesome show! Great Job!
@ThePrimeagen2 жыл бұрын
thanks man! i am so so so close!
@floppa9415 Жыл бұрын
One that also got me good a few times are the standard lib's array functions. Some of them like filter or map return you a shallow copy but some like splice, sort, reverse don't.
@studiousllama4776 Жыл бұрын
omg seriously. Thankfully all the major browsers now support toSorted, toReversed, etc., so hopefully soon we'll be able to start using those instead
@Chris-ln3xe2 жыл бұрын
1:34 What is the alternative to regex? how do you validate input to an API?
@DragonRaider5 Жыл бұрын
From my perspective the forEach is reasonable, because for arrays etc. it also gives you value first, key second. Mabye the issue was introducing these functions in the first place, no idea why for shouldn't cut it.
@darkosimonovski3653 Жыл бұрын
thank you
@craigasketch2 жыл бұрын
toFixed(2) returns a string got me today. Basically the entirety of Js's number system.
@u9vata Жыл бұрын
When interfacing JS or TS people from my C++ code what I hate most is that they silently send you json with all kinds of shit in it - that is invisible to them because of JS-sloppyness... Like when they randomly send "empty string" instaed of null, undefined as string and such horrible pieces of shit. My code is having tens of special cases for parsing their fucked up shit :D
@KoltPenny2 жыл бұрын
6. Starts with JAVA
@altairbueno56372 жыл бұрын
Even java knows about OR numbers
@ThePrimeagen2 жыл бұрын
proof its bad
@Kotfluegel Жыл бұрын
2:54 I don't get this part. A buffer is just an array of primitives. Shallow copy or deep copy, doesn't matter. It's the same. Or do you mean, the slice method creates a view on buffer with changed begin and end indices?
@aymenmt12 жыл бұрын
Math.max(); // -Infinity Math.min(); // Infinity
@ThePrimeagen2 жыл бұрын
... that cannot be real
@hamzazouari9992 жыл бұрын
@@ThePrimeagen i actually had to test it, he is right, oh hell nauugh
@basudevadhikari222 жыл бұрын
My goodness!
@pryflack36462 жыл бұрын
OMG it’s true! 🤣
@astroid-ws4py2 жыл бұрын
Holy Fk, It is true, Thanks god I am not working with JavaScript.
@quentincaldway2 жыл бұрын
The"Bruh" gets me every time! 🤣. Now I need a video on 10 things you Love about rust....Yes....I'm asking for 10 lol. You're hilarious....Your brain oozes with knowledge! Appreciate the value you always give brother! Hope you catch a break with that project you're working on with Netflix lol can't imagine. ~Blessings!
@maxwellhunt3732 Жыл бұрын
The fact that the condition undefined > 0 simply evaluates to false and doesn't cause any sort of error has caused me endless pain debugging at work. When there's a function which isn't working probably, returning undefined instead of a number, which then gets compared to 0 and there's no way of knowing.
@t3dotgg2 жыл бұрын
Banger video tbh
@amirosman87972 жыл бұрын
Totally agree with everything you say, but enough with JavaScript we are waiting for the Elixir video, we need to know your thoughts on Elixir against Go, Rust and JavaScript.
@b1chler2 жыл бұрын
The single most annoying part imho is the lack of standards. There r 100x different ways of doing things one more ugly then the other. Crap gets added with every JS version but nothing gets deleted. It’s just like a teenagers room. Dirty, stinky and full of smartasses.
@jonathanprivitera93942 жыл бұрын
Shoutout to all these Italian hackers, Daniele Scasciafratte spitting fax on that tweet at 0:09 Thanks to Matteo Collina to for accepting the devhour invite!
@oskrm2 жыл бұрын
Clearly, [] is the same as 0. IDK how you'ren't seeing it.
@user-he4ef9br7z2 жыл бұрын
If you're drunk they even look the same.
@kristun2162 жыл бұрын
Loose comparison do be like that in dynamic languages
@ThePrimeagen2 жыл бұрын
you are perfectly correct, drunkeness is the real reason [] = 0
@KvapuJanjaliaАй бұрын
0:10 Windows Defender anti-virus allowed you to run JavaScript in OS kernel (It was an exploit, but still).
@konga81652 жыл бұрын
Love you man! Keep it up!
@mjrduff-gaming23652 жыл бұрын
Last time in typescript, I figured out that, any regexp for an HTML file does not show you all groups that match you regexp. If you write it like that /href="(\/[\w]+)"/g or as new RegExp(/href="(\/[\w]+)"/, "g") It matches only the first match while using exec, but string.match shows you all matches. But no groups, only full matches
@dealloc2 жыл бұрын
Don’t use regex to parse HTML. Ever.
@tah34602 жыл бұрын
Sort() defaulting to sorting lexiographically, despite dealing with numbers.
@jsonkody2 жыл бұрын
Hmm .. if you show that FOR and FOR_EACH next each other it looks strange but it's kinda consistent from other standpoint -> FOR just iterate on key:value pairs while those functional methods like .map .filter .forEach .. they use index just as optional second argument(or key in this case) but they always use value as first 'thing'/argument/whatever -> and they work somewhat like this in many languages I think .. so it does make sense :D Thx for the video
@arsnakehert2 жыл бұрын
The (value, key) in forEach actually makes sense and is kind of expected, typically optional arguments in programming languages come in a “most optional comes last” kind of fashion, and typically with forEach you only want to iterate over values, with the index or key being the optional argument in the lambda, so it makes sense that it comes after the “less optional” argument
@ThePrimeagen2 жыл бұрын
This is only an argument in js that makes sense. Go, rust, cpp, lua, who knows else don't do this
@theodorealenas31712 жыл бұрын
It clicked instantly to me, when I first used it a few months ago. And that's the reason it clicked too. But yes Python doesn't do that. Also I thought I'm the only one who comes back to this video periodically
@arsnakehert Жыл бұрын
@@ThePrimeagen Sorry, when I said "typically in forEach" I meant typically in forEach as used in JS specifically
@CheefCoach Жыл бұрын
@@ThePrimeagen Lucee does. I am pretty sure that php is doing that as well.
@GreyDeathVaccine Жыл бұрын
@@CheefCoach It's wierd in PHP. We have optional indexing but it is in correct order. With index foreach($array as $key => $value) Without index foreach($array as $value) So it is obvious. Just look for => 🙂
@Nellak2011 Жыл бұрын
One thing that JS does that messes with me when I try to do FP in JS is that JS passes the variables by reference, and I can accidentally mutate state, even when I am trying my best not to. This leads to unexpected behavior and confusion because my "pure" function is making side effects.
@javascripttalks2 жыл бұрын
I completely agree that JavaScript was designed for web UI dev and It should be used that way. Most UI developers don't need bit manipulations anyway. Just because you can develop low level networking stuffs with js, doesn't mean you should do. I think developers nowadays are too lazy to learn another language and keep pushing javascript everywhere. Some people think C/C++ is for old people and JS is cool :D
@error.418 Жыл бұрын
I really hope you're not writing backend with C/C++ when we have much better languages for that domain...
@sct8482 жыл бұрын
Man your videos are very entertaining
@jandresfg2 жыл бұрын
Storing functions as consts will always rub me the wrong way, but I've become used to it. Also, the fact that a function may or may not receive an argument is just weird -it always frustrates me when I realize something I needed in my code was given to me all along via an angument I neglected until now 😑
@SimonBuchanNz2 жыл бұрын
As in, when you're implementing a callback? That's one of the less talked about benefits of Typescript, the editor will tell you what arguments you can add. This one doesn't even need you to be writing Typescript, just have typings installed!
@xdman29562 жыл бұрын
all the key, value vs value,key vs wtf are the arguments make js hard to write without help of an ide, however ide suggestions mitigate this this is a bit worse emotioinally, cuz you realize you wasted time for worse reinvention of a wheel, tedious and rather dumb
@effoffutube Жыл бұрын
I like how you've twisted your rage into joviality.
@emreaka39652 жыл бұрын
0:13 I'm glad that I'm not one of those guys. I only use javascript to dev applications that will run on browsers because I had to! Nowadays I can also use the language of my choice ;) thanks to Web Assembly.
@nwachukwuujubuonu63452 жыл бұрын
What alternative to regex would you recommend?
@codemastercpp2 жыл бұрын
Heyyyy, that javascript tea pouring meme was provided by me :D
@vladimirreyes1938 Жыл бұрын
The strong point of JavaScript is it's Aquiles Heel, If you try to run JavaScript from 20 years ago, in a latest version of V8 it will still run, an run better then it did 20 years before. trying to keep the compatibility of everything that you've written makes it harder to create new features y fix everything that was mistake.
@srirajnair25942 жыл бұрын
You said not to use regex , but what is the other alternative to that?
@GiveMeSomeMeshuggah Жыл бұрын
For HTML, use a dedicated parsing library, since HTML is not a regular language. If you’re trying to parse a regular language, there are libraries that allow you to write out a grammar and visit each node of the parse tree. This is a lot less brittle than trying to debug a manual regex parser when the spec changes. And then if you have a use case that’s not a regular grammar and/or you can’t use a library for, (I’m so sorry) reading char-by-char and parsing that way will often be faster and less error prone than a regex.
@michalatlas28652 жыл бұрын
Alright, awesome, I agree that regexes are kinda hard to verify and I'll use them only for quick shell scripts and for find and replace........ What now tho? You can't just say avoid something that's used so widely (ofc, I understand this is just a short video), should I write a grammar and a parser for it instead? Tbh, now I think about it that would be kinda cool. But tell me, what's your idea of a replacement?
@ThePrimeagen2 жыл бұрын
honestly, plenty of easy things. take this for example. you want to validate its a vim cmd. well.. you probably reach for a regex. Hold on devil. let index = cmd.chars().position(|c| !c.is_ascii_digit()).unwrap(); let (num, cmd) = cmd.split_at(index); let num_res = str::parse::(num); Rust code. Its easy, its easier to understand than a regex, and its performance is well understood.
@tiberius92832 жыл бұрын
@@ThePrimeagen What about stuff like email or particular codes like IBAN? can you do without regex?
@bcpeinhardt2 жыл бұрын
The fact that every function is a closure (I realize this is a fundamental feature of JavaScript and one of the reasons people love it). This is less of a footgun and more of a death by one thousand cuts situation. The fact that you can't trust any single javascript function signature to let you know what data a function interacts with makes it that much harder to reason about your code, and I think this slows down refactoring especially (or at least I notice it slowing me down). If you've ever read the body of a javascript function and thought "Where the fuck is that variable coming from" you've experienced this.
@shimadabr2 жыл бұрын
Having studied that topic recently after seeing this feature a lot in conjuction with callbacks, i agree. It's so strange to me to have data "leaking" downstream to functions on the same scope. The fact that it's so useful and heavily used makes me wonder if it's bad or not (i'm a beginner, so idk)
@user-lb1ib8rz4h2 жыл бұрын
@@shimadabr lack of predictable behaviour makes it harder to write code with less bugs. if someone's aware of the behaviour and using it, i feel like there's easier ways to write clearer code?
@briansalkas349 Жыл бұрын
No custom equality for maps. If your key is an object you can't use a field to check if its already there. This has caused me to either avoid maps or use maps in very weird ways.
@BlitzkriegHD Жыл бұрын
Gotta say, right off the bat you mentioned the global regex flag and I audibly YELLED after realizing THAT was the reason of some annoying bug in a project I have been working on. Strong start hahaha
@anisoseryx2 жыл бұрын
Lemme add number 6, this keyword with functions When I started to learn I used a normal anonymous function instead of arrow function within a class, i never suffered like that hour all I needed was the arrow function Number 7 threading: the reason why I switched to another lang whenever I needed threading it's pain =(
@ThePrimeagen2 жыл бұрын
hah. I didn't want to talk about this. everyone knows about this being a bit confusing. And threading! Its the reason why people _like_ javascript unironically.
@sagarrajak69962 жыл бұрын
Use promise brooo
@anisoseryx2 жыл бұрын
@@ThePrimeagen I liked at first too I was like woaaa it's cool but it's absolutely painful xd
@parlor31152 жыл бұрын
@@anisoseryx No it's not. Promises is a really great API and I see a lot of languages having a similar approach to async programming.
@anisoseryx2 жыл бұрын
@@parlor3115 the prove isn't with promises I use them all the time dw, it's for certain cases where threading becomes painful like when I made a discord api wrapper I needed some variables to be shared and it was a real pain to get it done since my variables were constantly changing and needed to be updated across all threads, you can see how complex this problem can be by checking djs code they do that too. Long story short threads are nice but Javascript isn't made for this and I prefer to use another language like csharp to tackle it
@Manana7016 Жыл бұрын
You covered a lot of stuff that I don’t think is covered in Bootcamp and tutorials. Seems you tell things like they are. I’d be really interested on your take on self-taught developers. Not just no CS degree. Self taught with no degree period. How well do they do?
@Kaiju33012 жыл бұрын
JavaScript isn’t my favorite but I keep a toaster in my bathroom with a php sticker on it just in case.
@ThePrimeagen2 жыл бұрын
this seems to be the most reasonable
@gpcureton2 жыл бұрын
I've watched the Twitch stream you made a few days ago where you wrote a plugin. I bounced around the VOD looking, but I couldn't figure out what the hell it was for. Was it so you could do the "unfolding code" animation starting at 2:56?
@MrSciencedude2 жыл бұрын
Just subbed to get you to 100K!!!! also my first comment ever
@alexIVMKD2 жыл бұрын
Reminded me of a clip from Fridman's podcast about how "less than ideal" languages are so widely used, quite the mystery honestly... It was my first language but I am seeking to accept the lord in my heart by learning some rust-lang, hopefully
@justafreak15able2 жыл бұрын
@ThePrimeagen Can you make a video on how to replace Regex with a better solution for field validations and all.
@jaredsmith58262 жыл бұрын
In addition to the things on your list and the things you deliberately left out in the pinned comment, I would say the thing I hate the most about writing Javascript is the lack of a standard library (insert leftpad joke). How many devs start every project by pulling in lodash and moment and... but the worst part about it to me is how it leads to tragicomically fragile transitive dependency graphs: you pull in some huge popular library and you look at their dependencies and half of them are throwaway utility functions and those haven't had an update in the last 5 years. Or the author of one of them gets butthurt over something and yanks it, breaking the internet in the process. You know, the little things. Oh, and PHP has the same inconsistent API issue: some of the "find this thing in a data structure" functions are needle, haystack and some of them are haystack, needle and no one can ever remember which is which. Of course, PHP pretty much sucks in general, so maybe not worth making fun of.
@ThePrimeagen2 жыл бұрын
ok, this is a good call. the lack of std is mind boggling
@Winnetou172 жыл бұрын
PHP pretty much sucks in general ? *massively triggered* Have you even checked it in the last 10 years ? I'll fight you to death on this bro!
@jaredsmith58262 жыл бұрын
@@Winnetou17 not quite ten but it's definitely been at least 7 or 8 years since the last time I coded in it. So maybe it's better now? I've never actually met somebody actually willing to defend it as a language (plenty of people defend it as a technology choice while conceding its flaws).
@Winnetou172 жыл бұрын
@@jaredsmith5826 Well, getting more serious now, it actually improved a lot. Since PHP 7.0 (now we're at version 8.1), I'd say it's a decent language. Much more static typing, less bugs, less exotic behaviours and hidden errors because 0.1% might want that feature, and general modern features. It has pretty regular releases, though it also followed the extremely annoying and stupid trend of only supporting a version for a couple of years, but other than that, it's going well. There's still some of that haystack, needle and needle, haystack nonsense, because backwards compatibility (ugly or not, there's millions of websites written in PHP, so backwards compatibility is very important). I like it as a language because you can easily grow with it. You can start by simply having a really simple program with several functions and ifs and fors, fully procedural. And you can expand easily and at your own pace towards fully featured OOP style, with namespaces, interfaces and traits, with autoloading. You get the idea.
@SirusStarTV Жыл бұрын
Array.prototype methods use (value, index, array) order of arguments (reverse of array[index] -> value), you don't always need index of value when iterating over arrays. Objects aren't iterable so "for of" doesn't work for them, only "for in" for iterating over keys only, Object.entries() does give them iterable functionality and neat syntax of destructuring like [key, value].
@kinositajona2 жыл бұрын
As a library maintainer... my least favorite part of JS is the lack of ECMAScript feature support among the various bundlers and frameworks. The number of issues where "it doesn't work in my React Native app bundled with this new bundling framework that doesn't even say it guarantees support for RN... but for some reason I thought it was your fault so fix it now, slave!" is literally the body of the issue are too damn high... I swear, I tried moving from ES5 to ES6, and people complain about everything. BigInt has been stable and in every browser and NodeJS install under the sun for almost a decade and literally people freaked when I tried to use it and it broke their shit. WHY ARE WE ETERNALLY STUCK AS LIBRARY DEVS ONLY USING ES5!?!?!?!? *pulls out hair* I need a coffee, but it reminds me of JavaScript so I've sworn off the stuff.
@dealloc2 жыл бұрын
Not sure this is bundler issue more than it is configuration/user issue. Most bundlers supports downlevelling ES (i.e. with Babel). Although not unique to JS world, I agree that tools can make end-user think OSS library maintainers are at fault for their broken software is a problem.
@SimonBuchanNz2 жыл бұрын
This is actually a case where JS is ahead of other languages, if not perfect: Rust literally just updated their minimum Linux kernel version from 2.6.32 to 3.2 - which came out nearly a decade ago. At least with JavaScript's bundling and polyfilling environment you have a fighting chance of taking a library published using all the latest and greatest features and running it in IE5.5 for Mac. I mean it sucks to do so, but you can...
@Rodriyabala2 жыл бұрын
Prime you've uploaded a video working with the rust framework for web dev "Yew", with assembly around is there something like that but for go?
@ThePrimeagen2 жыл бұрын
that i don't know
@marcomongalo33282 жыл бұрын
Not using regex patterns? What's the alternative you guys use?
@ThePrimeagen2 жыл бұрын
parser
@marcomongalo33282 жыл бұрын
@@ThePrimeagen which type? Although parsers require more code and are slower for short convoluted patterns. Don't you think? On the other hand, parsers are more easily read by humans. Wouldn't regex be "blazingly fast" compared to parsers ? Don't get me wrong, I love me some PEGs
@stephenJpollei2 жыл бұрын
I actually really like regexps, but never use the g flag. I also tend to write regexps that are anchored and don't have multiple ways that they can match. I kind of wish that raku style regexps and friends were available in more languages. The using signed 32bit for bit-ops is super gross.
@bernhardposselt6467 Жыл бұрын
[1, 2, 10].sort() => [ 1, 10, 2 ] Because sort coerces everything in the array into strings in the sort method. HF debugging
@taragnor2 жыл бұрын
My personal favorite is that NaN (not a number) has the type "number."
@RayZde2 жыл бұрын
My JavaScript ML algorithm predicts your channel is going to skyrocket.
@nathanp33662 жыл бұрын
Don't even know javascript because I am a scientist but I still watched the whole ting.
@amandapeine6745 Жыл бұрын
In NodeJS, child_process exec & execFile just kill your process of it outputs more than 1 MB of data. Even if you are actively reading it.
@davidattlee27342 жыл бұрын
I want that backstory to the Primeagen. 100k special plz.
@FPChris2 жыл бұрын
I took “The Raytracer Challenge” with JS. Because JS *is* everywhere. Script wait dialog warnings during pixel level for loops FOR DAYS.
@ThePrimeagen2 жыл бұрын
jeeze
@FPChris2 жыл бұрын
I mean just because you can use JS doesn’t mean you should. I “thought” because the book was presented in pseudocode that JS would be easy to fix as I went along. There’s a guy on YT that did it with Rust. I’m sure it’s blazing.
3:42 bruh, I hate JS as much as anyone here, but you're ignoring something obvious. forEach is usually used for iterating over values, indices are (almost alaways) useless. Image having to write `arr.forEach((_, v) => v)` everytime you want to ignore the index. This is why `for x of array` iterates only over values. You can do: ``` [...Object.entries(arr)] .forEach(([i, v]) => {}) ``` To get the order you expect. Of course, that code has too much boilerplate, so we'll have to wait for the iterator-helpers proposal to reach Stage 4
@sadikkadom95662 жыл бұрын
Is it possible to create the C language from Javascript to make Javascript faster?
@ivoevansstorrie39162 жыл бұрын
This got me once: function average(averages: number[]) { return averages.reduce((sum, n) => sum + n) / average.length } we divide by average.length, not averages.length, and average.length is for some reason the number of arguments the function takes.
@leilafarahmoussa2 жыл бұрын
This is cursed
@jazzochannel2 ай бұрын
the reason being every object in jevascrapt has a prototype. learn to
@FaridAbbasbayli2 жыл бұрын
To me, it makes perfect sense that `Array.forEach()` has value as the first argument of the cb, cause you don't need the index most of the time for a simple and quick iteration, so you just do `Array.forEach(item => processItem(item))`. When doing something more complex better to use regular for loop anyway.
@talhaakram2 жыл бұрын
I think Ruby does this better where the `.each` method does not pass in index, to iterate with index you have to use `each_with_index` which makes things very obvious. So `Array::each` and `Hash::each` both work they way they should (only values in case of arrays and k, v in case of a Hash) and you can always just use the `Hash::values` to get any HashMap's contained values.
@haras-unicorn2 жыл бұрын
its also because there are no overloads in javascript and functions can take any amount of arguments just discarding the unused ones so the forEach implementation might as well just be: const forEach = (a, f) => { for (const [k, v] of a) { f(v, k) } } and it would work for callbacks taking just a key or a key and a value.
@ezg52212 жыл бұрын
Lucky I found that day 1. Figured I could just call _.forEach(console.log); but that captures all the possible arguments, meaning value, key and the entire array for every element in the array.
@animedreamz20092 жыл бұрын
I’m surprised that Netflix isn’t using erlang or elixir given how good they are for multi connection services. Imagine having to rewrite the whole backend with rust…but I guess you can use wasm so it could all be rust.
@ThePrimeagen2 жыл бұрын
i would love to write a backend in rust
@oskrm2 жыл бұрын
@@ThePrimeagen Any reasons why higher-ups don't use Rust?
@MarcosVMSoares2 жыл бұрын
Elixir is life bro.
@animedreamz20092 жыл бұрын
@@MarcosVMSoares I heard that WhatsApp uses erlang and how they were able to scale because of its concurrency and ability to run on low end tech.
@raffimolero642 жыл бұрын
@@oskrm not as tried and teated as other languages, harder to find devs for, has a reputation for being associated with blockchain hopefully time will fix these issues
@artemeelemann317 Жыл бұрын
The forEach for map works like just for regular array when you use forEach you get (value, index) not (index, value)
@ThePrimeagen Жыл бұрын
yes and its really dumb for a map i have several questions for those forEach'ing over map, especially value first. its a terrible api design.
@jepemz8732 жыл бұрын
An object will keep the keys in order of insertion... except for numbers. I know I should have used a map but objects serialize easily.
@matiasbpg2 жыл бұрын
First, love your videos as always. Didn't you leave Netflix? I remember a vlog you weren't happy at how that went. Now I'm not sure lol, but if you returned to Netflix I just wanna say I'm happy you.
@ThePrimeagen2 жыл бұрын
if you watched the full vid i explain at the end someone brought me back in :)
@matiasbpg2 жыл бұрын
@@ThePrimeagen I missed that completely hahaha. Anyways happy for you it worked out!
@KirkWaiblinger Жыл бұрын
setTimeout(f, 0) // f is instantly executed setTimeout(f, Infinity) // f is instantly executed
@ThePrimeagen Жыл бұрын
... no way
@KirkWaiblinger Жыл бұрын
@@ThePrimeagen i see that you just dropped a whole video on this. Nice!
@jazzochannel2 ай бұрын
well, if it's infinity then it might as well be now. are you trying to suggest that you UNDERSTAND infinity? of course you're not. and neither is jevascrapt.
@KirkWaiblinger2 ай бұрын
@@jazzochannel hmmm... I have a physics and math degree that have given me enough of an understanding to know that something that happens an infinitely long time from now will not happen immediately.
@brentlio5578 Жыл бұрын
The best place to use regex is for things that you know for a fact that has a very rigid and predictable pattern. Like repetitive codes and languages. Or just a quick tool for extracting data from large amount of text that you need very often. What regex is really not good at is filtering things that are potentially bad for your purposes.