9 Reasons People Hate JavaScript

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
JavaScript the most popular programming language in the world and also one of the most hated languages but why why is there so much JavaScript hate let's be honest JavaScript has baggage it was created in 1995 by this dude in just 10 days as a tiny scripting language to add a bit of interactivity to web pages it wasn't meant for the massive complex apps we built today so naturally it's got some weird behaviors that can make everyone even coding Pros confused for example JavaScript automatically converts values from one type to another in operations that involve different types this is supposed to make JavaScript flexible but it can lead to some confusing unpredictable results for example if you add two empty arrays we get an empty string if we add an empty array to an empty object we get the string object object but if you swap the order of operants we get zero and if you add two empty objects we get not a number in JavaScript we have two operators for comparing values loose equality or double equals and strict equality or triple equals if you accidentally don't type that extra equal sign you're in for a surprise here's another funny example with double equals number zero equals the string zero now number zero also equals an empty array so if number zero equals empty string and an empty array we should assume that a string zero equals an empty array right nope they're not equal here's another funny one let's say we have an array of numbers like 1 100,000 21 30 and 4 if we use array. sort to sort this array we get the same result why because by default the sort method sorts elements as if they were strings to have JavaScript sort numbers correctly we need to provide a compare function to the sort method the other issue is that JavaScript has two special values for representing no values null and undefined a lot of people especially beginners don't know the difference but they are not the same thing undefined means a variable has no value assigned but null means the value is intentionally empty another problem is that this keyword which is supposed to refer to the object that it belongs to but it can have different values depending on where it's used and how the this keyword shifts and morphs confusing developers as it changes context now JavaScript pretends to have classes but it doesn't JavaScript classes are just syntactic sugar over Constructor functions JavaScript uses prototypical inheritance which is different from the classical inheritance model we have in languages like Java or C the other big problem is the module system in JavaScript JavaScript was not initially designed for large scale applications so it didn't have a native module system like languages like C Java or python so over time people came up with various module systems like commonjs AMD UMD and finally the official OS script modules the problem problem is each of these module systems have their own syntax and conventions and a lot of older projects still use the older systems this means we have to translate between module systems using tools like webpack or B which adds another layer of complexity now typescript was created to address these issues it's a super set of JavaScript that adds static typing and other features it can help catch errors and make large projects more manageable but it's a whole other language you got to learn on top of JavaScript plus there is an extra build step involved because we have to compile our typescript code into regular JavaScript code so browsers can understand it that's why some folks find typescript adding an extra layer of complexity to their projects so they have been moving away from it the other problem with JavaScript is it's chaotic ecosystem of packages libraries Frameworks and even meta Frameworks every day you see a new medium or Twitter post about a new JavaScript tool or framework that can do something twice faster while complicating the project tfold Junior devs jump up and down on how amazing it is while the project gets more entangled in yet another blackbox JavaScript tool the problem is by the time you learn a new framework it's already outdated and replaced by something newer and shinier that's why folks from other backgrounds sometimes get the impression that JavaScript devs spend more time chasing the shiny new tools than practicing core coding principles and best practices now on a positive note JavaScript runs everywhere it's the language of web but also runs on servers tons of jobs require JavaScript so even with all the quirks it's a language that pays the bills if you enjoyed this video give it a like And subscribe for more videos like this
Info
Channel: Programming with Mosh
Views: 66,520
Rating: undefined out of 5
Keywords: javascript, javascript for beginners, learn javascript, web development, javascript crash course, programming with mosh, code with mosh, mosh hamedani, javascript tutorial, learn javascript for beginners, javascript basics, javascript programming, programming tutorial, js tutorial, javascript lesson, javascript 2024, front end, programming, coding, javascript important parts, javascript essentials, javascript summary
Id: J-graiyPhpw
Channel Id: undefined
Length: 4min 45sec (285 seconds)
Published: Fri May 17 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.