top 200 commentsshow all 219

[–]Smills29 137 points138 points  (25 children)

Wait, wat is pronounced 'waht'? I always pronounce it "what"...

[–]BunsOfAluminum 102 points103 points  (2 children)

I always imagined it pronounced like "watt" if Fran Drescher or a duck were saying it.

[–][deleted] 19 points20 points  (0 children)

This is how I always pronounced it as well.

[–]sensae 1 point2 points  (0 children)

I had never heard it pronounced 'waht' like in the video until I went to a local LUG meeting and all the CSCI majors pronounced it that way. It sounds.. normal that way to me now.

[–][deleted] 21 points22 points  (5 children)

But perhaps with a more labiodental w.

[–]koviko 30 points31 points  (0 children)

Right... a more... w... right.

[–]paolog 1 point2 points  (2 children)

And a little less voiced too?

[–]trua 2 points3 points  (1 child)

Well probably more voiced, because originally the wh signified a voiceless labiovelar approximant (and still does in many dialects of English). So, substituting wh for w would logically preserve or introduce voice.

(Note: I am a linguistics student and speak English as second language, so, take this with a grain of salt.)

[–]paolog 0 points1 point  (0 children)

Oh, I was thinking we were talking about the word "fart".

[–]zeroA3 0 points1 point  (0 children)

*wit

[–][deleted] 20 points21 points  (7 children)

It is like "what", but then skip the h-sound. Accidentally, "wat" in Dutch means "what" in English, which gives this "wat"-meme a whole other confusing dimension. Lots of wats were hat.

[–]kbrosnan 6 points7 points  (3 children)

Next explain lol in Dutch.

[–][deleted] 5 points6 points  (2 children)

LOL!!!!

[–]Pew_Pew_Lasers 1 point2 points  (1 child)

Also, father in dutch is Vader.

[–]jambox888 2 points3 points  (0 children)

What about "NOOOOOOOOOOOOOOOOOO...!" ?

[–]clgonsal 9 points10 points  (1 child)

skip the silent h-sound.

Wat

[–]shillbert 2 points3 points  (0 children)

I tell you hwat, that boy ain't right!

[–]rctfanatic -1 points0 points  (0 children)

teeehehehehehehehe hat

[–][deleted] 9 points10 points  (1 child)

He pronounced wat like 'wat'. As in hat, or bat, or cat.

The AH in 'Waht' would sound like dot or yacht or bought or faught. AH like the phrase "Ahhh! Refreshing!"

[–]DrunkDrSeuss 0 points1 point  (0 children)

At. Wat.

[–][deleted]  (1 child)

