8 ways JavaScript is just... different.

8 ways JavaScript is just... different.

Dreams of Code

6 месяцев назад

58,615 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@sideone3581
@sideone3581 - 10.02.2024 11:18

I was thinking not not use js on backend for any reasons at all
now You gave me more clarity why I was thinking that

Ответить
@MrXerios
@MrXerios - 09.02.2024 22:19

8 more reason I never want to have to learn javascript.

Ответить
@roccociccone597
@roccociccone597 - 09.02.2024 20:51

JS doesn't do anything the best. It's quite literally a mistake.

Ответить
@Spencer-wc6ew
@Spencer-wc6ew - 09.02.2024 17:53

I'm imagining javascrip will add a ==== operator at some point that's the same as === except "NaN ==== NaN" is true.

Ответить
@jouebien
@jouebien - 09.02.2024 06:25

and in a number of cases a JSON responses from a server will omit JONS keys with values of undefined. Which is why you'll often see null in JSON data over undefined.

Ответить
@azuretan
@azuretan - 08.02.2024 18:32

This is “wat” all over again

Ответить
@davidgrajalesmirage
@davidgrajalesmirage - 08.02.2024 17:01

The more I watch this the more I an conviced to not use Javascript at all. Design flaws are not "features". Javascript type Management is worse than working with C pointers

Ответить
@cewla3348
@cewla3348 - 08.02.2024 11:22

typescript is useful because arr.prototype.sort() actually WORKS because you can make just a number[]. My editor (actually a game) throws an error if you try to use number[] outside typescript.
It doesn't support typescript.

Ответить
@terry-
@terry- - 07.02.2024 15:29

Great!

Ответить
@Terrados1337
@Terrados1337 - 07.02.2024 14:01

Is JS reeeeally used that much of are people using frameworks of JS cause they dont actually want to use JS but there is no alternative?

Ответить
@anonim1079
@anonim1079 - 07.02.2024 09:51

So, I started my adventure as a programmer with JS and I got used to it.
It has its quirks, but I don't see it as a problem when moving to other languages, most are really similar and don't change much between them.
Although personally JS makes a little more logical sense to me in some cases, it also has many useful mechanics (spread operator) that make working with objects much easier.
I'm not saying that JS is the only right language, everyone likes something different and everyone specializes in something different.
I think it is also worth mentioning the TS which is trying to at least partially correct some errors (while creating millions of others).

Ответить
@maurobraunstein9497
@maurobraunstein9497 - 06.02.2024 06:45

This is a good video for beginner JS-haters to learn the talking points about hating JS without having to actually code in JS, so they can be one of the cool kids at the office lunch table once they find a job in Golang or Rust or whatever is cool these days. I guess not Golang. Fact is, it's entirely disingenuous to call JS a programming language in the first place. You shouldn't expect JS to behave like other programming languages. JS stands for, and I swear this is true, Java*Script*. As in, scripting language. As in bash, PHP, Perl. You know. SCRIPTING. The fact that it was turned into a general-purpose programming language meant that it needed a lot of baggage that it just didn't have by virtue of that kind of thing not being necessary. Hell, you showed an example of classes, and classes are new to JS! When I learned JS 5 ye -- I mean, 10 y -- is it really 2024 already, damn, 12 years then, 12 years ago. When I learned JS 12 years ago, there were no classes; you had to use prototypes. There was no let and const either; it was var this and var that. OK, not var this; this is a reserved keyword. I guess it was var self = this.

Point is, while JS definitely has its... quirks, they generally match its original purpose as a scripting language for web pages, and it's only after people started bringing it to new contexts that it somehow became weird for it to have, for example 5 == "5". Seriously, why should you have to do all these parsing steps to get from the string to the number? It's a website. There's a form on it. You type a 5. That's a string in the HTML text box element. You need it to be a number. So it is a number, end of story, done. No need to worry about converting between the 5 that the user clearly typed into the box and the number 5. That's kind of the point of JS; you don't want to have to worry about types because they just get in the way of making your 1990's-era webpage. And now it's used as an enterprise language so you need all this stuff to be able to use it, including Typescript transpilers to add types to your language with a deliberately minimalist type system. The weird behavior with adding and subtracting strings and whatnot is, really, completely expected if you understand what it's trying to do. It will generally do the thing you want it to do, and if it doesn't, you can easily coerce it with unary + to force a number or adding "" to force a string.

