11 ms·
Wat [video] (2012)
- Lev1a 4y agoA true classic.
- TigeriusKirk 4y agoMasterful comic timing and repetition.
- ElCapitanMarkla 4y agoI love that guys laugh near the end, it's like John Belushi was in the audience
- jMyles 4y agoMy goodness; I haven't watched it in a couple years, and I have to say, I still literally laugh out loud. The timing is just so solid. I also want to say on a personal level that I really like Gary; he has been so friendly to me every time we've met.
- sublinear 4y agoI'm not defending javascript, but I just want to answer the "wat" by saying these are all just jabs at its type coercion rules, the fact that an array is an object, and that the toString method for each type usually isn't that helpful by default. None of this matters most of the time, but yeah it's still funny. In case you want to laugh harder: https://getify.github.io/coercions-grid/ https://getify.github.io/coercions-grid/
- eyelidlessness 4y agoWhen I first saw this video, besides laughing constantly I also generally anticipated what was coming next because I was intimately familiar with JS type coercion esoteria. A decade later with a near decade long strict personal rule to never rely on implicit type coercion (with one exception, undefined/null, because it’s almost always what you’d want/intend), quite a lot of that memorization has fallen out of my head, and I’m prepared to let it stay that way. Because yep, it pretty much reduces to the category Type Coercion Rules. But that category in JS is so absurd that normal absurdities feel like minor tomfoolery. (And lest I paint myself as the typical HN anti-JS crusader, I do almost all of my work and personal dev in JS/TS, mostly without complaint.)
- TheRealPomax 4y agoAnd even that last one you can now finally explicitly account for with the incredibly unfortunately syntaxed, but critically useful, double question mark.
- eyelidlessness 4y agoYeah, and I also make exceptions for == null and != null where it aids readability of the code. Linter blocks any other type coercive comparison, but allows that one (and honestly I think it should be mandated, but I haven’t had a need to push that lever for a long time either).
- illiarian 4y agoI once read the spec to see why the hell type coercion was the way it was... And it kinda made sense? But this was 5-6 years ago and I forgot all the details. Because without going into deep dark corners of the spec it doesn't really make sense. At all :)
- rektide 4y agoBrowbeating JS with this derision has/had become almost an article of faith amongst online circles. It's clearly not great behavior but generally it doesnt really have much impact on day to day. Yet people love making themselves feel better by latching on to criticism. Signaling your greatness & expertness by beating up on others.
- ParetoOptimal 4y agoWhat if it's not beating up on others, but being very critical of languages because you believe language choice actually does matter?
- xdennis 4y agoThat's completely fair, but I FEEL (don't know for sure) that many people who criticize JavaScript don't know it very well and don't pick meaningful things to criticize, but things like its rubbish type coercions (which doesn't have a big impact in real life).
- rektide 4y agoYou should a) pick big impact items to argue your case b) still acknowledge strengths & successes amid your critique. Also if you are facing the world's most popular language & a very successful one people build all sorts of stuff with without complaint, it's a big barrier. I think most language bigots lack a good narrative. They have a language they love, or a language they hate, but they harp upon specific issues. But to I think most coders, choice of language is actually pretty far down the list, especially if you ask them to ignore the ecosystem of packages/tooling & focus on the language itself. Trying to go beyond scoring points & telling a story about life being actually authentically really different on one path or another keeps being harder and harder to se, as we keep marching through the decades & seeing few really really strong distinct clear advantages anywhere, no one really excelling at their claimed bag, in an unreplicateable way that shows it really is the language, not just ecosystem. (rust being one genuine exception)
- goto11 4y agoIf you use JavaScript you need to be aware of these pitfalls, otherwise it will bite you. The video just does it in an entertaining way.
- titzer 4y agoImplicit conversions are very pernicious. In Virgil, the only implicit conversions that happen are promotions, i.e. representation changes that don't change values, like float -> double, int -> larger int, int -> double (where no rounding occurs), etc. AFAICT this is a pretty sane model.
- ParetoOptimal 4y ago> None of this matters most of the time, but yeah it's still funny. Implicit type coercion doesn't matter most of the time? You don't often have bugs because of it?
- sublinear 4y agoIn the browser all user input, API responses, and application state is validated and sanitized before it ever gets to the application logic. On the backend all requests and database values are similarly validated and sanitized before any logic occurs. Anything less is bad code regardless of what languages are used.
- kerkeslager 4y ago> In the browser all user input, API responses, and application state is validated and sanitized before it ever gets to the application logic. Good thing there are never any bugs in validation and sanitization code!
- sublinear 4y agoYou shouldn't roll your own for this. From what I've had to do web-wise, here's a few tools. First, for the APIs, you need documentation: https://swagger.io/ https://swagger.io/ From which you can generate JSON schemas and use those to validate in the browser and on the backend. https://www.npmjs.com/package/jsonschema https://www.npmjs.com/package/jsonschema As well you should be writing a few more schemas for your application state and leverage the regex validation of your input components... Speaking of which, you also need to sanitize out some potentially nasty input. https://www.npmjs.com/package/dompurify https://www.npmjs.com/package/dompurify Obviously this isn't everything and not perfect, but a lot of this tedium can be automated away if you have a few good examples of the happy path and some basic tests in place to prevent quick and dirty changes from poking holes in these layers.
- jeffhuys 4y agoSigh. I hate this type of "conversation". Go back to reddit.
- cmrdporcupine 4y agoIt's not just implicit conversions. It's misuse of operators, too. Using the '+' operator string append is the kind of thing that language designers get initially seduced by ("it just makes sense" "so convenient" "neat") but the reality is that combined with implicit type coercions it's just a recipe for exotic and unexpected behaviours. Precedence rules and expectations for 'string append' vs 'add numbers' is different. And then if you through in 'multiplication = repeat.' It's ... now you have this Wat-talk video (which is a classic which I always share with people when the topic of this comes up.) Maybe I'm just getting stuffy as I get old, but the older I get the more .. explicit.. I want my PL semantics to be.
- dang 4y agoHere are some of the related old threads. I was surprised that there was only one sizeable one about the video (3515845). Others? Wat (2012) [video] - https://news.ycombinator.com/item?id=26850630 https://news.ycombinator.com/item?id=26850630 - April 2021 (28 comments) WAT – A lightning talk by Gary Bernhardt from CodeMash (2012) - https://news.ycombinator.com/item?id=10096614 https://news.ycombinator.com/item?id=10096614 - Aug 2015 (1 comment) Wat by Gary Bernhardt - https://news.ycombinator.com/item?id=10092845 https://news.ycombinator.com/item?id=10092845 - Aug 2015 (1 comment) Javascript — Wat - https://news.ycombinator.com/item?id=6307393 https://news.ycombinator.com/item?id=6307393 - Aug 2013 (3 comments) WAT - A lightning talk by Gary Bernhardt from CodeMash 2012 - https://news.ycombinator.com/item?id=6054676 https://news.ycombinator.com/item?id=6054676 - July 2013 (1 comment) The WHY of WAT - understanding why 'JavaScript is Crazy' - https://news.ycombinator.com/item?id=3517883 https://news.ycombinator.com/item?id=3517883 - Jan 2012 (52 comments) Wat - https://news.ycombinator.com/item?id=3515845 https://news.ycombinator.com/item?id=3515845 - Jan 2012 (98 comments) (Note: reposts are fine after a year or so - https://news.ycombinator.com/newsfaq.html https://news.ycombinator.com/newsfaq.html. Links like the above are just options for the curious.)
- sethammons 4y agoJust the other day I introduced my daughter who is learning js to this video; so funny
- brasetvik 4y ago>> JSON.parse("{}")["__proto__"]["A"] = "T" "T" >> W = {} Object { } >> W.A "T"
- olliej 4y agoThat’s literally just prototype inheritance vs a UI nicety in node I assume. What alternative behaviour would you expect?
- brasetvik 4y agoIt’s the wat I’ve seen have the most security impact. Deep merging two JSON parsed objects is innocuous enough everywhere else that most don’t think twice about doing it. Lots of widely used libraries that provide deep merging utilities have had security vulnerabilities because of this. I guess you could argue that the wat is that objects coming out of JSON.parse don’t have null as its prototype.
- owl57 4y agoAnd this is not deserving of WAT. This is actually a result of how awesome JavaScript is. But if you ever actually do this, then... WAT.
- nwoli 4y agoIf anyone knows, is this classic video the reason the wasm “assembly” format is called ‘.wat’? I always suspected/assumed it was
- deleted 4y ago[deleted]
- kibwen 4y agoThe format would have inevitably had "wa" somewhere in it for "web assembly", and indeed I assume that the authors were well aware of this famous talk and chose "wat" as a cheeky reference.
- almog 4y agoPerhaps this talk/prophecy is also encapsulated in that reference: https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript https://www.destroyallsoftware.com/talks/the-birth-and-death...
- capableweb 4y agoI did some digging on that in the past and didn't come up with any conclusion. I guess it's possible that someone somewhere came up with it as a reference to the video. But also, maybe it's just a coincident and they came up with WebAssembly Text Format first, then the acronym. But then it should have been WATF instead, so maybe no, after all... Would love any sort of reference to the discussion(s) where the naming and file format name comes up, but didn't find anything relevant last time I looked.
- kevingadd 4y agoFor a while they were .wast files, I don't remember there ever being an official discussion or debate over whether to make it .wat. Your guess at least seems plausible.
- johnfn 4y agoIn case some JavaScript developers are looking for Wats in other languages when people come to beat up on JS again :), here's a "delightful" one from Unity in C# that I've had in my notes for years but never published anywhere. (Note that C# by itself doesn't have this behavior of course - Unity is the Wat factory.) [Serializable] public class Foo { public String bar = "Wat"; } public class Test: MonoBehaviour { public Foo foo = null; void Update() { Debug.Log(foo.bar); // logs Wat } }
- cheeze 4y agoYou can do the same with statics in Java
- kelnos 4y agoNot with that syntax. That syntax declares 'bar' as an instance variable. and 'foo' there is a null pointer, so trying to dereference it like that should produce a NullPointerException. Sure, you could change the declaration of 'bar' to include 'static', and change the access of 'bar' from 'foo.bar' to 'Foo.bar', but... that's not what the code says.
- twic 4y agoI think you can do the same in C++, or at least something very similar. If a method isn't virtual and doesn't touch the object's fields, you can invoke it on null quite happily. Doesn't Go do this too?
- gyrvbg 4y agoShould be featured on typescriptlang.org front page imho. Although typescript still has the “any” type so maybe it could get a video all on its own.
- jjnoakes 4y agoTypeScript has its own WATs too, and to me they are almost worse, because you have this false sense of security based on it being TypeScript and not JavaScript. https://www.typescriptlang.org/play?#code/MYewdgziA2CmB00QHMAUBtARARgAyYBoACHfY0zAXXgFsBDAB1QboCcJYBJMAFwEo+AKCA https://www.typescriptlang.org/play?#code/MYewdgziA2CmB00QHM...
- try_the_bass 4y agoI don't understand why this is a "wat"? This is just a) not understanding how `map` works, and b) not understanding the args to `parseInt`. The callback function for `map` is passed three args: the current item, the index of that item, and the whole array. `parseInt` takes two args[1]: `number` and `radix`. So you're calling (unrolled): parseInt("10", 0) => 10 parseInt("10", 1) => NaN parseInt("10", 2) => 2 This doesn't seem particularly surprising to me? [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- jjnoakes 4y agoMap passes three arguments to parseInt but parseInt only takes two. I think a language with a type system ought to have a way to get a warning for that kind of thing. Especially when it does so in other contexts. I understand why it is this way, but I think it is very surprising and unintuitive behavior.
- jjnoakes 4y agoFor example (continuing my sibling comment), if you unroll it properly, you do get TypeScript complaints. parseInt("10", 0, ["10", "10", "10"]) parseInt("10", 1, ["10", "10", "10"]) parseInt("10", 2, ["10", "10", "10"]) https://www.typescriptlang.org/play?#code/ATAOEMCcGcFMEkB2AXAFAIgIwAZ0BphsCBtLXAs-YSgXQEoAoECGBFDHKzEyizv3PSZgocJGl7AATD37U5tOkA https://www.typescriptlang.org/play?#code/ATAOEMCcGcFMEkB2AX... So TypeScript intentionally suppresses this kind of complaint when matching up function types even though it issues them when calling functions directly. The reason for that has a justification, but in contexts like this, I think it is a WAT-worthy interaction. https://github.com/microsoft/TypeScript/wiki/FAQ#why-are-functions-with-fewer-parameters-assignable-to-functions-that-take-more-parameters https://github.com/microsoft/TypeScript/wiki/FAQ#why-are-fun...
- aftbit 4y agoHmm I cannot reproduce most of these. In node 19, the first two work okay, but the latter two do not agree: > [] + [] '' > [] + {} '[object Object]' > {} + [] '[object Object]' (expected: 0) > {} + {} '[object Object][object Object]' (expected: NaN) Furthermore, the Ruby one fails for me too, in irb 1.4.2, ruby 3.0.5p211: irb(main):002:0> def method_missing(*args); args.join(" "); end (irb):2: warning: redefining Object#method_missing may cause infinite loop /usr/bin/irb: machine stack overflow in critical region (fatal)
- crdrost 4y agoYes! JavaScript is even more watty than you wat! Your context is implicitly parenthesizing the expressions you are evaluated, treating them as expressions rather than statements. Statements are also expressions of a sort too in JavaScript so uh there's also that. Here's the full wat matrix: > do {[] + []} while (false); '' > do {[] + {}} while (false); '[object Object]' > do {{} + []} while (false); 0 > do {{} + {}} while (false); NaN > do {([] + [])} while (false); '' > do {([] + {})} while (false); '[object Object]' > do {({} + [])} while (false); '[object Object]' > do {({} + {})} while (false); '[object Object][object Object]' (as a hint, `{} + []` is actually `{}; +[]`, that is not an addition operator in that context).
- runarberg 4y agoYeah, Gary was actually wrong about that one, you can actually hear objections from the audience: 1. [] + {} is actually the string '[object Object]' not an object per say, {} is the object and [] + casts it to string. 2. {} + [] depends on runtimes. In firefox the first {} is actually an empty statement, not an object Object.fromEntries([]) + [] is always the string "[Object object]" just like [] + {}. In node you can do this {} {} + [] or even {1 + 1} + [] for the desired 0. Effectively it is the same as +[] 3. {} + {} is the same. The first {} is an empty statement
- kaba0 4y agoSee sibling comment
- softwaredoug 4y agoI'll be that person I asked ChatGPT: > Gary Berhnhardt gave a famous talk called "Wat" about Javascript. Can you create similar "Wat" style examples for Python? The examples it gave me were... not that 'wat'-y Sure, here are some "Wat"-style examples for Python: 1. Unpacking tuples: >>> a, b = (1, 2) >>> a 1 >>> b 2 >>> a, b = 1, 2 >>> a 1 >>> b 2 2. Division by zero: >>> 1 / 0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: division by zero Though this one is interesting: 4. Using the is operator: >>> x = 256 >>> y = 256 >>> x is y True >>> x = 257 >>> y = 257 >>> x is y False
- capableweb 4y agoI gave it a try as well, and GPT-4 taught me something new about Python (I don't normally write Python, so it's not surprising): def add_to_list(value, target_list=[]): target_list.append(value) return target_list list1 = add_to_list(1) list2 = add_to_list(2) print(list1) # [1, 2] print(list2) # [1, 2] In this example, one might expect list1 to contain only 1 and list2 to contain only 2. However, because the default value for the target_list parameter is mutable, it gets shared between function calls, leading to unexpected behavior. The other examples it gave me were not that unexpected. Prompt was: > Show me examples of where Python type inference works in unexpected ways.
- roywiggins 4y ago> because the default value for the target_list parameter is mutable, it gets shared between function calls bit of a weird way to phrase it, I think they're always shared between function calls, you just don't notice when they're not mutable.
- masklinn 4y agoThat is correct, default values are initialised at compilation time and stored in the function object.
- afraca 4y ago
- sparker72678 4y agoOne of my favorite lightning talks of all time. So well done.
- maliker 4y agoI usually show this to new devs starting out as a quick way to explain inconsistent and/or leaky abstractions. It’s a great and entertaining intro.
- vasergen 4y agoNot sure what js shell he uses, since it is an old video but in browser or node you will get predictable results for his examples. What you need to know that in js '+' sign will add numbers only if both operands are numbers, otherwise it will coerce both to string type, which is true for {} or []. To convert to string js will use '.toString()' method like this {}.toString() and [].toString(). Now {}.toString() is equal to a string '[object Object]' and [].toString() is equal to an empty string '' (for non empty arrays it will print numbers separated by comma). So if we add anything in JS and on both sides are not numbers we actually add strings! And adding strings means concatenation and it works as you would expect, just put two strings together. Having that, let's take a look on those examples again 1. [] + {} equal to '[object Object]' 2. {} + [] equal to '[object Object]' 3. {} + {} equal to '[object Object][object Object]' So no 'magic' involved there. Note that some results are different as in the video, you can check it in console in your browser UPD: typo
- crdrost 4y agoNone of the behaviors mentioned in the video have changed; they are all pinned down by ECMAScript standards and to change them would be a breaking change to the internet. The behavior of your console might be slightly different from the behavior of his console, but there are still many reasonable ways to replicate his results. See my comment below if you're still unsure about this point.
- threatofrain 4y agoI'm getting inconsistent results in Node (19.8), Deno (v8 11.2), Chrome (112), Safari (16.4).
- vasergen 4y ago> but there are still many reasonable ways to replicate his results But can you replicate his results for js in any modern browser or node environment? I agree that standards are fixed, but there is definitely a difference between implementation of those standards in different environments
- threatofrain 4y agoNaN ** (NaN >> NaN)
- olliej 4y agoIt’s been more than a decade of this drivel, that largely is not weird or bizarre if you actually think about what is being shown. The only legitimate complaints come from the type coercion rules, and even those are completely consistent albeit suffering from the era of “scripting languages should do conversions implicitly”. Things like {} + {} Behave weirdly, only if you don’t ask what happens in every other brace based language when given that syntax: the first {} is parsed as a block statement in C, C++, Java, C#, giving you a +{} expression. Similarly conflating repl output with the value of expressions as though the language is doing something odd. Or the absurd belief that typeof NaN should be something other than number. While I do love the idea of statically typed languages being forced to crash on NaN results at runtime, that being because the value type is suddenly wrong is stupid.
- anyfoo 4y agoOne can fully understand the type coercion rules and the effects that result from them, and still acknowledge that said type coercion rules are not optimal, at least because they lead to very non-optimal outcomes. I for one am tired of people claiming that this is not "weird or bizarre", because not only is it obvious that several parts of JavaScript including the type coercion rules are (at best) strange, it's also absolutely not surprising from its history: The person who originally invented JavaScript wanted to implement Scheme, but management wanted to go for "something similar to Java". JavaScript was prototyped in ten days[1], and I doubt anyone back then really anticipated the role it would later come to have. There is an entire standards body that aims to hammer JavaScript into something that makes more sense, because, well, we're stuck with. (Or rather, you are stuck with it, I don't do web development.) https://web.archive.org/web/20200227184037/https://speakingjs.com/es5/ch04.html https://web.archive.org/web/20200227184037/https://speakingj...
- JonMR 4y agoI was there live! Good times. A friend convinced me to dip out of another session to go watch Gary's talk. I feel lucky. I've seen Gary give a few talks. All fantastic. The Birth & Death of JavaScript is my second favorite. The fact that he stayed in character as someone from 2035 for the entire talk and used a slightly evolved English.. brilliant. I saw that at Strangeloop and have fonder memories than the PyCon rendition on his site. https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript https://www.destroyallsoftware.com/talks/the-birth-and-death...
- noman-land 4y agoThis guy does such great videos. The 2035 thing was so creative. And Wat is legendary in Javascript circles.
- bb88 4y agoYeah, I re-watched that video tonight. We're coming up on the 10th anniversary of "The Birth and Death of Javascript". Much of it still holds water. I think what's disappointing is how little progress we've come in the 9 years since that video has come out. WASM has been a disappointment -- at least to me. And the problem WASM solved really would be almost better instead if we just had a ring 4 for web browsers. It seems clear that X86 has won, unless you think that RISC V still has a chance (which is dubious unless you're in the embedded space)
- jmillikin 4y ago> And the problem WASM solved really would be almost > better instead if we just had a ring 4 for web > browsers. It seems clear that X86 has won, unless > you think that RISC V still has a chance Mobile has a large and growing lead over desktop[0] for web traffic, and every popular mobile device released for the past ~decade has run on ARM. [0] https://techjury.net/blog/mobile-vs-desktop-usage/ https://techjury.net/blog/mobile-vs-desktop-usage/
- bb88 4y agoArm was only %8 of the CPU market in 2021. https://www.theregister.com/2021/11/12/apple_arm_m1_intel_x86_market/ https://www.theregister.com/2021/11/12/apple_arm_m1_intel_x8... I'm still waiting for those arm desktops that run Windows...
- at_a_remove 4y agoI am in no sense a person who has the chops, inclination, or talent to create a programming language. However, I do sometimes think about "What would a programming language with the following precepts be like?" and pose to myself various hypothetical axioms, or results, or constructs. It would be ... interesting ... to design a language without WATs. Where the truth tables and the NaNs and whatnot all made a kind of sense. I am left wondering if perhaps a minimum number of WATs would inevitably be present, no matter your design.
- acomjean 4y agoI think the language spec is where you would define things so you don't get "WATs". Getting a language that is intuitive and consistent is part of the tricky part. https://www.ecma-international.org/publications-and-standards/standards/ecma-262/ https://www.ecma-international.org/publications-and-standard... https://github.com/php/php-langspec/blob/master/spec/08-conversions.md https://github.com/php/php-langspec/blob/master/spec/08-conv...
- twic 4y agoGary blocked me on Twitter. I have no idea why. But in a strange way I feel honoured.
- kaba0 4y agoIsn’t that just that new behavior of Twitter where people can forbid what circles can see their posts? I also found that I can no longer view several “global” posts unless I follow the given person, which has to be approved or something like that? I only rarely use Twitter though.
- twic 4y agoI don't think so. It's been this way for years, and if i look at his profile in a private browsing tab, i can see everything.
- shadowgovt 4y agoJavaScript is some of the best evidence we have that design consistency is not the dominant factor in determining language popularity. I haven't figured out what is yet. I have a hunch that having a short path to working small and medium complexity projects is a big part of it. But I can't rule out the possibility that the most important thing is just application context... Would anybody still care about JavaScript if the browser hadn't happened?
- Cacti 4y agoWithout the browser, JavaScript wouldn’t even be called JavaScript.
- toyg 4y agoWithout the browser, JS would just not exist. It was invented explicitly to animate html pages in Netscape, in a couple of weeks. Arguably, nobody else would ever need a language with JS's original feature set.
- kragen 4y agoyou are absolutely correct; the most important thing is just application context java was in browsers but couldn't manipulate the dom; same thing with flash vbscript was in browsers but only msie
- kaba0 4y agoAnd that context is largely politics. There is no reason why Java could not have manipulated the DOM.
- kragen 4y agoright, or elisp or tcl or perl or basic or bash technical merit does matter to some extent; forth or assembly would probably not have been adequate, and javascript is far superior to java for this
- Buttons840 4y agoSince JavaScript has only a few data types, and no operator overloading, I'm just going to memorize how the operators work on each type. This will save my sanity from the underlying logic.
- DiabloD3 4y agoThe wat video is one of my favorite videos to show newer programmers. It really convinces them not to use Javascript, and consider more serious, mature languages... like Rust. (If this was a TED talk, this is where the audience would confusedly applaud)
- mgoetzke 4y agoWhile I like Rust a lot in many ways and have been around for quite some time :) Javascript, like Rust, is just a tool and experienced programmers choose the right tool for the job. Just going by syntax (or in this case type coercion) alone is too simplistic for me. Erlang, Eiffel, C, ASM, JS, Rust, C#, F#, Java, or any other language almost can be good choices depending on circumstances. As for the specific claim of maturity. Rust is quite solid and attractive to me, but based on the number of changes over the last years not necessarily more mature than any other bigger language out there and arguably quite young albeit with a nice and growing ecosystem. Rust specifically is also in danger of going down the C++ route with a lot of over-engineering though by having too many levels of abstractions (And I write this as someone who learned C++ from a typewriter style written book of Stroustrup himself and loved every minute of it)
- jeffhuys 4y agoReally, you're just closing a door on them based on your opinion. Newer programmers, and you let them consider Rust vs JS? That's a `wat` in my opinion.
- chrisweekly 4y agoClassic. I laughed almost as hard rewatching it just now as I did on first view over a decade ago.
- ChancyChance 4y agoI've seen so many HN posts on "hey look at this silly language thing" that I'm immune.
- bmitc 4y agoBrilliant and actually humorous presentation. At first, I thought it was going to be some nerd deep-dive, but then it really was just a presentation of wats. And honest to god, how do people program in JavaScript?
- masklinn 4y agoCarefully. These issues pretty much all come down to implicit conversions, which you quickly learn to avoid as it’s usually unhelpful (likely a reason for typescript’s popularity).
- cipheredStones 4y agoJavascript has a lot of weird type coercion behavior, but it's not actually hard to avoid. "Never use ==" and "don't use operators on things if it's not obvious what they would do" gets you pretty much everything you need there. This is not to say that there's nothing else weird going on in Javascript, but the things people show off most as "wow, isn't this weird?!" aren't that consequential.
- jdlshore 4y agoThey use a linter. Linters are an established and commonly-used part of the ecosystem, and entirely prevent these issues.
- jeffhuys 4y agoIn normal development, you don't try to add a number to an object, or two arrays together, for instance. I know people just _want_ to bash JS because it's trendy, but come on.
- ratorx 4y ago> In normal development That’s the problem. This is an unexpected situation and the JS philosophy is to silently do something that tries to make the best of it, rather than e.g. throw an error or warning. I think it’s perfectly reasonable to bash JS for this. This is a direct consequence of the JS design philosophy. This is similar to the memory-safe vs memory-unsafe debate (except IMO, slightly dumber because I can’t personally think of any reason this is the behaviour you would want, whereas there might be performance reasons for memory-unsafe). It is increasing the bar of producing good code, without any actual benefit.
- userbinator 4y agoThis was probably more humorous in person, but I do wonder if it's human instinct to ridicule things one doesn't understand. Intuition isn't universal, and what might appear to be straightforward rules in isolation can lead to complex and surprising emergent behaviour when combined.
- edem 4y agoOldie but Goldie!
- kzrdude 4y agoI guess a Rust wat would be fn get_x() -> i32 { return return return return return return return return return 1; }
- scoopr 4y agoSome fun ones at https://github.com/rust-lang/rust/blob/master/tests/ui/weird-exprs.rs https://github.com/rust-lang/rust/blob/master/tests/ui/weird...
- kzrdude 4y agoclosure_matching: wat! I figure out that "|_| Some(2) =>" in a match arm is just a disguise for the alternation "_ | Some(2)" with prefix separator, but what does the `let` do there?
- alabhyajindal 4y agoThis guy went from making fun of JavaScript to teaching JavaScript
- abdellah123 4y agoI love coding comedy genre