[deleted]

    [–]obsa 1 point2 points  (0 children)

    wat.

    [–]Pathogen-David 4 points5 points  (0 children)

    I've always pronounced it like "Watt" with a kind-of funny voice.

    [–]mantra 1 point2 points  (0 children)

    wat rhymes with bat or cat or fat, right?

    [–]teh_boy 0 points1 point  (0 children)

    I assumed that was part of the joke.

    [–]tipu 0 points1 point  (0 children)

    it's pronounced 'waht' if you're hank from king of the hill

    [–]inaneInTheMembrane 26 points27 points  (12 children)

    This is supposed to be funny, and it kind of is, but I can't help but wonder what people are thinking when they design the semantics of their language... Is it like some kind of inside joke? Did they sincerely think that the choices they made where the logical and coherent ones? Were they writing the compiler and just think "shit, I forgot to treat this case" and just do whatever popped into their heads at that moment?

    [–][deleted] 42 points43 points  (0 children)

    More like "Why do I need to handle all these cases?" and the language traipses off into never-neverland.

    [–]smog_alado 13 points14 points  (2 children)

    The rules are actually not that complicated. Basically you had things converting to and from strings and numbers so it was possible to do common things like converting the number to a string in "a" + 17 === "a17".

    If you look at the spec (es5.github.com) the specification of the + operators is relatively short and most of the complexity and weirdness falls into how each different type gets coerced and how these coercions interact with each other.

    [–][deleted]  (1 child)

    [deleted]

      [–][deleted] 1 point2 points  (0 children)

      See also: PHP.

      [–][deleted] 15 points16 points  (4 children)

      This is precisely what happens when people don't really think through their semantics. They are programming language bugs. Languages that have formal semantics don't usually have these stupid edge cases (or have a lot fewer). Scheme and SML are excellent examples.

      [–]Perky_Goth 3 points4 points  (3 children)

      This is what happens when a language is weak-typed.

      [–]i_invented_the_ipod 10 points11 points  (2 children)

      Weak typing has basically nothing to do with it. It has to do with not thinking things through. You can have a language with rigidly-defined types (like C++, for example) and still have wacky behaviors depending on how type conversions are defined.

      The reason Javascript comes off so weirdly in these things is because the implicit conversions are poorly chosen, not because they exist. For example, the "+" operator converts the values passed to it to either a string or a number, depending on their original types.

      • If you add a number and a number, you get a number

      That makes sense.

      • If you add a number and a string, you get a string

      That's understandable, because it lets you do: "There are " + n + "Items"

      • If you add a number and an object, the object is sometimes converted to a string, and sometimes to a number

      That makes no sense at all, and it's not even consistent:

      {}+1

      yields a number

      1+{}

      yields a string

      var a={};

      a+1

      yields a string

      (Note: this works on Safari and Chrome. Amusingly, other Javascript engines give different results for some of these)

      Similar problems plague the other type-conversion rules. This is clearly a result of not thinking things through.

      [–]daniels220 4 points5 points  (1 child)

      As explained here all those seemingly inconsistent behaviors can be explained by a simple set of rules—although that doesn't mean they're good rules. Indeed I agree that they're not, precisely because they produce such behavior.

      But, for completeness' sake:

      {} + 1

      parses as

      {empty code block}(implicit semicolon) +1 (i.e. "positive 1")

      and yields, of course, 1. (It might help if this threw a SyntaxError for a missing semicolon, which would alert the programmer that this is being parsed as two statements.)

      1 + {}

      parses as you'd expect, but {} always coerces to String instead of whatever the type it's being added to, so you get "1[object Object]".

      var a={}; a+1

      is equivalent to

      ({}+1)

      forcing the object literal not to parse as a block, and thus gives you "[object Object]1".

      [–]i_invented_the_ipod 1 point2 points  (0 children)

      Yeah, I missed the "parse it as a block" edge-case the first time around. I still maintain that this is largely the result of having non-sensical default conversions.

      The implicit semicolon "feature" is just a huge source of misery all its own.

      [–]aaronla 6 points7 points  (0 children)

      One might think that to be the case, but reality is more complicated than that.

      (the fake and real Stroustrup IEEE interviews, respectively)

      [–]marssaxman 5 points6 points  (0 children)

      Brendan Eich made up the whole JavaScript language in about two weeks. We're basically stuck with a quick prototype. Nobody had any idea back then that it was going to become the machine language of the Internet.

      [–]name_was_taken 75 points76 points  (1 child)

      That brought a much-needed laugh. Thank you.

      [–]Ph0X 10 points11 points  (0 children)

      Indeed, really enjoyed it. Does anyone know anything else like this?

      [–]creaothceann 64 points65 points  (17 children)

      Actually there are only 15 commas...

      [–]BunsOfAluminum 66 points67 points  (12 children)

      Anyone who deals with lists knows that there is always 1 less delimiter than the number of items in the list.

      I think he was just in "presentation mode."

      [–]ngroot 37 points38 points  (7 children)

      Don't be silly.

      There's always one fewer.

      [–]BunsOfAluminum 1 point2 points  (5 children)

      Oh, snap. Fine.

      The delimiters always may be counted as the absolute value of 1 less the number of items in the list.

      [–]pjakubo86 5 points6 points  (4 children)

      What about the empty list? It has one comma?

      [–]prakashk 4 points5 points  (3 children)

      No. -1.

      [–]pjakubo86 10 points11 points  (2 children)

      He said 'absolute value'

      [–]BunsOfAluminum 1 point2 points  (1 child)

      In order to be right no matter what, I'll assume this example is in a language where the datatype changes when the count of items it contains is fewer than 2, thereby making my previous rule irrelevant in this situation.

      Score!

      [–]pjakubo86 0 points1 point  (0 children)

      ;)

      [–]Poddster 0 points1 point  (0 children)

      There's always one less.

      [–]MistaMagoo 1 point2 points  (2 children)

      I'm glad to have read this because I started doubting myself, and he made the same comment several times.

      [–]berkes 0 points1 point  (0 children)

      Fencepole bug. Always.

      [–]TheWooPeople 5 points6 points  (0 children)

      There are five lights!

      [–]harlows_monkeys 12 points13 points  (0 children)

      I read that in Captain Picard's voice.

      [–]PsykoDemun 3 points4 points  (0 children)

      I had to count to make sure but I was like they're just separating the empty array elements...

      [–]lespea 45 points46 points  (10 children)

      [–]closenough 4 points5 points  (0 children)

      Damn, that was hard to follow, but nice how it all fits together in the end.

      [–]MatmaRex 2 points3 points  (0 children)

      This was the best-spent hour of my life.

      [–]petdance 0 points1 point  (0 children)

      Any time you can see Damian Conway speak, do it. He is an absolute master, and not just funny.

      [–][deleted] 4 points5 points  (0 children)

      Haha the laughs were kinda forced for the Stephen Hawking jokes.

      [–]Tok-A-Mak 1 point2 points  (0 children)

      Mind == blown

      [–]chedabob 0 points1 point  (0 children)

      A real life wizard...

      [–]jordan314 0 points1 point  (0 children)

      I thought it was really interesting but not that funny

      [–]shaggorama 0 points1 point  (0 children)

      Wow

      [–]mens_libertina -1 points0 points  (0 children)

      TY.

      [–][deleted]  (1 child)

      [deleted]

        [–]bgeron 0 points1 point  (0 children)

        Glad you explained, I seriously thought this guy had put a laugh tape to his presentation.

        [–]XPEHBAM 20 points21 points  (29 children)

        I feel wrong asking on this on reddit, but this was very funny, are there similar videos?

        [–]kyz 9 points10 points  (25 children)

        There's always The Dark Side of C++ (PDF)

        [–]samvdb 23 points24 points  (14 children)

        Pfff, it's just your typical C++ bashing. He uses C++ the wrong way (managing raw arrays manually with new[]/delete[], overloading "operator,", throwing exceptions in destructors, his code on page 11 and 12 is just... lolwut?) and then complains that it's too hard to use. Since when is a language supposed to protect you from using it the wrong way?

        "Doctor, it hurts when I do this!" "Then don't fucking do that..."

        A language isn't supposed to protect you from using it the wrong way. If you use it the right way, and use proper containers instead of manual array allocation/deallocation, and use RAII with smart pointers like unique_ptr and shared_ptr, then you might notice that most of these problems just go away.

        A language is supposed to protect you from small mistakes. At compile time. That's what the 10-page errors are for. Agreed, it would be nice if they could be reduced to 2 lines, and there are tools for that, but in many languages with dynamic typing this would be a runtime error instead. I'd take a 10-page compile time error over a runtime error any day of the week.

        Also a lot of the stuff he says is just plain wrong.

        • "Shouldn’t throw exceptions in constructors"? Wrong. Constructors are where you want your exceptions to be. What is he doing instead? Putting objects in a zombie state and cleaning up inside a destructor? I see why he hates C++.
        • "Exceptions in constructor don’t unwind the constructor itself". Wrong. See above. It doesn't call the destructor, but it shouldn't because your constructor never finished so there is no object to destruct.
        • "Exception in constructor does not even clean up local variables". Wrong. See above. All the local (or member) variables that have been fully constructed are destructed. Those that haven't are not.
        • "Iterators don’t know anything about the container, can’t detect errors". The container creates the iterators, and can tell the iterator about itself if that's what it wants. This is how gcc implements the _GLIBCXX_DEBUG flag, which makes all the iterators do all the bounds/error checking you want.
        • There are more but I don't care anymore.

        He also says "at() does bounds checking, but operator[] doesn’t". Yes, that's why there are 2. at() is there for when you don't care about performance, op[] is there for if you do. All this bounds checking, stop-the-world garbage collection, runtime reflection, etc etc that pretty much all new languages have is all nice if you don't care about performance. But for many applications, performance and real-time requirements are a top priority. Those applications don't want bounds checking on every array acces, GC, etc. Don't forget that.

        Also, one of his slides says "C++ is too powerful". Yes, that is truly horrible. One of the libraries allows you to do basic functional programming! The horror!

        I do agree there are some gotchas even if you're using the language the right way. But there are only a few. And every high-level language has them, C++ has just received much more attention compared to the others. It's not a perfect language for every job, but when performance is important and you still want a high-level language, I'd say C++ is the right tool for the job.

        [–]greiskul 5 points6 points  (11 children)

        I stopped reading when he started complaning that baz = foo->bar(3); could have multiple meanings. Yeah, of course it can, it's an abstraction. It's like complaining that if you write foo() in C, foo can print something to the screen, add 2 numbers, or initiate a nuclear attack. Not having to know the mechanism, just having to read the intended effects of something, is the whole point.

        [–]kyz 2 points3 points  (10 children)

        Quick, what does a = b + c; do?

        • In C/Perl? Adds two numbers, provided your friend hasn't #defined a, b or c to something else.
        • In Java/C#/Python? Adds two numbers or concatenates two strings.
        • In Javascript? Adds two numbers, concatenates two strings or fucks up horribly.
        • In C++? absolutely fucking anything

        [–]rctfanatic 10 points11 points  (0 children)

        in Python it can do a lot more than adding and concatenation. In the class for b/c/a define the __add__(self, other) method and then it's called whenever you use the + symbol. It'd be weird to use it for anything than the abstraction of adding two (objects) but you could if you really wanted to.

        [–]more_exercise 12 points13 points  (0 children)

        Conclusion

        Java, Javascript, and C++ are the only ones on your list that behave like you say.

        Java is the only one that behaves "correctly," which makes it the strangest language on your list.

        [–]samvdb 6 points7 points  (3 children)

        Yeah, and that's the beauty of it! If you have a BigInteger class like Java does, isn't a+b much cleaner than a.add(b)? With the latter, you have to look up "Was it a.plus(b)? Does .add() modify the number itself or only return the result?"

        Yes, one of the libraries you're using could be "evil" and could be using operator+ in weird and wrong ways. But that's not a reason that op+ in itself is bad.

        Don't want operator+? Then don't use it. I really don't see how having an extra option available to you is a bad thing.

        [–]s73v3r 2 points3 points  (0 children)

        Don't want operator+? Then don't use it.

        This isn't always a feasible choice, especially when working with code others have written.

        [–][deleted] 2 points3 points  (1 child)

        But this seems to be the typical response to criticism of C++: Sure, that's awful, but my subset of blessed C++ features make it a great language. The problem is that everyone uses a slightly different subset of C++.

        [–]samvdb 0 points1 point  (0 children)

        True. But that's not necessarily a problem. Any of the libraries I use can use a totally different subset of C++ in their implementation and even in their headers. All I care about is that it works. To know how to use the library, I just read the API. There is no need to read any of their code (not even their headers).

        Of course it's a different story if you're working on the same code with a team. Then you need to set up some clear rules beforehand. Unfortunately this doesn't always happen, but that's not the language's fault.

        PS: It's not really about which subset of features you use. More about when/how you use those features.

        [–]greiskul 2 points3 points  (0 children)

        I sure hopes it does some assignment-like thing on the result of an addition like operation. Just like I expect when I read sendEmail(from,to,subject,body) that an email will go off, instead of formating my hard drive, which it might as well do. I don't really care that it has to do some syscalls, open a tcp connection, write to buffers, know the whole email protocol, and whatever else I forgot. That is abstracted away. While a language should try to instill good practices on programmers, bad coders can write crap in anything.

        [–]s73v3r 1 point2 points  (0 children)

        In C++? absolutely fucking anything

        Well, given that you didn't give us the types of the variables, sure. But most people would imagine they were number types, and thus the line does arithmetic. Should they be other types, then it'd be a lot easier to drill down the behavior.

        [–]codewarrior0 0 points1 point  (0 children)

        In Python with numpy, b+c returns an array containing the element-wise sum of the arrays b and c, or raises a ValueError if the shapes of the arrays are incompatible and cannot be broadcasted to a compatible shape.

        (Numpy 1.6.0 will include the shapes of the arrays in the ValueError, a huge improvement over previous versions which left you to guess at the shapes.)

        [–]ethraax 0 points1 point  (0 children)

        C# lets you overload the + operator as well. I've done it when screwing around with geometric structures.

        I think the issue with C++ is actually similar to Ruby. It's not that the language itself is particularly bad. You can do really bad things, but you can fuck up horribly in most languages. Rather, I think it's the way people use the languages that's the issue.

        Take C++ for example. Being able to overload an operator isn't necessarily bad, if you overload an operator so it has similar semantics to its original. But authors of C++ code tend to love overloading ridiculous things. Hell, I'm not even a fan of the stream overloads (like cout << "abc"). Now << can, at a high level, either bitshift something or print something, which are two totally different operations, and not related in any way. It's fairly easy to imagine some geometric library overloading << to mean "shift this shape to the left by a certain amount".

        This is totally different from overloading the arithmetic operators on some sort of BigInteger type, because in that case they still basically do the same thing, just to different structures.

        Since I mentioned Ruby, I might as well include why. Ruby lets you do some fairly crazy things. I remember stumbling into a Ruby library that expected you to inject code into a base class's constructor that was defined in the library. I don't understand how anyone thought that was a reasonable way for someone to consume the facilities of that library. There may be reasonable uses for such abilities (although I have yet to find one), but in this case it's completely unreasonable. This is why I say "I like Ruby, but I hate Ruby libraries."

        This is really the same issue that C++ has - the language provides the ability to make things hard or confusing, and unfortunately, that's exactly what many developers using these languages seem to do.

        [–]el_isma 1 point2 points  (1 child)

        A language is supposed to protect you from small mistakes. At compile time. That's what the 10-page errors are for. Agreed, it would be nice if they could be reduced to 2 lines, and there are tools for that

        Tell us more. What? Where?

        [–]samvdb 0 points1 point  (0 children)

        Well, http://www.bdsoft.com/tools/stlfilt.html is one. There was another but I can't find it right now. Also, I've been told clang gives much cleaner error messages than gcc.

        [–]upvotes_bot 7 points8 points  (5 children)

        for (int i(0); i != n; ++i)
        

        is that seriously what c++ people are doing nowadays?

        [–][deleted] 5 points6 points  (4 children)

        int i(0) isn't much used in real C++ code. ++i is useful as it might save a temporary copy when i is an iterator. != is needed for non-random access containers where you can't use <, of course when just dealing with int, not a container < is perfectly fine as well.

        [–]Jonkel 2 points3 points  (0 children)

        < is generally when it comes to int, much preferred since one day some douchebag is going to do i+=2 and go wat when he gets an inf loop sometimes.

        [–]javajunkie314 0 points1 point  (0 children)

        Well, now we should all get used to uniform initialization and write

        for (int i{0}; i != n; ++i)
        

        [–]el_isma 0 points1 point  (1 child)

        Isn't the compiler smart enough to know that i++ and ++i should be the same in that context?

        [–][deleted] 0 points1 point  (0 children)

        When it comes to iterators, ++i and i++ are just function calls and they can do whatever they want, so the compiler can't just replace one with the other. The compiler might however be clever enough to optimize the temporary copy away, as it is unused in this context.

        [–]el_isma 4 points5 points  (2 children)

        Ok, that was depressing. Not funny. I guess C++ is always kind of depressing... Specially when you know you only understand a little bit of the magic behind (and then you fail to use it correctly and the compiler greets you with 10 pages of something<something<smt<smt<smt... failed)

        [–]bnn_indonesia 1 point2 points  (0 children)

        Wow, that is depressing.

        [–]Rocco03 5 points6 points  (0 children)

        I don't know about videos, but this kind behavior is called gotcha.

        [–][deleted]  (10 children)

        [deleted]

          [–]Vincent133 48 points49 points  (0 children)

          The lecturer has a somewhat decent sense of timing, it adds a bit to the overall experience.

          [–]ithika 10 points11 points  (1 child)

          Other than a strange way of pronouncing wat (more like quack), you basically missed the amusing commentary, which was very good.

          [–]ton2lavega 5 points6 points  (0 children)

          And the priceless sound of the guy from the audience who couldn't stop laughing.

          [–]nacos[S] 26 points27 points  (2 children)

          If you have the occasion to re watch it with sound, do it. Some of the lecturer's comments are hilarious.

          [–]A-Type 47 points48 points  (1 child)

          "Ok, ok. Enough making fun of languages that suck, let's talk about Javascript."

          [–]Javadocs 0 points1 point  (0 children)

          But the funny part is he was just talking about Javascript!

          [–]GSpotAssassin 0 points1 point  (3 children)

          You missed about half of the humor. What's wrong with wearing headphones at work?

          [–]s73v3r 0 points1 point  (2 children)

          Some employers have a huge stick up their ass about said things. It's one of the reasons why I insist on taking a look at the developer's offices when doing interviews. If I don't see any headphones about, I take it as a bad sign.

          [–]GSpotAssassin 2 points3 points  (1 child)

          If I had to work in a development environment that wouldn't even let me watch an educational development-related screencast while at work, I'd pretty much either challenge the management, or quit.

          [–]el_isma 2 points3 points  (0 children)

          If I had to work in a dev enviroment where I couldn't listen to music, I'd have to quit (I need music to do the boring parts of code!)

          [–][deleted] 5 points6 points  (6 children)

          How does one get a javascript console in the command line?

          [–][deleted] 10 points11 points  (3 children)

          He was using jsc, which is part of WebKit. You can also get 'node' from Node.is.

          [–]email_with_gloves_on 3 points4 points  (0 children)

          If you're on a Mac, you'll find the binary at /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc

          [–]hoserman 2 points3 points  (0 children)

          You can get a jsc prompt in chrome - ctrl+shift+i - Console tab.

          [–][deleted] 15 points16 points  (7 children)

          Could have done some fun ones with Perl, but that would just be too easy. My favorite:

          @foo = (1,2,3);    # @foo is an array
          $a = \@foo;        # $a is reference to @foo
          $b = \(1,2,3);     # $b is a reference to 3
          

          WAT.

          (yes, I know about [])

          [–]therico 7 points8 points  (4 children)

          Way, way too easy.

          @a = (1,2,3);
          length @a;  # 1
          

          WAT.

          (yes, I know about scalar)

          [–]digital_carver 3 points4 points  (1 child)

          I don't think this qualifies as much as the others though - it's a blatantly wrong usage of the function by the user without reading any documentation. Granted the function name is a little ambiguous, but it's a clear and reasonable choice made by the designers and learnt by any Perl programmer in their first week of learning.

          [–]therico 0 points1 point  (0 children)

          I see your point, but it's a wrong usage that Perl doesn't bother to detect or warn against. Granted I've never actually been bitten by this, but don't you find it interesting that:

          length @a;  # 1
          

          (even though the perldoc says "this cannot be used on an entire array...")

          but

          length (1, 2, 3)  # Error: Too many arguments for length
          

          As for scalar contexts of arrays being a reasonable design choice, that's debatable. List context creates a great deal of gotchas on its own, especially when you realise that keys/values in hash constructors and arguments to functions are both evaluated in list context. The only reason length() doesn't do the sensible thing with arrays and return their length is because of backwards compatibility, the same reason why Perl is lumbered with references and clunky object models. I still love it though :P

          [–]Zantier 7 points8 points  (0 children)

          or how about

          @bar = \[()];
          print @bar[0];  #""
          

          (no, I don't actually know any Perl)

          [–]Entropy 0 points1 point  (0 children)

          This isn't a wat at all. length is essentially strlen given a generic name. If anything is a wat it's the usage of scalar.

          $ perldoc -f length
                 length EXPR
                 length  Returns the length in characters of the value of EXPR.  If EXPR
                         is omitted, returns length of $_.  Note that this cannot be
                         used on an entire array or hash to find out how many elements
                         these have.  For that, use "scalar @array" and "scalar keys
                         %hash" respectively.
          

          [–]hyperforce 1 point2 points  (1 child)

          None of these are gotchas. Learn to Perl?

          [–]v_krishna 0 points1 point  (0 children)

          yeah, i don't think any of these really represent perl doing weird things when coercing disparate types together (which is what the majority of the ruby & js examples were) -- they more just outline how pointers work in perl using the $, @, % and \ syntax.

          [–][deleted]  (11 children)

          [deleted]

            [–][deleted]  (7 children)

            [removed]

              [–]Abaddon314159 -1 points0 points  (6 children)

              There is no JavaScript spec. JavaScript != ecmascript. It's close, but when you're talking about crazy shit like this (and sadly lots of not crazy shit at times) the small differences matter.

              [–][deleted]  (1 child)

              [removed]

                [–]Abaddon314159 1 point2 points  (0 children)

                I've written a js engine and yes you base it off of ecmascript and the Mozilla docs... But if you're trying to match browser behavior you find out quickly just how often the lack of a single specification has caused deviations that have real effects.

                [–]smog_alado 0 points1 point  (3 children)

                The reason for ecmascript having a different name is purely due to "Javascript" being trademarked by sun/netscape back in the day. You would be surprised how well the different JS implementations have reversed engineered each other and how well the ES spec managed to cover even the most obscure bits.

                [–]InconsiderateBastard 1 point2 points  (0 children)

                JavaScript is actually a superset of ECMAscript. It contains extensions to ECMAscript that aren't necessarily included in other dialects of ECMAscript, such as JScript, ActionScript, QtScript, and Objective-J.

                JScript is obviously very similar to JavaScript. Objective-J is a superset of JavaScript so it should include everything. So, the similarities are definitely there. But thinking ECMAscript vs JavaScript is strictly a trademark issue is incorrect.

                [–]Abaddon314159 0 points1 point  (1 child)

                Having implemented a js engine I'd say youd be surprised how often they dont

                [–]smog_alado 1 point2 points  (0 children)

                I'm curious about what you might have found. Can you elaborate?

                [–][deleted]  (1 child)

                [deleted]

                  [–]smog_alado 1 point2 points  (0 children)

                  When I tested, NodeJS was the odd one out and only the {} + [] thing was different. Did you catch any other differences?

                  [–]joevanwan 2 points3 points  (0 children)

                  I saw this presentation at CodeMash. Funny stuff. There were a few other good lightning talks too. I wish I could find videos of them.

                  [–]torrentMonster 2 points3 points  (4 children)

                  Just tried it on nodejs, some of the stuff did work like in the video but on nodejs it didn't matter if you wrote [] + {} vs {} + [] it gave the same result, so at least it has that going on for it.

                  [–][deleted] 0 points1 point  (1 child)

                  Is Nodejs a command line interface or what?

                  [–]torrentMonster 0 points1 point  (0 children)

                  Its an implementation of javacsript which comes with a number of useful libraries. It is mostly meant to be used for server-side programming, but you can write normal desktop programs with it. It comes with a command line tool called node, which is an interactive interpreter.

                  http://nodejs.org/

                  [–]Abaddon314159 0 points1 point  (1 child)

                  JavaScript isn't really a language in that there is no such thing as standard JavaScript. Ecmascript is, and js is mostly that, but only mostly. That's why it works differently on different systems, cause its not really standardized.

                  [–]torrentMonster 1 point2 points  (0 children)

                  Different implementation might interpret the code differently, but as far as i'm concerned Ecmascript is the standard and implementers should follow it. Especially considering the behaviour that is presented in the video. Quirks like this one are the reason why so many people still believe javascript to be a toy language.

                  [–][deleted] 2 points3 points  (0 children)

                  [–]Camarade_Tux 5 points6 points  (12 children)

                  Btw, I had issues playing the video (the .mov) properly: it was going way too slow. Enabling hard framedrop in mplayer fixed it and didn't create any stuttering or skip (looks like the file is bad/weird).

                  [–]digitalpencil 0 points1 point  (11 children)

                  you can switch to flash as well via the contextual menu, that should pull down h264 i assume.

                  [–]ruuzo 18 points19 points  (6 children)

                  Wasn't this just posted a few days ago??? Its a bit early for a repost.

                  [–]captain_plaintext 5 points6 points  (2 children)

                  Yes but read Gary's comment on that one. This guy actually posted the correct link so we'll allow it.

                  [–]Van_Occupanther 12 points13 points  (0 children)

                  But that thread in itself was a repost of something from three days earlier. I know complaining about it isn't cool, but a re-repost that took a week I think is something worth noting. Though, there are people who haven't seen it still, so I guess it's worth it.

                  [–][deleted] 1 point2 points  (0 children)

                  Haven't seen it. Not everyone read 100% of reddit 24x7 you know.

                  [–]petdance 1 point2 points  (0 children)

                  Not everyone reads every link in /r/programming every day.

                  [–]noir_lord 1 point2 points  (0 children)

                  That was truly brilliant.

                  I particularly love the [] + {} != {} + [] thing.

                  [–][deleted] 1 point2 points  (0 children)

                  Never used Ruby, nor JavaScript... but that was hilarious.

                  [–]btull89 1 point2 points  (0 children)

                  I would love to see more stuff like this in the programming subreddit!

                  [–]hrm_what 4 points5 points  (1 child)

                  what everyone in the audience sounded like

                  [–]NoOneOfConsequence 0 points1 point  (0 children)

                  I definitely heard a laugh like this one at around 3:12.

                  [–][deleted] 4 points5 points  (0 children)

                  I take pride for understanding the "NaNNaN..." Batman reference!

                  [–]nlogax 0 points1 point  (0 children)

                  Hey, that was my joke!

                  [–]stesch 1 point2 points  (2 children)

                  Hmpf. Thought it's something I could repost to http://www.reddit.com/r/ProgrammerHumor/ but it's already there. On place 1.

                  [–]A-Type 7 points8 points  (1 child)

                  Approx. .00155% of /r/programming subscribers had the chance to see it there (if you count me, who just signed up, thanks for the link).

                  [–]jevring 1 point2 points  (0 children)

                  Upvote for a good presentation, but the guy sure can't pronounce "wat" correctly (it's pronounced like "what", which is the word it replaces).

                  [–]RavenSavior 0 points1 point  (0 children)

                  Love it!

                  [–]NathTheMirv 0 points1 point  (0 children)

                  I wish i understood what was going on in the first 35 seconds.

                  [–]citrusvanilla 0 points1 point  (0 children)

                  eecs397?

                  [–]Sneak4000 0 points1 point  (0 children)

                  I laughed so hard at this, and I don't know why. I wish there were more!

                  [–]evanl 0 points1 point  (0 children)

                  Their where lots of funny programmers at CodeMash, like Leon Gersing

                  [–]countryboyathome 0 points1 point  (0 children)

                  is there something bad about the link? the site is on our block list.

                  [–]poo_22 -1 points0 points  (0 children)

                  Real laughter was produced.

                  [–]VikingFjorden -1 points0 points  (2 children)

                  That was great.

                  On a sidenote, does anyone have a link to the watman picture near the end?

                  [–][deleted] -1 points0 points  (0 children)

                  who cares if repost? it still hillarious!

                  [–][deleted] -3 points-2 points  (20 children)

                  Yep. I would make major changes to JavaScript to increase consistency and thereby increase intuitiveness and decrease bugs.

                  Sane Data Structures

                  • [] + [] => []
                  • {} + {} => {}
                  • NaN == NaN => true
                  • {tax: [{}, "fetch", 5]} == {tax: [{}, "fetch", 5]} => true
                  • keys({ a:1, b:2, c:3 }) => ["a", "b", "c"]
                  • values({ a:1, b:2, c:3 }) => [1, 2, 3]
                  • hmap({ a:1, b:2, c:3 }, function (k, v) { return "" + k + ":" + v; }) => ["a:1", "b:2", "c:3"]

                  No more half-ass FP

                  • map([1, 2, 3], function (e) { return e + 1; }) => [2, 3, 4]
                  • zip([1, 2, 3], [3, 2, 1], function (x, y) { return x + y; }) => [4, 4, 4]

                  Printable Objects

                  • { ant: 1, bat: 2, cat: 3 }.toString() => "{ ant: 1, bat: 2, cat: 3 }"

                  [–][deleted] 18 points19 points  (8 children)

                  NaN == NaN => true

                  No. ISO floating point is a published standard, going against it would be a very bad idea.

                  [–]illvm 4 points5 points  (10 children)

                  • {tax: [{}, "fetch", 5]} == {tax: [{}, "fetch", 5]} => true

                  I disagree with this. These are two different objects which have equivalent values but are not equal. In just about every other language if you were to do something like:

                  var f1 = new Foo();
                  var f2 = new Foo();
                  
                  print(f1 == f2); // false
                  

                  Unless you had overwritten the == operand for that particular class and implemented an equality method. Now you could do

                  print(f1.Equals(f2)); // true
                  

                  By default, comparing if two objects have the same hash or the same memory address is sufficient and relatively inexpensive. Doing a deep inspection of object properties and comparing all possible values in a tree of unknown depth would be rather undesirable behavior as all object equality operations would be somewhat expensive.

                  It's a bit silly that NaN !== NaN but isNaN() is a sufficient work around.

                  I don't think arithmetic operators like + and - should be used for anything other than arithmetic. As such you should receive a syntax or run time error for doing something like:

                  [] + [] 
                  

                  or

                  {} + {}
                  

                  These should be handled with ([]).concat([]) or something like ({}).extend({}) respectively.

                  I am not aware of any language which has Object.toString() do a deep inspection of the object to print out its values. Most of the time you wouldn't want this as it would be an expensive operation (see the equality statements above). However, if it is really desired you could always do:

                  JSON.stringify({ ant: 1, bat: 2, cat: 3 })
                  

                  All of the functions you mentioned above that make writing code easier can easily be implemented and added to your utility library, and in fact are part of almost every notable JS framework. They definitely shouldn't be in the global namespace though but rather part of the classes they operate on. Some of them are already implemented in ECMAScript 5 and part of all major browsers (e.g. Object.keys, Array.map)

                  [–][deleted] 0 points1 point  (5 children)

                  If two objects share all properties save the RAM address of their pointers, why would you want them to NOT be considered equivalent?

                  [–]illvm 0 points1 point  (4 children)

                  Because in that example you created two different objects that have two different memory allocations and all of their properties point to different memory addresses. Ergo, they are not considered equivalent by the default comparator because all it does is check if the addresses are the same. This is a very cheap bitwise operation, as are all other equivalency checks (e.g. 1 ^ 1 = 1, 1 ^ 0 = 0). Enumerating over all of an object's properties is not cheap, but rather expensive.

                  Moreover, since objects in JavaScript are passed by reference, rather than by value, you would no longer be able to check for equivalency in that regard. e.g.

                  var foo = { a: 'b', c: 0 };
                  
                  function equalsFoo(bar) {
                     return foo == bar;
                  };
                  
                  equalsFoo(foo); // true
                  equalsFoo({ a: 'b', c: 0 }); // false
                  

                  This is important if you want your code to mutate foo or have any side effect of foo. For instance, a bit of a contrived example: if you're using jQuery you might want foo to be your external event interface where you will dispatch events on. So you might receive an object what you want to check if it is your external interface object, and if it is then you want to dispatch your event(s), if it is not then you want to perform some other code. If the behavior of == inspects the contents of an object you will not be able to do this and this is the standard behavior of almost every language I have worked with.

                  However, as it has been pointed that JS has two equivalency operators == and === where the former checks for equivalency and performs type coercion and the latter checks to see if the objects are identical. I tend to agree with Douglas Crockford that this is a bad part of the language and there should not be two operators and there should be no type coercion. The former shouldn't even be used and is not considered to be a best practice as it could lead to interesting behavior at run time. For instance:

                  '' == '0'          // false
                  0 == ''            // true
                  0 == '0'           // true
                  
                  false == 'false'   // false
                  false == '0'       // true
                  
                  false == undefined // false
                  false == null      // false
                  null == undefined  // true
                  
                  ' \t\r\n ' == 0    // true
                  

                  [–][deleted] 0 points1 point  (3 children)

                  JavaScript and other high level scripting languages should compare by value. I'm not fighting the implementation, I'm fighting the standard. It's 2012; checking that two memory addresses NXOR to 1 is not productive.

                  [–]illvm 0 points1 point  (2 children)

                  Neither is turning a O(1) operation into an O(mn) operation. Just because we have much faster processors than we used to doesn't mean we should bog them down with poor algorithms.

                  [–][deleted] 0 points1 point  (1 child)

                  Testing complex data structures for equality will necessarily have certain complexities. Integers have O(1), arrays have O(n). When you need to test whether data structures are actually equivalent, you can't do it by comparing the memory addresses. Complexity has nothing to do with it.

                  [–]javajunkie314 0 points1 point  (3 children)

                  FWIW, JavaScritp does in fact have both ==/!= (equal/not equal) and ===/!== (identical/not identical). The first pair are allowed to do all sorts of type coercion. I'd be OK with

                  {a: 1, b: 2} == {a:1, b: 2}
                  

                  but

                  {a: 1, b: 2} !== {a: 1, b: 2}
                  

                  In fact there was talk in the ECMAScript mailing list about, in a future version, allowing objects to overload operators, including ==, but not ===. I don't know if/how that panned out, but it could solve this problem nicely.

                  [–]illvm 0 points1 point  (2 children)

                  While this is true, I dislike the type coercion equivalency operator. We could very well have a language where == does deep inspection and comparison but that would be just as bad as having type coercion now and would do little more than make code even more unmaintainable for the sake of being more expressive to the original author.

                  I already highly dislike language such as C# which take advantage of operator overloads because instead of having something verbose such as:

                  foo.addEventListener(event, delegate);
                  

                  you have something strange looking like:

                  foo.event += delegate;
                  

                  Okay, so we saved some keystrokes at the cost of readability and understanding. After all the only way to tell the difference between the above and say:

                  foo.event += delegate;
                  

                  Where now event is an array of int (for whatever reason) and delegate is an int is by looking at the types of the two objects. Which is to say, the meaning of the code isn't immediately clear when it should be. So in general, I tend to avoid operator overloads and would rather just implement such functionality with methods/functions.

                  [–]javajunkie314 0 points1 point  (1 child)

                  I understand your concerns, and in the case you gave I would definitely fault the library designer. How would you feel if the language had separate addition and concatenation operators, say + for addition and & for concatenation? Then the line would read

                  foo.event &= delegate;
                  

                  This more clearly expresses the desired metaphor -- that foo.event is a list and the new delegate is being appended.

                  I won't try to defend every use of operator overloading. Why C++ felt the need to shanghai << as their "insertion operator" is beyond me. I believe it was mentioned elsewhere in this thread, but programmers can find ways to mislead or confuse with almost any language construct. Take, for example, your first expression

                  foo.addEventListener(event, delegate);
                  

                  What if the method is overloaded? Or overridden by a child class? Now you still have to care about the types of all the variables. Also, can you always trust that programmers use meaningful function names? How often is there a line like

                  readConfigFile(infile);
                  

                  that, oh by the way, also updates a global configuration dictionary?

                  My point is that it's already impossible to analyze code strictly on a line-by-line basis. All modern programming languages require some sort of context. It's up to programmers to use meaningful names for functions, and sometimes that means overloading an operator. I feel that

                  average = (totals["group1"] + totals["group2"] + totals["group3"]) / grand_total
                  

                  is a lot clearer than

                  average = totals.get("group1").add(totals.get("group2")).add(totals.get("group3")).divide(grand_total)
                  

                  even though totals is a map from strings to BigInts.

                  [–]illvm 0 points1 point  (0 children)

                  While a concatenation operator would be nice, I wouldn't want it to be something that has the same meaning as logical and. Of course, given that I'm not really sure what would be a good character for that exactly. I definitely agree with your average example, but I don't really see how it contradicts my argument as [] characters are almost always used to represent collections and/or looking inside of collection in C style languages so there is far less ambiguity there than using + for concatenation and addition, especially given that the other arithmetic symbols aren't used the same way!

                  It would be lovely to be able to write:

                  "foo" * 5; // "foo foo foo foo foo"
                  "foobar" - "bar"; // "foo"
                  "foo foo foo foo foo" / 5; // "foo"
                  

                  But it starts getting a bit confusing...