We live in a strange world



  • https://github.com/iojs/io.js/pull/1457

    The fact that this is not only possible but actually even slightly ... I can't believe I am going to say this ... reasonable is a little bit wild.


  • SockDev

    Implementing something in JS for a JS framework? Say it isn't so! :stuck_out_tongue:



  • Implementing something in JS rather than C for speed


  • SockDev

    Which to me says the C code was total garbage, not that JS is genuinely faster ;)



  • @RaceProUK said:

    Which to me says the C code was total garbage,

    So is the js:

    This parser uses regular expressions for most of the parsing.



  • C code must've been utter garbage then. Though doing these things in C ­— especially nonblocking — is not easy.



  • I think they're all just crazy js people, so it makes sense that they'd want to js all the things. For instance...

    #Is it io.js or IO.js or iojs or IOjs or iOjS?
    The official name is io.js, which should never be capitalized, especially not at the start of a sentence, unless it is being displayed in a location that is customarily all-caps (such as the title of man pages).

    :rolleyes:


  • BINNED

    Oy vey

    .js


  • SockDev

    Compare that to Node, who just say 'here's this thing we did', and get on with making the next version :smile:



  • Goddamn I fucking hate Javascript.



  • The fact that the C code wasn't as optimal as it could have been doesn't surprise me - it's that the JIT has gotten good enough that you need to be more-than-decent at C to get better performance than what V8 can get once it sees how you're using JavaScript. What's next, several typed / JIT versions of PHP?


  • Discourse touched me in a no-no place

    @boomzilla said:

    So is the js:

    This parser uses regular expressions for most of the parsing.

    You missed off a bit:

    [ack that RE is wrong] However I wanted something that would be easy to get right


  • Discourse touched me in a no-no place

    Premature optimization:

    #Various Performance Improvement Techniques

    [...]

    • Use val !== val instead of isNaN(val). NaN is the only value in JavaScript that does not equal itself or anything else.
      jsperf

    Just how frequently does this code check for NaN that (on this box) a difference of 15,777,846 vs 570,482,405 operations per second is going to make a noticeable difference?

    Well the only instance of this I can find in the diff is this:

    ``` if (val !== val || val > MAX_CHUNK_SIZE) return this._setError('Bad Content-Length'); ```

    Well if they want premature optimization with obfuscation, why didn't they simply go for:

    if (!(val <= MAX_CHUNK_SIZE))
       return this._setError('Bad Content-Length');
    

    And that code seems to get run only when it's going through the header. I doubt a profiler has been anywhere near this code.



  • @PJH said:

    You missed off a bit:

    [ack that RE is wrong] However I wanted something that would be easy to get right

    And that bit should get the prefix, So is the author.



  • @PJH said:

    > - Use val !== val instead of isNaN(val). NaN is the only value in JavaScript that does not equal itself or anything else.

    That is another amazing JS feature. Like this:

    typeof(null)
    "object"
    null instanceof Object
    false

    or JSON.stringify(Infinity). To think that is the standard that implementers have to uphold. Brrrrr.



  • @Hanzo said:

    That is another amazing JS feature

    BZZT! NaN != NaN is guaranteed by IEEE 754 -- it's the same way in C++, Python, JS, and basically every other language on a modern system. (isnan wasn't a thing in C until oh, C99...)



  • @Hanzo said:

    typeof(null)
    "object"
    null instanceof Object
    false

    makes perfect sense if you understand that setting a variable to null simply creates a special object reference that doesn't point to anything, almost completely analogous to a 0 pointer in C.

    The typeof operator sees that the variable holds an object reference, as opposed to a primitive value type like number or string or boolean or undefined; the instanceof operator tries to follow the prototype chain on the referenced object to see if it leads back to the global Object object, but can't do that because the object reference doesn't actually refer to anything at all.


  • BINNED

    @flabdablet said:

    makes perfect sense if you understand that setting a variable to null simply creates a special object referencethe weird implementation details

    <FTFY



  • To be fair, null is a special value for pointer types in a lot of languages, not just js.



  • @tarunik said:

    BZZT! NaN != NaN is *guaranteed by IEEE 754

    I didn't know.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.