This raises the question: is JS "good enough" to be used as an enterprise language, then? That's kind of a dumb question. Lots of enterprises do use it. I can understand why people who aren't used to it would complain about it, because the features you get by using JS aren't necessarily comparable to the features you lose by not using whatever other language. In my job we use Java, and Java is great for when you don't want your teammates to use your code incorrectly. You can force people to use the right arguments to your method by labeling its types. I want to add an argument to some basic functionality everyone is already using; well, I add the argument and now doing things the old way gives a syntax error. No need to wait for users to email support to find out that it doesn't work! But that doesn't make JS invalid or even bad. Fact is, it requires a different way of thinking. If you're thinking in JS, you can write good JS code, yes, even in an enterprise. Features and tools have been added to the language over time to make this work. But it doesn't make sense to complain that JS doesn't do things like other general-purpose programming languages when it's always been and is meant to be a scripting language for the Web.

Ответить
@2Sor2Fig
@2Sor2Fig - 06.02.2024 01:01

As a person who designs all of their apps and web-servers entirely in Python, JavaScript is one of those things I always dread writing. Only time I've ever thought maybe C would be easier.

Ответить
@claus7992
@claus7992 - 05.02.2024 16:46

I wanna a video about this on js

Ответить
@SilentPrayerCG
@SilentPrayerCG - 05.02.2024 16:27

I think if language allow you subtract and add number with text, it's pretty logical that adding will result string, but subtracting will result number. Never used java, and hear it first time, and don't see where is confusion. Tho it's probably because most of my programming experience based on Visual Basic, which is not very strict about such things too.

Ответить
@Lighter7900music
@Lighter7900music - 05.02.2024 16:11

Still my favourite language tho.

Ответить
@guanciottaman
@guanciottaman - 05.02.2024 15:43

By the way an empty string is always equal to false in Python too. In fact if you want to check if a string is empty, you do if not string, which makes sense

Ответить
@norude
@norude - 04.02.2024 17:43

The production value is good, but please move on to more advanced topics

Ответить
@ReRubis
@ReRubis - 04.02.2024 11:52

Great explanation why it's a bad PL.

Ответить
@felixfourcolor
@felixfourcolor - 04.02.2024 02:12

The Nan thing seems reasonable though? How else would you implement it?

Ответить
@NoName-1337
@NoName-1337 - 03.02.2024 14:16

Yea… js was never intended to be used for enterprise applications.

Ответить
@dabbopabblo
@dabbopabblo - 03.02.2024 02:17

That last class issue can be completely avoided so it prints only the name its instantiated with no matter what its called with by defining the methods in the constructor as properties on the this keyword, but binding them to this: `this.method = function(){}.bind(this)`

Ответить
@lancemarchetti8673
@lancemarchetti8673 - 02.02.2024 17:54

Excellent explaining Thanks

Ответить
@filo8086
@filo8086 - 02.02.2024 14:07

That was an interesting video, i also didnt know the difference between "let" and "var"

Ответить
@Scoopta
@Scoopta - 02.02.2024 09:47

doing 10 + "foo" is just concatenation, java lets you do the same, that's not addition

Ответить
@anasouardini
@anasouardini - 01.02.2024 07:08

You forgot: it can't get you a job as a junior.

Ответить
@ducodarling
@ducodarling - 01.02.2024 03:14

ES 6 was a mistake. Adding in the "class" keyword was a huge mistake. There are no classes in javascript.

Ответить
@CuulX
@CuulX - 31.01.2024 22:37

These "JS is bad, here's why" videos always bring up the same things, and always end up bringing up something about floating point to show how JS "can't even do math" when the behavior is actually correct according to spec and similar non-issues. And all the parts that are brought up are JS v1.0 features which I can agree is bad, but it's not the language I use. I never use "var", how "var" works doesn't matter since the language is great without it. If you learn JS from looking at ancient and bad code then you will of course learn the wrong things. The reason JS is popular is because it's fast, runs everywhere and actually is a great language. Modern JS !== ancient JS. It's not ancient JS that people love and make it popular, so the flaws don't really affect the quality of the language. Would be nice to rename the language and just remove backwards compatibility, but why bother?

I do use == instead of === pretty much always though, and never have bugs because of that. I just don't mix types unless it has some real advantage, and if so I type check first.
And same for arithmetic and values being truthy or falsy, just don't start an concatenation expression with numbers and don't try to do math on strings unless you have checked formatting first and preferably called an explicit number parsing function. A lot of errors can only happen if you just have no clue whatsoever what the variables are for and try stuff randomly.

Ответить
@gerrcassytb
@gerrcassytb - 31.01.2024 22:11

What a funny walkthrough ❤😂

Ответить
@wolverine3694
@wolverine3694 - 31.01.2024 15:55

U call it curses! or flaws. I say they are pretty cool features that no other programming languages can give🔥. Only people that don't understand say those are flaws.

Ответить
@g4fun980
@g4fun980 - 30.01.2024 18:45

poor NaN(ny)...

Ответить
@HumanGamer
@HumanGamer - 30.01.2024 17:23

