Biggest Hello World Ever



  • A Hello World for Dart.

    Could anyone tell me whether all those binding functions (in the form bindX_Y, like bind1_4 or bind2_2) are there for optimization, or simply for filler?



  • What am I looking at? The bottom textbox is the JS compilation of the top? Or... something else?

    Remember back when web pages gave some indication of what exactly they were? Instead of just a couple textboxes with vague labels? Those were the days. Oh wait, Gi Thub, this is made my open source people, no wonder it sucks...



  • Oh wow, it's like putting "cat /usr/include/* >> helloworld.c" in your Makefile.

    Also, the comments on that item are pure gold.



  • @db2 said:

    Oh wow, it's like putting "cat /usr/include/* >> helloworld.c" in your Makefile.

    I'd say it's more like statically linking the whole of libc into your helloworld application, regardless of what's actually used or not.  That appears to be the entire Dart language runtime in there.



  • ♿ (Parody)

    @blakeyrat said:

    What am I looking at? The bottom textbox is the JS compilation of the top? Or... something else?

    Remember back when web pages gave some indication of what exactly they were? Instead of just a couple textboxes with vague labels? Those were the days. Oh wait, Gi Thub, this is made my open source people, no wonder it sucks...

    You obviously didn't read the title (Dart Compilation). Or the text on the page (Simple test program invoked with an option to eagerly compile all code that is loaded in the isolate).

    You demonstrate a good point, though. It's easier to just get angry about something random than to pay attention.



  • @boomzilla said:

    You obviously didn't read the title (Dart Compilation). Or the text on the page (Simple test program invoked with an option to eagerly compile all code that is loaded in the isolate).

    Yes, because the two words "Dart Compilation" obviously describes exactly what's happening on that page. It would have been utterly impossible for them to write a sentence like, "Compiling Dart's Hello World program into JavaScript produces over 17k of output" that human beings would be able to read and understand. Or for Renan to do that, for that matter.

    Grump.



  • @blakeyrat said:

    @boomzilla said:
    You obviously didn't read the title (Dart Compilation). Or the text on the page (Simple test program invoked with an option to eagerly compile all code that is loaded in the isolate).

    Yes, because the two words "Dart Compilation" obviously describes exactly what's happening on that page. It would have been utterly impossible for them to write a sentence like, "Compiling Dart's Hello World program into JavaScript produces over 17k of output" that human beings would be able to read and understand.

    I think you maybe meant to say "blakeyrat would be able to read and understand". If you take a minute and casually skim through the comments, you'll notice that just about every commenter on there understood what was going on, and they read the same page that you did. But, I digress, a blakeyrant wouldn't be a blakeyrant without gross misinterpretations, and gross negligence on the part of you.



  • @dohpaz42 said:

    If you take a minute and casually skim through the comments, you'll notice that just about every commenter on there understood what was going on, and they read the same page that you did.

    Shocker: people who visit Github every single day know what content is on Github pages. Stop the presses! In other news, water wet!

    Seriously, did you think that argument through before posting it? Because it's really, really retarded. Maybe consider upping the "think before posting" time by a couple minutes for next time.

    @dohpaz42 said:

    But, I digress, a blakeyrant wouldn't be a blakeyrant without gross misinterpretations, and gross negligence on the part of you.

    Note:

    1) I did suspect it is exactly what it is, but I still asked for clarification because I wasn't sure
    2) I'm hardly the only one to complain about WTFs that are nothing but a link with absolutely zero explanation
    3) Asking for things to be clearer and more accessible is always a good thing especially with programmers who are, and let's be generous, complete shit at communicating



  • @blakeyrat said:

    @dohpaz42 said:
    If you take a minute and casually skim through the comments, you'll notice that just about every commenter on there understood what was going on, and they read the same page that you did.

    Shocker: people who visit Github every single day know what content is on Github pages. Stop the presses! In other news, water wet!

    There you go assuming again. The only time I ever visit Github is if I have to browse my company's source code. What this means, in no uncertain terms (as clear as clear can be): I've never before visited a page on Github that wasn't the login page, or a source code repository; i.e., I've never even heard of Gist before, so viewing the OP's link was brand-spanking new to me, and I understood it very well (hint: it's called common sense; google it).

    @blakeyrat said:

    Seriously, did you think that argument through before posting it? Because it's really, really retarded. Maybe consider upping the "think before posting" time by a couple minutes for next time.

    Obviously more than you did. You should eat your own dog food sometime.

    @blakeyrat said:

    Note:
    ...

    3) Asking for things to be clearer and more accessible is always a good thing especially with programmers who are, and let's be generous, complete shit at communicating

    Well, I can't argue this point very much, since you are so keen at proving it time and time again. :)


  • ♿ (Parody)

    @blakeyrat said:

    Shocker: people who visit Github every single day know what content is on Github pages. Stop the presses! In other news, water wet!

    Well, I've only been there a handful of times. Mostly from links from this site, in fact, but it wasn't difficult to figure it out. I suppose it helped that I'd looked into Dart a little bit due to Nagesh's thread about it.

    @blakeyrat said:

    2) I'm hardly the only one to complain about WTFs that are nothing but a link with absolutely zero explanation

    Yes, I don't see a WTF at the page. Maybe the OP thought the resulting JS code was TRWTF. And maybe it is, although the part that says "VMOptions=--compile_all" seems like a hint that whoever posted that stuff at Github made it do that on purpose, presumably for educational purposes, which is pretty much the purpose of Hello World programs, generally.

    As to the OP's question, I imagine it would be more obvious if we saw a compiled program that had more features to see how those things are used. As DaveK said, it looks like the runtime library for the language when compiled (translated is probably a better word, actually) into js. To answer it, you'd probably want to look at how closures differ between the two languages.

    @blakeyrat said:
    3) Asking for things to be clearer and more accessible is always a good thing especially with programmers who are, and let's be generous, complete shit at communicating
    Honestly, I don't see much of a difference between programmers and non-programmers. Most people totally suck at it.


  • From the Dart library:

     

    function native_BoolImplementation_EQ(other) {
    if (typeof other == 'boolean') {
    return this == other;
    } else if (other instanceof Boolean) {
    // Must convert other to a primitive for value equality to work
    return this == Boolean(other);
    } else {
    return false;
    }
    }

    Wow.  Is it just me, or does that look like something right out of a TDWTF front-page article?




  • @dohpaz42 said:

    If you take a minute and casually skim through the comments, you'll notice that just about every commenter on there understood what was going on
    You mean like:

    rvagg commented

    </p><p class="info">
      <i class="date"><a href="https://gist.github.com/1277224#gistcomment-55523"><time class="js-relative-date" datetime="2011-10-10T21:05:57-07:00" title="2011-10-10 21:05:57">October 10, 2011</time></a>
        <span class="icon"></span>
    </i>
    

    holy moly...

    timmolendijk commented

    <time class="js-relative-date" datetime="2011-10-10T21:08:53-07:00" title="2011-10-10 21:08:53">October 10, 2011</time>

    Whoah

    danielalexiuc commented

    </p><p class="info">
      <i class="date"><a href="https://gist.github.com/1277224#gistcomment-55534"><time class="js-relative-date" datetime="2011-10-10T21:23:20-07:00" title="2011-10-10 21:23:20">October 10, 2011</time></a>
        <span class="icon"></span>
    </i>
    

    When I first opened the page I thought it was only 23 lines long, and still thought 'Yikes'.

    Then I saw the next 17,237 lines...

    showell commented

    </p><p class="info">
      <i class="date"><a href="https://gist.github.com/1277224#gistcomment-55586"><time class="js-relative-date" datetime="2011-10-10T23:24:38-07:00" title="2011-10-10 23:24:38">October 10, 2011</time></a>
        <span class="icon"></span>
    </i>
    

    Just think of what Dart could do in 34,528 lines of code.

    pyrotechnick commented

    <time class="js-relative-date" datetime="2011-10-10T23:26:46-07:00" title="2011-10-10 23:26:46">October 10, 2011</time>

    It could say hello to the world, twice.

    Rotten194 commented

    </p><p class="info">
      <i class="date"><a href="https://gist.github.com/1277224#gistcomment-55666"><time class="js-relative-date" datetime="2011-10-11T03:23:42-07:00" title="2011-10-11 03:23:42">October 11, 2011</time></a>
        <span class="icon"></span>
    </i>
    

      <div class="content-body wikistyle markdown-format"><p>Dart is 
    

    pretty new, so I'm not surprised that it's a little rough around the
    edge - especially in the compiled JS, which you shouldn't need to look
    at anyways. But 17KLOC? For fucks sake.

    A significant number of comments are along the lines of "WTF?"


     

     

     



  • @DaveK said:

    From the Dart library:

     

    function native_BoolImplementation_EQ(other) {
    if (typeof other == 'boolean') {
    return this == other;
    } else if (other instanceof Boolean) {
    // Must convert other to a primitive for value equality to work
    return this == Boolean(other);
    } else {
    return false;
    }
    }

    Wow.  Is it just me, or does that look like something right out of a TDWTF front-page article?


    Most definitely. What catches my eye about that function is the 'else if' portion that tests 'other' to be an instance of Boolean, and if so it converts it to an instance of Boolean. Then again, that might have been what you were eluding to, if you weren't referring to the function as a whole.



  • @dohpaz42 said:

    @DaveK said:
    From the Dart library:

     

    function native_BoolImplementation_EQ(other) {
      if (typeof other == 'boolean') {
        return this == other;
      } else if (other instanceof Boolean) {
        // Must convert other to a primitive for value equality to work
        return this == Boolean(other);
      } else {
        return false;
      }
    }

    Wow.  Is it just me, or does that look like something right out of a TDWTF front-page article?


    Most definitely. What catches my eye about that function is the 'else if' portion that tests 'other' to be an instance of Boolean, and if so it converts it to an instance of Boolean. Then again, that might have been what you were alluding to, if you weren't referring to the function as a whole.
    FTFY



  • ♿ (Parody)

    @DaveK said:

    Wow.  Is it just me, or does that look like something right out of a TDWTF front-page article?

    Well, it kinda looks like it, but I suspect that it really isn't, though I don't know enough about javascript (or the type system in Dart, for that matter) to say. But I suppose it has something to do with the way js converts 'true' or 'false' into a boolean. What would js type coercion do in the case of, say comparing values like: true == 'true'



  • @Sutherlands said:

    @dohpaz42 said:

    Most definitely. What catches my eye about that function is the 'else if' portion that tests 'other' to be an instance of Boolean, and if so it converts it to an instance of Boolean. Then again, that might have been what you were alluding to, if you weren't referring to the function as a whole.
    FTFY

    Eh, you obviously got the point. I'm more disappointed that you didn't FTFM using Dart. ;)



  • @boomzilla said:

    @DaveK said:
    Wow.  Is it just me, or does that look like something right out of a TDWTF front-page article?

    Well, it kinda looks like it, but I suspect that it really isn't, though I don't know enough about javascript (or the type system in Dart, for that matter) to say. But I suppose it has something to do with the way js converts 'true' or 'false' into a boolean. What would js type coercion do in the case of, say comparing values like: true == 'true'

    According to the W3 Schools, it basically treats any non-empty/negative/null value as true. And it is a WTF, in the very least because the 'else if' should be using 'object.valueOf()' and not instantiating a new Boolean type. Edit: Because a Boolean object (any object, really), evaluates to true because it is non-empty/negative/null. Take for example the following (which would mimic passing a Boolean object into the function with a false value):

    [code]console.info(true == new Boolean(new Boolean(false)));[/code]

    This evaluates to true using Firebug's console. However, the following code reflects the better way to handle it:

    [code]console.info(true == new Boolean(false).valueOf());[/code]



  • @boomzilla said:

    What would js type coercion do in the case of, say comparing values like: true == 'true'
     

    Hit F12, click the console line, and paste " true == 'true' "



  • @dhromed said:

    @boomzilla said:

    What would js type coercion do in the case of, say comparing values like: true == 'true'
     

    Hit F12, click the console line, and paste " true == 'true' "

    I stand corrected on my first assumption. I thought that JS would have done an implicit conversion. Interesting. I guess this young padiwan has a lot to learn, of the force, he does.


  • ♿ (Parody)

    @dhromed said:

    @boomzilla said:
    What would js type coercion do in the case of, say comparing values like: true == 'true'

    Hit F12, click the console line, and paste " true == 'true' "

    Oh, cool. See, like I said, I don't do javascript. But I was right. The code itself isn't a WTF.



  • The premise that ontogeny recapitulates phylogeny has been discredited in evolutionary biology, but here we have strong proof suggesting that there may be some truth in it in the realm of compiler design.

    Here we have a translating compiler, being developed in 2011, that roughly matches the compiler programs of 1971 in terms of technique and elegance.

    Perhaps by the time the Dart compiler is ready for public usage it will have evolved features like dynamic linking and target-platform optimization.

     

     



  • @dohpaz42 said:

    @dhromed said:

    @boomzilla said:

    What would js type coercion do in the case of, say comparing values like: true == 'true'
     

    Hit F12, click the console line, and paste " true == 'true' "

    I stand corrected on my first assumption. I thought that JS would have done an implicit conversion. Interesting. I guess this young padiwan has a lot to learn, of the force, he does.

    And at least a little of how to spell "padawan"!



  • @DaveK said:

    And at least a little of how to spell "padawan"!

    Okay, I give. It's Monday, and I can't spell very well. In my defense, my spell checker didn't have an entry for either.


  • BINNED

    @dhromed said:

    Hit F12, click the console line, and paste " true == 'true' "

     


    Didn't expect that. I'd have expected that if a comparison boolean <-> string is allowed at all, one of the two would compare to true. Shouldn't take such assumptions when you mainly do statically typed languages.

     



  • @dohpaz42 said:

    @DaveK said:
    And at least a little of how to spell "padawan"!

    Okay, I give. It's Monday, and I can't spell very well. In my defense, my spell checker didn't have an entry for either.

    Whaaaat?!!!?!  Call yourself an engineer and you haven't even added Star Wars terminology to your local per-user dictionary?

     

    Next you'll be telling me it doesn't do Klingon either.




  • @dohpaz42 said:

    Okay, I give.

    What exactly? Clothes? Footwear? Chinese fortune cookies?

     



  • @DaveK said:

    Whaaaat?!!!?!  Call yourself an engineer and you haven't even added Star Wars terminology to your local per-user dictionary?

     

    Next you'll be telling me it doesn't do Klingon either.


    I rarely ever add anything to my local per-user dictionary, so no it doesn't do Klingon either. I don't wear glasses; I don't have a pocket-protector; I don't go to comic-cons (or any cons for that matter); I don't have a binary clock (but I can at least read a binary clock); I don't have a lightsaber (not in spell check, btw, but Google confirms it is spelled correctly); I don't drink energy drinks (well, I do drink coffee); and I have only memorized the powers of 2 up to the 16th exponent (65,536 - I know this because this is the size of a TEXT column in MySQL). As an aside, I can only recall PI up to the hundred-thousandth place for PI reliably; on a good day, I can get up to the hundred-millionth (I usually forget the millionth decimal).



  • @serguey123 said:

    @dohpaz42 said:

    Okay, I give.

    What exactly? Clothes? Footwear? Chinese fortune cookies?

     

    I give you a hard time for getting the below Konami code wrong:

    @serguey123 said:

    Filed under: up up down left A+B

    It's up-up-down-down-left-right-left-right-B-A. You're welcome. :)



  • @dohpaz42 said:

    I give you a hard time for getting the below Konami code wrong: @serguey123 said:
    Filed under: up up down left A+B
    It's up-up-down-down-left-right-left-right-B-A. You're welcome. :)

    I was not aiming for that.  I'm not a nerd, nor a consumated gamer, more of a hobbyist, mentioning "up" and making it look like some kind of combo or special move from a game was my whole aim, not the konami code


  • BINNED

    @dohpaz42 said:

    It's up-up-down-down-left-right-left-right-B-A-[Select]-Start. You're welcome. :)
    FTFY

     



  • @topspin said:

    @dohpaz42 said:

    It's up-up-down-down-left-right-left-right-B-A-[Select]-Start. You're welcome. :)
    FTFY

     

    Since the code is entered on the title screen, and you have to press start to play the game anyway, the Start is a gimmie, which is why I didn't include it. The Select is for the two-player, and obviously, just like the Start, is a gimmie as well, since you have to press it to go into two-player mode.


  • ♿ (Parody)

    @topspin said:

    @dohpaz42 said:
    It's up-up-down-down-left-right-left-right-B-A-[Select]-Start doesn't matter. You're welcome. :)

    FTFY

    FTFBOY



  • @blakeyrat said:

    Shocker: people who visit Github every single day know what content is on Github pages.
    I have never been to a github page before, and I managed to figure out pretty much immediately what it was all about. If you weren't, you're either a bit dense (but I don't really believe that) or you're playing dumb on purpose in order to have yet another cause for some (self-)righteous indignation, which you seem to crave so much.



  • @Renan said:

    Could anyone tell me whether all those binding functions (in the form bindX_Y, like bind1_4 or bind2_2) are there for optimization, or simply for filler?

    Optimisation for common cases - although I don't think invoking function.call() can be remotely classified as optimising.


Log in to reply