What the... JavaScript?

Поделиться
HTML-код
  • Опубликовано: 11 июл 2024
  • Kyle Simpsons talk for Forward 2 attempts to “pull out the crazy” from JavaScript. He wants to help you produce cleaner, more elegant, more readable code, then inspire people to contribute to the open source community.
    JavaScript Training from NewCircle: crcl.to/72rru
    forwardjs.com/
  • НаукаНаука

Комментарии • 204

  • @groberti
    @groberti 9 лет назад +234

    I'd rather have an error message than a guess by the js intepreter. That is just one reason why it is sometimes hard to work with JS. It won't give you an error message when it clearly should.

    • @rarelyviral5274
      @rarelyviral5274 9 лет назад +21

      This also causes sloppy code, as the compiler does not force the programmer to actually provide an actual value

    • @michaelmarquez7980
      @michaelmarquez7980 7 лет назад +3

      Improper coding style cause lack of error handling. You should never come across an error you cannot understand.

    • @Zaphodox
      @Zaphodox 7 лет назад +1

      You obviously never tried writing in assembler then ;)

    • @toordog1753
      @toordog1753 7 лет назад +1

      Zaphodox still never had an issue. it's all about understanding computers and what you're writing

    • @Zaphodox
      @Zaphodox 7 лет назад +2

      Then you are a far greater programmer than I ^^

  • @anler2b
    @anler2b 8 лет назад +294

    "js tries to do the best possible thing that it can rather than just throwing errors everywhere" - that's a recipe for disaster, imho

    • @hemiacplurge3572
      @hemiacplurge3572 7 лет назад +28

      I'm hip to your mantra. Don't powder my little behind and kiss my forehead when I *(#$& up, TELL ME! I will fix it with the same brain I made the mistake with and thereby improve my brain! Smart brain good!

    • @qvtkc
      @qvtkc 7 лет назад +5

      I disagree. It means that you have to say exactly what you want, otherwise random shit will happen. The only problem is that people start relying on said random shit.

    • @Rauli788
      @Rauli788 6 лет назад +44

      If the language would throw errors instead of returning random shit, people would have to fix their code.

    • @austinsojka7917
      @austinsojka7917 6 лет назад +1

      I agree

    • @xbsidesx
      @xbsidesx 3 года назад

      Not when your intent is to show interfaces to a public that are not programmers, like the web. There was a time when a JavaScript error or just console.log broke your entire code. It's still a script code first.

  • @saeedbaig4249
    @saeedbaig4249 5 лет назад +7

    Just because it's explainable, doesn't mean it's not a WTF. If the language specification says something that is totally counter-intuitive and incoherent to programmers, it's still a WTF.

  • @DrSpooglemon
    @DrSpooglemon Год назад +2

    22:47 - It makes sense that the effect(however bad it may be) of overriding the return of the try block with the return of the finally block doesn't happen if you don't put a return in the finally block - because you didn't put a return in the finally block. The default return of a function does not override the return in the try block, only the return placed inside the finally block does that.

  • @qvtkc
    @qvtkc 9 лет назад +82

    21:15 but... it's not a crazy loop thing. "default" just means "case ", it's a normal case and needs a break if you don't want fall-through.
    Actually I can see how this could be very useful!

    • @Elrinth
      @Elrinth 7 лет назад +1

      yeah I thought the same

    • @bobafullsugar
      @bobafullsugar 7 лет назад +3

      but how would it trigger a case that it doesnt fit in?

    • @baldomo11
      @baldomo11 7 лет назад

      qvtkc you can just copy in the default the code inside one of the cases, tho i can't see why you would do that, the default is code that executes only when the other cases aren't met

    • @qvtkc
      @qvtkc 7 лет назад +3

      Jason it's called fallthrough. The switch statement finds the first matching case and then runs until it finds a break, even if that means passing into another case. And default is just a case that matches everything other cases don't.

    • @qvtkc
      @qvtkc 7 лет назад

      @Baldomo yes, you could do that, but restructuring the switch means that you don't need to write as much.

  • @sindarin1350
    @sindarin1350 8 лет назад +38

    I think it's pretty obvious that the average programmer gets confused by all the coercion even if you can explain how it gets to the seemingly bizarre results. A language should not help programmers make subtle mistakes!

  • @teckyify
    @teckyify 9 лет назад +70

    It's just a plain dangerous approach that's defended here.
    Yes, that stuff is in the spec but it's just not wise or even stupid to use expression which are not obviously clear and correct and have some subtle nuances in special constellations.
    This implicit making the "best" possible thing instead of raising an error is exactly the shitty parts of JavaScript.
    It's not the "best" possible behavior, it's almost the worst behavior, beside giving random results.

  • @coolworx
    @coolworx 8 лет назад +19

    Folks that have been forced into Javascript by way of attrition, have my sympathy.
    Who knew that Eich's 10 day Frankenstein of Lispy, C-syntaxy, Globally fucked by a variable monster would morph and pupate into the dominate runtime that is native to nearly every consumer computational device on the planet?
    But, as Crockford declared, it has its good parts. And I'd say that if the publishers hadn't nixed it, Doug would have called it Damn Good Parts. Stop hating and start learning to love.

    • @deboayangbile1689
      @deboayangbile1689 8 лет назад +1

      +Noah Namey One engineer here. Honestly, i'm already having JS fatigue.

  • @MikeFoss18
    @MikeFoss18 6 лет назад +14

    17:20 Looks like Chrome has fixed this. "new Array(3)" now produces "[empty x 3]".

  • @stevik999
    @stevik999 8 лет назад +30

    the second warmup does makes sense:
    3 > 2 > 1 means it compares 3 > 2 which is "true" and since true = 1 it cannot be greater than 1

    • @mattarriola277
      @mattarriola277 8 лет назад +7

      yeah he threw in a few of those. whatever you think of switch statements with fallthrough, i think the default case falling through the 10 and into the 20 made perfect sense

    • @thpion
      @thpion 8 лет назад

      I totally agree. Also most of the finally examples seemd very reasonable to me (not all, though).

    • @kynikersolon3882
      @kynikersolon3882 7 лет назад +7

      I think it is bad. Just taking a boolean and use it as number looks like a very badly designed type system to me.

    • @thpion
      @thpion 7 лет назад +5

      Kyniker Solon
      well yeah...but that's the whole premise of JS

    • @kynikersolon3882
      @kynikersolon3882 7 лет назад +4

      Do you think this availability of quick hacks is worth sacrificing a decent type checker at compiletime?
      I'm genuinly curious I have not much experience with JavaScript.

  • @core36
    @core36 7 лет назад +5

    my biggest wtf moment with javascript was the fact that in javascript, in the date object, i.e. month nr 8 is not august. in php 1 is jan and 12 is dec, but in javascript jan is 0 and dec is 11. i made a calendar and had to post a selected date to php, when suddenly my month only had 30 days when i expected it to be 31 days, because i expected javascript to be at the right month.

  • @martijnvankekem3286
    @martijnvankekem3286 4 года назад +5

    Some of these things aren't really the downside of JavaScript. This, for example, IS a weird flaw:
    null > 0 returns false.
    null == 0 returns false.
    null >= 0 returns true.
    Huh?

  • @fwyae
    @fwyae 8 лет назад +14

    i learned more about javascript in this then any tutorial in years :)

  • @henke37
    @henke37 7 лет назад +6

    36:00 Thinking that stealing class functions is sane is the real WTF. The possibility of that is the real WTF.

  • @SvitlanaShepitsenaTemplates
    @SvitlanaShepitsenaTemplates 8 лет назад +5

    Well, this guy is AWESOME. His way of teaching JS and the original view on JS is the best I watched. Now when Mr Crockford sounds a bit weird (if not crazy) - Kyle is the only one to watch.

  • @Nike-iv2ni
    @Nike-iv2ni Год назад +1

    I think he wants us to read his book. And I also think that he may have a whole series but I am not quite sure. Maybe he hasn't mentioned it often enough yet.

  • @fakkmorradi
    @fakkmorradi 8 лет назад +2

    15:19 line 4, I think String([undefined]); is treated as an undefined array entry, so stringifying it would assume that the array entry would be returned. And it would not print whats undefined in the array when printing the entry or entries. Am I way off??? Or even making sense

  • @paokalexthes
    @paokalexthes Год назад

    watching this in 2022 and I got to say,
    The part at 31:05 with object destructuring alias:value which is reversed when destructuring has been bugging me forever.
    I legit never remember what's the correct order and just do it randomly and I then go to see if I get an error to see if I chose the wrong order.

  • @tonybrown7847
    @tonybrown7847 9 лет назад +10

    Kyle knows his JS, I like most of what I've learned from his "You Don't know JS" books

  • @gillianbc
    @gillianbc 5 лет назад +1

    Great books and Kyle's a great speaker too. Absolute legend.

  • @bernardleech5007
    @bernardleech5007 7 лет назад +3

    27:03 I just tested this in the console in Chrome v56 and the behavior is different from what Kyle shows here. For me, it.next(25) resumes the generator and logs out "c:25", then returns {value: 7, done: true}. So is falling out of the finally clause 'fixed' now? Or is this ES7 behavior or something else? wtf js?

  • @jamdonut
    @jamdonut 9 лет назад +2

    *sees language* *does everything to break it* *writes a book*

  • @DarkSwordsman
    @DarkSwordsman 7 лет назад +1

    14:00
    Wouldn't null mean empty, in other words, "0" when compared to an empty string?
    Then undefined means that there is absolutely nothing, which is why it would be NaN?
    would 14:41 have anything to do with 9:30 ?

  • @tzetzo_tzetzov
    @tzetzo_tzetzov 7 лет назад +6

    Just found out that:
    Number([]);
    -> 0
    Number([,]);
    -> 0
    Number([,,]);
    -> NaN

  • @KirbyLWallace
    @KirbyLWallace 8 лет назад +5

    If the spec is that Number.MIN_VALUE is the smallest positive number possible, then there is nothing WTF about "Number.MIN_VALUE < 0 //false". Or am I missing his point? This is not limited to JavaScript. Java, and other languages do the same thing with these expressions. C# will throw an exception given such a statement.

    • @saeedbaig4249
      @saeedbaig4249 5 лет назад

      I think what he was getting at was that a lot of newbies (who aren't familiar with JavaScript and haven't necessarily read the spec) would be surprised that Number.MIN_VALUE isn't actually negative. I know it surprised me when I first learnt about it!

  • @Artecolote1
    @Artecolote1 8 лет назад +6

    a lot of these actually make sense.
    ei
    in String([null]), you are defining an Array with a value of null which = to []. therefore String([null]) == String([]) which == to ""

  • @1DJLNR
    @1DJLNR 8 лет назад

    hey kyle wheres your other vids?

  • @QwertyNPC
    @QwertyNPC 9 лет назад +4

    About the coersion of undefined and null - according to the dictionary right here: dictionary.reference.com/browse/null there are many reasons to coerce null to 0. Also it makes sense to separate undefined and null like that, because there is nothing in undefined that would suggest a relation to 0.

    • @Artecolote1
      @Artecolote1 8 лет назад

      +MrLewhoo yes, as i understood it, undefined means that it doesn't exist at all. while null does exist but it has no value which makes sense to be 0.
      var i
      i = undefined
      var i = null
      i = nothing

    • @niklastreboun8561
      @niklastreboun8561 7 лет назад

      null should be numerical void, not 0

  • @AmxCsifier
    @AmxCsifier 8 лет назад +1

    Guys, plz recommend a programming talk, something you had fun watching, thank you

  • @gosnooky
    @gosnooky 6 лет назад +3

    13:50, the undefined and null issue makes perfect sense if you understand how C deals with nulls. The null value is 0x00 in ASCII and is used to terminate strings among other things, so with an ascii value of 0, it makes sense that JS would equate it to 0. Undefined is just that, no way to coerce a number from something that is not defined on the stack or heap.

    • @henriquebecker2713
      @henriquebecker2713 2 года назад +1

      No, you are confusing 'nul' (the character, with just one 'l') with NULL (the C constant, used for null pointers).

  • @martinalcala4823
    @martinalcala4823 3 года назад

    17:28 ........ What about Array.from({ length : 3 }); ?

  • @dmitriyobidin6049
    @dmitriyobidin6049 8 лет назад +11

    About => : wtf are you talking about? What about lexical this?

    • @asdqwe4427
      @asdqwe4427 8 лет назад +2

      +Wilkong Lexical scoping is the only good thing that we got from it

    • @user-sw1wq8lh2w
      @user-sw1wq8lh2w 8 лет назад +2

      +asd qwe and implicit returns

  • @teunissenstefan
    @teunissenstefan 5 лет назад +1

    Imo the switch behaviour is exactly what you would expect since you didn't put a break; there.

  • @boriseng
    @boriseng 7 лет назад +1

    What's actually wrong at 23:24? Seems to make sense.

  • @caparcher2074
    @caparcher2074 7 лет назад +9

    Alot of the things you are suggesting would break javascript even more

  • @justchaz
    @justchaz 7 лет назад +2

    I really do like the flexibility that the JS provides. Just need to know the what's happening behind the code

  • @supernewuser
    @supernewuser 9 лет назад +4

    Good well informed talk. Only downside was trying to get a WTF chant going whenever a slide came up.

  • @evald80
    @evald80 6 лет назад +2

    The behaviour with the "finally" keyword is really a wtf and very dangerous one!

  • @darioc23c
    @darioc23c 6 лет назад +6

    Too many rules which I think could be avoided at the beginning (now it's too late), one of them is == vs ===

  • @kitsunde
    @kitsunde 9 лет назад +4

    I struggle to think of a way finally would work that would be more reasonable than the current behavior, it was completely obvious to me what would happen in each case and seems expected. Finally interrupts all flow control by design. If it was the case that you would want to keep the return from inside of the try{} block around somewhere that would seem to be an extension onto how finally works in any language I'm aware of. If you were meant to receive that value it should share the same syntax as catch (or possibly have a second parameter for the return value) i.e. try{ return 5; }finally(returnValue){ console.log(returnValue)}. Returning to limbo without any supporting method of recovering the value seems like the only valid choice.

  • @DrunkenUFOPilot
    @DrunkenUFOPilot 7 лет назад +2

    Isn't MIN_VALUE the same thing called 'epsilon' in other languages? The smallest value you can add to 1.0 to get something different. So why doesn't JS call it EPSILON?

    • @xynyde0
      @xynyde0 2 года назад

      what language calls min_value epsilon lol

    • @rastaarmando7058
      @rastaarmando7058 2 года назад

      @@xynyde0 C, C++ and C# do, I think.

  • @PaterEcstaticus888
    @PaterEcstaticus888 5 лет назад +3

    I'm so tired of the JavaScript fans, who try so hard to persuade everyone (themselves included) that JavaScript isn't a language for amateurs. Here's what its creator Brendan Eich had to say about JS back in 1998: "There were people who argued strongly that Java's fine for programmers who build components, but there's a much larger audience of people who write scripts or maybe copy a script from somebody else and tweak it. These people are less specialized and may be paid to do something other than programming, like administer a network, and they write scripts part-time or on the side. If they're writing small pieces of code, they just want to get their code done with the minimal amount of fuss... We agreed that this new language should look like Java, but be a scripting language." web.archive.org/web/20060507162841/cgi.netscape.com/columns/techvision/innovators_be.html

  • @zackiles
    @zackiles 8 лет назад +6

    Funny guy, interesting presentation, but what's even funnier is I haven't encountered most of what he talked about. Really never found man spots where I'm doing heavy operand stuff like this tbh,

  • @georginikoloff9280
    @georginikoloff9280 7 лет назад +1

    Great video by Kyle, everything he produces is of an amazing value

  • @ryanfleming2448
    @ryanfleming2448 3 года назад

    Cool talk, coming from a c/++ developer. I don't quite agree with the switch-case statement though. Traditionally in c/++ we always place a break with the default case for consistency, its also just gets optimized out once compiled. Just like other case statements, if a break is not used this can be very advantageous for doing multiple case statements, for example:
    switch (t) {
    case 1:
    cout

  • @xybersurfer
    @xybersurfer 5 лет назад +17

    it looks like this guy has been corrupted by JavaScript and he doesn't even realize it

  • @planktonfun1
    @planktonfun1 8 лет назад +2

    ECMAScript syntax is relaxed to enable it to serve as an easy-to-use scripting language. I. E.
    a variable is not required to have its type declared nor are types associated with properties, and defined functions are not required to have their declarations appear textually before calls to them.
    That's why we have this wtf error, the script assumes the declared value as something else, you can fix this by specifying the type you intended to use

    • @planktonfun1
      @planktonfun1 8 лет назад

      +Paulo Castro This is what javascript differs from C, it has its tradeoffs

    • @horridohobbies
      @horridohobbies 8 лет назад +2

      +Paulo Castro
      Python is a great, easy-to-use scripting language, but it doesn't have any of this WTF nonsense.

    • @planktonfun1
      @planktonfun1 8 лет назад +1

      +Richard Eng yup, phython's typing discipline is strong, less guessing, less errors.

    • @nacs
      @nacs 8 лет назад +1

      +Richard Eng Oh come on, python has it's own set of WTF nonsense like all the significant white-space, forced indentation and other python-isms. Both languages have their pros/cons but let's not pretend python is perfect.

    • @horridohobbies
      @horridohobbies 8 лет назад +3

      +nacs
      You're right, ALL programming languages have their warts. But JS has far more warts than any other language in wide use. Just look at the many lists of WTFs available; I've shown some of them here: medium.com/javascript-non-grata/javascript-is-a-dysfunctional-programming-language-a1f4866e186f. Let's not pretend that JS is in any sense normal.

  • @theaninova
    @theaninova 5 лет назад

    Cool, a switch loop!

  • @hamzahajji5814
    @hamzahajji5814 7 лет назад +1

    35:34 why is there a "function" instead of class and a semicolon after a class declaration. I thought extends is used with classes not functions!! wtf?

    • @gabrielbuonomano
      @gabrielbuonomano 5 лет назад +1

      In JS, there are no classes. The class syntax is just function syntax underneath.

  • @greenarrow6996
    @greenarrow6996 6 лет назад +5

    Good video, but I have to make this comment...
    Kyle Simpson says that most WTFs arise from lack of understanding of the language spec, of how things should work, of the reasoning behind the spec. There is probably some method to the madness but he says he can’t see it. And, still, he encourages people to use JavaScript.
    WTF?!! Excuse me, but why should I want to use a language whose spec is so obtuse that I can't easily understand the reasoning behind it, or how things are supposed to work? What kind of language requires so much special scrutiny, so much extra effort to understand?
    He says JavaScript has greatness to it. I'm not so sure about that, but even if I accept it, there are other languages that can do what JavaScript does without all the ugly baggage. The ONLY reason to use JavaScript is because, for programming the web browser, you have no choice. You must use JavaScript, or at least a language that transpiles to JavaScript.
    Removing choice is hardly a ringing endorsement for the JavaScript language.

    • @CheefCoach
      @CheefCoach 4 года назад +1

      That is the proper question, why somebody who doesn't want to spend the time to learn JavaScript is using JavaScript? Those are the people who are calling js a bad language, even tho most of the problems come out of their own lack of knowledge of the language.
      It is not a baggage, but a lack of it. js don't force you to spend your time on defining the variables like some other programs do. Or force you to write a class to create an object.
      Maybe it should exist a version of js that is doing that for long and complex websites, but there are a lot of websites that require small codes for working. I believe that js is designed to program small codes quickly.

  • @poamrongrith1563
    @poamrongrith1563 5 лет назад +1

    Ooh great. Even in '18

  • @cyberparadise4365
    @cyberparadise4365 8 лет назад +1

    19:30 LOL IM DYING.

  • @jennifer7chan
    @jennifer7chan 7 лет назад +1

    Wow you really know JS

  •  5 лет назад

    The default/break is not a WTF at all. This is how switches work. This is how they work as well in languages like C or Java.

  • @vapeurdepisse
    @vapeurdepisse 2 года назад

    I remember in the 90s when we used JavaScript to animate a "cool" drop-down navigation menu. It should have not gone any further. Wasm for the win.

  • @jondbarrow
    @jondbarrow 5 лет назад +2

    23:07 I don't see how that's a "wtf". What did you expect, that not defining a return in 'finally' would return undefined? How would that make sense? If that's how it functioned, then any function that used 'finally' would return undefined unless given the return in the 'finally'. But then that prevents the ability to run code after the function returns, which is something you mention as being useful just seconds before.

  • @ahm951
    @ahm951 9 лет назад +11

    if your code doesn't make sense then don't expect answer that make sense

    • @thewildmangotrader4943
      @thewildmangotrader4943 5 лет назад

      @Evil Eric Wrong, if you know your data and the expectations, why would you rely on the interpreter to give you an error, means you do not know what you are doing. If the code does not make sense to you, then, WTF are you doing programming? Do you expect the compiler/interpreter to slap your face? Tell me one reason why you would write a piece of code that does not make sense to you in the first place and then "have every expectation the interpreter wont understand it either"?, Really!!

    • @xybersurfer
      @xybersurfer 5 лет назад

      @@thewildmangotrader4943 it's normal for humans to make mistakes while writing code. you can't convince me that you don't make mistakes. the problem is exactly that the bad language spec "thinks" too often that it does understand these mistakes

    • @chrisnewey
      @chrisnewey 5 лет назад

      @@thewildmangotrader4943 The problem is when the code DOES make sense to you but is incorrect. Or have you never written code at 3 AM?

  • @jaschardomann5407
    @jaschardomann5407 5 лет назад +3

    Two options:
    1. Fix that horrible language.
    2. Replace it with a clean designed language.

    • @ChumX100
      @ChumX100 4 года назад +1

      Well yeah, they tried. Except that
      1) Many performance-critical applications depend on the horrible properties of the language.
      2) By design, there is no alternative for the web (wasm is going places though).
      Also, there is this weird phenomenon with software tools: Once a certain level of popularity is reached, it will NEVER die, no matter how lacking they are (think PHP for example).

  • @smintgames3973
    @smintgames3973 9 лет назад +1

    i have a weird javascript sending me random shit messages like: 1 more thing if you are wathing a vid say "you video sucks". reminder. When i see this i am scared

  • @knife_wizard
    @knife_wizard 7 лет назад +3

    I'm hearing a lot of rationalization here...
    9:21 "You're taking it from a truthy value to false" IMMEDIATELY raises nonsense flags in my head. What the hell does any of that mean? The line states that you are comparing an empty array to whatever the 'not' of an empty array is. He justifies this by stating that, 'in the spec' things get converted to a number before they're compared. Any good reason for that? I would argue that they should NEVER be converted to numbers in the first place. What the hell is the reasoning for that? I keep hearing how the book explains it in a way that's rational, but the rationalizations done by a book are fucking meaningless to me. Javascript consistently misuses mathematical notation to fit it's own conception of reality, which would almost me amenable, if it had anything even approaching a feasible type system. I'm also super drunk, and these issues are STILL blindingly obvious. All I'm seeing is rationalization for bad behavior that does not deserve or warrant any defense.
    EDIT: Also hadn't seen beyond the gross rationalization segment when I wrote this comment. The rationalization is STILL gross and unacceptable, but, he does eventually leverage some criticisms against the language.

  • @AyhanSipahi
    @AyhanSipahi 9 лет назад +2

    link to slide: speakerdeck.com/getify/what-the-javascript
    Download: speakerd.s3.amazonaws.com/presentations/a7e67313cb884cfe83951d2096015f4a/wtjs.pdf

  • @jakechan5796
    @jakechan5796 9 лет назад +5

    wow those books are free online... cool

  • @BLOOMS
    @BLOOMS 9 лет назад +27

    "I don't like classes."

    • @CzipperzIncorporated
      @CzipperzIncorporated 9 лет назад +2

      BLOOMS oop

    • @coolworx
      @coolworx 8 лет назад +11

      +BLOOM JS is more OOP than Java. Actually it''s the OOP, nothing but the OOP - no classes needed.
      I create one object, then BAM I extend it with another - no intermediary needed. No Platonic boilerplate class needed.
      I create something useful from the getgo, and extend and learn from there, instead of creating a mass of theoretical taxonomy (which is doomed to be an ill fit when all is hashed about) before practically wading into the problem.

  • @uthoshantm
    @uthoshantm 6 лет назад

    Any system or machinery intended to be used by a human being should be intuitive and logically consistent. That is not the case for JS. How many books should be read to learn all the quirks of a single programming language? Three? Is this an efficient use of scarce resources?

  • @LennoardRai
    @LennoardRai 5 лет назад +1

    typeof NaN = "number"

  • @dalewyngaard
    @dalewyngaard 8 лет назад

    where's a good place to start if I would like to create a Javascript App?

  • @armanb9778
    @armanb9778 7 лет назад

    Kyle Simpson rocks.

  • @joonhasebring
    @joonhasebring 9 лет назад +15

    I'm seeing a lot of confusing code scenarios that look like someone is trying to be esoteric for the sake of entertainment rather than providing value for the programmer. I would just lint this shit and be done with it.

    • @DrunkenUFOPilot
      @DrunkenUFOPilot 7 лет назад +3

      None of those examples look like anything working programmers in the real world would ever write, except beginners and show-off smartasses.

    • @niklastreboun8561
      @niklastreboun8561 7 лет назад +2

      all those examples are snapped from popular libraries. The problem is that there isn't any syntax checking, so when somebody writes something and it accidentally work, they think it works, so it must be true.

    • @thewildmangotrader4943
      @thewildmangotrader4943 5 лет назад

      @@user-if1de8pt2j I agree with you, he is actually looking for very stupid and specific conditions that you can easily avoid.

  • @youtubeforcinghandlessucks
    @youtubeforcinghandlessucks 7 лет назад +3

    I am disappointed, most of the WTFs that seem to tick him off are not WTFs at all, especially after the middle of the video where it was supposed to actually get "crazy". Destructuring order of names is key:alias and makes total sense, especially when you apply it to deeper structures - the json syntax stays on the right side. Temporal dead zone is a WTF name but it is completely logical. Yes it is inconsistent with the old approach, but that is on purpose. Why would we even want a new way of declaring variables if it worked just like the old way? The goal is to phase out var and only have let in the future, and the transition period can seem like a WTF but it is needed.
    The "default" case falling through is completely natural and consistent. Missing "return" in a finally not meaning "return undefined" - completely natural. Breaking out of a "finally" block - yeah it's odd and can get messy, perhaps it is a WTF that it is allowed. But once you accept it is allowed at all, the way it works is completely natural and consistent, even in generators.
    Speaking of generators, in older versions of the spec you had to catch an exception to know when the generator was over, which was a huge WTF. But now there are some other WTFs left, like the redundant star syntax in declaring them - presence of yield is a sufficient indicator; or the fact that they start in a paused state, which is completely pointless, and makes the parameter of the first resume call meaningless; or the fact that they went with the half-hearted single-stack-level generators which greatly hampers their use in lambas in forEach or map and such, when they could have gone the full monty with lua-like coroutines able to yield across multiple stack levels.
    There are even bigger WTFs in JS that I expected to be mentioned: the still half-assed attempt at meta-programming, i.e. Proxy class or prototype chain mutation as specific examples, but more generally just being constantly countered by other language developments like pointless access control on properties, static analysis and performance optimization in engines, etc; the ability to override String and Number coercion but not Boolean coercion, leading to impossibility of falsey objects; the inability to make a function-like callable object (except with the mentioned lame Proxy class); native Promise performance; the async/await syntactic sugar they plan in the next version (which sucks because it's based on generators with single-stack-level limitation);

    • @youtubeforcinghandlessucks
      @youtubeforcinghandlessucks 7 лет назад +4

      Oh how could I forget 3 > 2 > 1... The mere idea that this can or should be fixed to "work" is a WTF.

    • @Adiounys
      @Adiounys 7 лет назад +1

      I don't think you get the idea of WTFs. Just because you understand why something happens that doesn't mean it's "completely natural and consistent" it may be convinient for language implementation or justified by preformance reasons but this doesn't mean it's natural and consistent.
      On the other hand your proposals of WTFs should be better call
      wishful thinkings...
      But one thing I must agree is your last comment - yeah, let's reverse order of > operations and break the web! :D

    • @youtubeforcinghandlessucks
      @youtubeforcinghandlessucks 7 лет назад +2

      Yes I think people should engage brain and apply logic before declaring something a WTF, why is that so odd? In none of the cases that I argued is the supposed WTF justified just by implementation convenience or performance reasons, but by logic.

    • @Adiounys
      @Adiounys 7 лет назад

      Ok, so for example, what logic should lead me expect that after "default" every line below will be executed until "break"?

    • @youtubeforcinghandlessucks
      @youtubeforcinghandlessucks 7 лет назад +2

      It works that way for all other case labels, why should default be different?
      Furthermore, that exact functionality is the only possible reason to want to put the default case not as a last case.

  • @NastySasquatch
    @NastySasquatch 5 лет назад +5

    Damn I haven't written any books and I can explain most of the ones he can't....

  • @kicknotes
    @kicknotes 6 лет назад +1

    I fail to understand why some people can't simply take these talks at face value versus turning them into flame wars. Whether you agree or disagree is beside the point. Did you learn anything? I think there are always useful bits to glean from every talk/book/etc., and instead of bashing the guy or the talk, just take the bits you found useful and let them serve to improve your development.
    The majority of those folks who respond with "this guy sucks!" or whatnot have contributed nothing positive of their own to the dev. community and likely never will.

    • @radadadadee
      @radadadadee 4 года назад

      I learned that JS is shit

  • @NobleNobbler
    @NobleNobbler 3 года назад

    Also, his not wtf's are all wtfs, with the exception of being wtfs he understands and likes

  • @brianbutton6346
    @brianbutton6346 2 года назад

    Content starts at 6:00

  • @elvinasss2767
    @elvinasss2767 3 года назад

    it's absurd that a lot of people because of that say JavaScript is easier to learn that way and because of such things have lower entry level, I think this is wrong, we don't need incompetent programmers, it's like making a hell for decent programmers who have to fix or read others code that use these assumptions and have a lot of edge cases that could happen because no beginner will know what the outcome will be when using different types, of course there are some parts and assumptions that JavaScript did right but most confusion still remains it tricks even advanced programmers, that's why bigger projects are written on TypeScript or similar dialects just to have that extra bit of security, but cmon people are able to build rockets so I'm sure we can find a way to be comfortable working with strict types and forget all the intricacies of that nonsense. For example PHP and JavaScript is moving closer to looking like strictly typed language, but it will take a long time since we can't delete the history and undo what has been done and backwards compatibility support will be an issue for a long time.

  • @igronus
    @igronus 4 года назад

    I think most of the examples is not from of actual projects' code but about of monkeys copypastes which probably should be denied on linter's level.

  • @sbacon92
    @sbacon92 5 лет назад +1

    @10:00
    No.

  • @rndszrvaltas
    @rndszrvaltas 6 лет назад +1

    Object destructuring is not a wtf at all, what's more, this is the consistent way to do it. For the sake of == being commutative, after the assignment, foo() == {x:BAM, y:BAZ} and {x:BAM, y:BAZ} == foo(). Moreover, if two objects are equal, we assume that they have the same values on the same properties. {x:BAM, y:BAZ}.x == foo().x, which is right, BAM == XX.

  • @Ganesh-ph4gm
    @Ganesh-ph4gm 7 лет назад

    Websites are built on JS. No surprise websites act as weird as JS.

  • @HoD999x
    @HoD999x 5 лет назад +1

    "read the spec"
    problem: it's 850 pages or so. compare that to simple and yet very powerful languages (clojure) and you see why javascript is hard to work with.

  • @AdroSlice
    @AdroSlice 5 лет назад +7

    "The spec sais so." Well the spec is arbitrary asf. I want to be able to learn a programming language, not the spec for that language. Things should make sense, and if you write something that wouldnt make sense, don't twist it into something that "According to the spec" does.

  • @DmitryFomin
    @DmitryFomin 6 лет назад

    well, with ClojureScript you will never have such problems with code readability :)))

  • @codi0dio
    @codi0dio 9 лет назад +1

    At first, I disagreed with you. But after listening, I realize that you are asking yourself "how should things be?" instead of "How can I fix this?" This is what Steve Jobs did, I respect you.

  • @mironmajkes3965
    @mironmajkes3965 5 лет назад

    number.MIN_VALUE < 0 false - is ok. 0 is the minest value :) But -number should be true here. '42 .toFixed(2);' is cause JS engine works it immediately conwert number to string - it just do that.

  • @BehruzbekOtayev
    @BehruzbekOtayev 2 года назад

    Js came a long way....

  • @macheads202
    @macheads202 9 лет назад +2

    What the fuck!

  • @Poneglyph
    @Poneglyph 4 года назад

    Coercing empty string and whitespace to 0 isn't unreasonable? Yes it is! It's absolute travesty!

  • @ube-23s
    @ube-23s 7 лет назад +2

    I thought this is about "what is JavaScript " When I saw and heard him for 10 seconds I knew he was one of those. Too advanced for me. He didn't even start by explaining what JavaScript is? All I see is, WTF, WTF, WTF, etc.

  • @NamanGoel34
    @NamanGoel34 9 лет назад +32

    That talk was terrible. Full of expected behaviour being called WTF, and unexpected behaviour being given a pass.

    • @LGtheCat
      @LGtheCat 5 лет назад +1

      Haha actually I got one of these not long ago and can relate to a huge headache it gave me

  • @StaviKay
    @StaviKay 7 лет назад +1

    i find most of the wtf's actually not a wtf at all. im 4 years experienced in actrionscript3.0 and by looking at these... they appear totally normal and reasonable.

    • @StaviKay
      @StaviKay 7 лет назад +1

      as for the whole "best guess" thing... um, err.. ERR. ERROR!

  • @UltimatePerfection
    @UltimatePerfection 6 лет назад +1

    There are only two type of code. Code you understand that you understand and code written by someone else.

  • @irfanbaig1888
    @irfanbaig1888 8 лет назад

    It's a funny video.

  • @a8lg6p
    @a8lg6p 3 года назад

    ...return { x: XX, y: YY}
    const { x: BAM, y: BAZ} = ...
    "Alias value, alias value..." Maybe I've been doing too much ES6, but this doesn't seem weird to me. I can see how it could be confusing, because they can look identical, but in my brain, object literals and object destructuring are just completely different things. In the first case, there are no "aliases" involved...it's KEY and value pairs. If the key is the same as the variable you're assigning it to, collapsing both sides of the : into one thing is a nice, pretty, convenient syntax sugar. In destructuring, it's like you're extracting the keys, and optionally renaming them, so...while maybe reversing it would be just as well and maybe more consistent...the way it is seems to make sense in a way. Maybe it's because they're on opposite sides of the equal sign, so it seems logical it would be a mirror image.

  • @jsonkody
    @jsonkody 5 лет назад

    Everything in JS makes perfect sense .. I can see no WFTs whatsoever :)

  • @dasten123
    @dasten123 8 лет назад +1

    wtf

  • @simonpeggboard4004
    @simonpeggboard4004 Год назад

    Javascript needs a rewrite .

  • @szeredaiakos
    @szeredaiakos 5 лет назад

    3x levels of inheritance ... WTF is wrong with people?

  • @Viral757_
    @Viral757_ 3 года назад +1

    omg.. this is horrible. i'm glad i never left the love bubble of C++.

  • @alex_on_the_web
    @alex_on_the_web 9 лет назад +6

    wow, a new video ripping on javascript's weird behavior. Surprised. How about people started to make videos about how you can make use of javascript instead of ripping on parts you wouldn't even use ever (except for my industrial size coercer software...)

  • @edgeeffect
    @edgeeffect Год назад

    I don't get how you can just brush over "fewer characters = more readable" .... This is the "most wrong" thing I've heard for at least a couple-a days... If your colleagues are espousing this idea to you, you owe it to humanity to humiliate them publicly!!
    On the subject to improvements to society... encouraging the audience to curse loudly and publicly is brilliant! "'dear god, give us often such rascals' - Voltaire" - Paul Morley.

  • @Ravend6
    @Ravend6 9 лет назад

    wtf???