How do you have all those fancy colors and icons in your terminal? like where it says what app your running and stuff

Ответить
@Nerdimo
@Nerdimo - 30.01.2024 16:20

May I ask what plugin are you using for your status line?

Ответить
@julienbongars4287
@julienbongars4287 - 30.01.2024 15:28

I'm disappointed you didn't talk about the object prototype model in Javascript (everything is an object, every object has an object prototype). You can do some weird things with that...

Ответить
@MIO9_sh
@MIO9_sh - 30.01.2024 11:18

That's what I always like to say, Javascript is a scripting language, it always has been. It's just v8 made it so fast it's feasible to be backend, but it really isn't meant to be used as a anything that couldn't afford downtimes.

Ответить
@realbootybabe
@realbootybabe - 30.01.2024 09:48

I like your videos so much! How Do you create your videos? Is this all done with Linux?

Ответить
@wintersakuraa
@wintersakuraa - 30.01.2024 05:11

Really like your terminal. Can you pls make a video about your setup))

Ответить
@iatheman
@iatheman - 30.01.2024 03:13

Cursed language indeed.

Ответить
@Garfield_Minecraft
@Garfield_Minecraft - 30.01.2024 02:47

it's just a little bit cursed

Ответить
@salemkode
@salemkode - 29.01.2024 20:11

I love video without music

Ответить
@the01revolution
@the01revolution - 29.01.2024 19:42

the way you present the js features after telling how other languages do is very hilarious 😂😂😂

Ответить
@mc4ndr3
@mc4ndr3 - 29.01.2024 19:31

Purists will note the language is named ECMAScript but people who know will call it Java--.

Ответить
@SteinGauslaaStrindhaug
@SteinGauslaaStrindhaug - 29.01.2024 17:50

Since JavaScript was made for being run interpreted in the client, there is no compilation step to barf up warnings to the developer; any errors will appear when it runs in the client. And while you should of course test your code before pushing it; having it fail and write an error that nobody can see in a log on some users computer is not very useful, especially when it's possible to do something useful. Also it might work perfectly and all types are correct in testing but since it runs interpreted in all sorts of weird browser with all sorts of poor internet connectivity; values that always are number in the 5 browsers you test on with a fully functional internet connection; might randomly become string in some other context. So the type coercion makes a lot of sense, if it's at all possible to do so it's in most cases better to do something a bit weird than completely crash for no apparent reason. For instance defaulting to string comparison for sorting is a good default because everything can be meaningfully coerced to a string, and occasionally having a list be sorted "ascii-betical" is way better than having the website crash whenever a table contains a stray value. And for debugging it's much better to have some kind of sorting than no sorting at all. But if you supply your own comparison function you can choose how much error handling you want.

Some of these complaints smells a lot of a backend programmer used to strict strongly and explicitly typed languages complaining about a weakly typed language being weakly typed as if that's a bug when it's actually a feature. I personally hate strongly typed languages that complain about doing arithmetic operations on two types of number; since in 99% of the time of course I wanted the result to be the one type that can contain the result most accurately. I think it probably should be either some compiler option and/or some decoration syntax in the language to indicate if I do want it to complain about such issues and want all type casting to be explicit.

There are of course some genuine unfortunate choices, especially in the 28 year old first specification; but that's why we use linters to avoid these ugly parts that has to be there for backwards compatibility. E.g. overloading + to mean both arithmetic and concatenation was probably mostly a mistake, especially with it's arcane rules for how the operands is coerced; a more sensible default if you wanted to have this overloading would be that if any operand is not a number both sides are treated like strings. But that's why modern lint rules prefer string interpolation over concatenation.

Ответить
@YuriiSahanovskyi
@YuriiSahanovskyi - 29.01.2024 17:06

Omg, I know what it is strange, but never thought how much. Thank you, now I am sure what I don't want to deal with js.

Ответить
@ShadowKestrel
@ShadowKestrel - 29.01.2024 15:48

there is a reason i use js to explain my feelings towards x86

Ответить
@cchutney348
@cchutney348 - 29.01.2024 15:45

What a nice language, we should make the Web run on it.

Ответить
@fagnersales532
@fagnersales532 - 29.01.2024 13:59

Watching this makes me really feel like I should move to Rust or something like that.

Ответить
@thefanboy3285
@thefanboy3285 - 29.01.2024 13:17

YEah. I'd like a whole video about this in JS;
But can someone explain to me why JS couldn't call sayName() when he let sayName = person.sayName ???

Ответить
@HarryBallsOnYa345
@HarryBallsOnYa345 - 29.01.2024 13:11

I always think of Null as "There will never be/was anything here" and Undefined as "There currently isn't anything here, but something could be here eventually."

Ответить