Statistics in javascript



  • Need to get various statistics based on post number? Easy? You bet!




    I hope they at least have some program to automatically generate that...



  • But what if you need more than 99990 posts?



  • I could almost see this making sense if (a) you've heard of caching; (b) you've heard of dynamically generated JS; (c) you've never heard of hashes (maps, dictionaries, etc.).



  • @mikeTheLiar said:

    But what if you need more than 99990 posts?

    Then you got a problem, but at least a bitch ain't one.



  • @mikeTheLiar said:

    But what if you need more than 99990 posts?
    99990 posts is more than anyone will ever need.



  • I thought it meant posts as in to a forum until I loaded the js file:

    alert ("The postal code is not found in the default rate per cent. enter a new ZIP code.")

    So not forum posts, postal code posts. Still pretty perverse!



  • It says in the first lines of the script "var myTextField = document.getElementById('postcode');" Then there is a whole bunch of names, starting with Helsinki. You read the code with the wrong expectation and never got the idea that they were place names, just foreign mumblejumble. I too can think of slightly more efficient ways of doing it, but WTF here only means Well, They're Finnish.

     


  • Considered Harmful

    I'd not actually seen return 1, 2, 3; syntax before in Javascript. It looks like it would be a tuple, but in practice it just returns 3.



  • @joe.edwards said:

    I'd not actually seen return 1, 2, 3; syntax before in Javascript. It looks like it would be a tuple, but in practice it just returns 3.

    Wow.... that's some bullshit.



  • TBH they could have been unrolling their loops in JS which used to yield performance improvements in older browsers.



  • @joe.edwards said:

    I'd not actually seen return 1, 2, 3; syntax before in Javascript. It looks like it would be a tuple, but in practice it just returns 3.

    I don't get returning a tuple. Just return a damn array!



  • @morbiuswilters said:

    Just return a damn array!
     

    Adding square brackets is too difficult?



  • @morbiuswilters said:

    @joe.edwards said:
    I'd not actually seen return 1, 2, 3; syntax before in Javascript. It looks like it would be a tuple, but in practice it just returns 3.

    I don't get returning a tuple. Just return a damn array!

    That's pretty much what a tuple is in a lot of dynamically typed languages anyways. Tuples are just the JS/Python nerds compensating for the fact that their language doesn't have real multiple return values.



  • @MiffTheFox said:

    That's pretty much what a tuple is in a lot of dynamically typed languages anyways. Tuples are just the JS/Python nerds compensating for the fact that their language doesn't have real multiple return values.

    What's so hard about just using an array in the first place? Why even have multiple return types? (And don't anybody mention Go's dumb-dumb error codes..)



  • @morbiuswilters said:

    @MiffTheFox said:
    That's pretty much what a tuple is in a lot of dynamically typed languages anyways. Tuples are just the JS/Python nerds compensating for the fact that their language doesn't have real multiple return values.

    What's so hard about just using an array in the first place? Why even have multiple return types? (And don't anybody mention Go's dumb-dumb error codes..)

    Go's error codes are bullshit, but the problem with an array is that you can change the return values and not immediately break all the other code, and then you have to deal with a "your array's too short" error vs a "not enough output items" error. Consider the three ways to have a function that gets in C#:

    // Using an array
    int[] range = GetMinMax();
    int min = range[0], max = range[1];
    
    // Using a tuple
    Tuple<int, int> range = GetMinMax();
    int min = range.Item1, max = range.Item2;
    
    // Using out parameters
    int min, max;
    GetMinMax(out min, out max);
    

    I like how out parameters are so specific: you can say in the function definition "the two values this function returns are called min and max". Compare to the second that says "this function returns two values" or the first that says "this function can return any number of ints, between 0 and Int64.MaxValue".



  • @MiffTheFox said:

    That's pretty much what a tuple is in a lot of dynamically typed languages anyways. Tuples are just the JS/Python nerds compensating for the fact that their language doesn't have real multiple return values.

    That is not JS/Python speciality, it's how most languages do it. Most languages that have multiple return values implement them as tuples. The only exception seems to be perl with it's list context. @morbiuswilters said:

    What's so hard about just using an array in the first place? Why even have multiple return types? (And don't anybody mention Go's dumb-dumb error codes..)

    Tuples contain fixed number of elements of independent types, while arrays contain variable number of elements of the same type. Of course in dynamic languages there is not much difference, but deconstruction is usually only supported for tuples and they are usually optimized for this.



  • @joe.edwards said:

    I'd not actually seen return 1, 2, 3; syntax before in Javascript. It looks like it would be a tuple, but in practice it just returns 3.

    That's the comma operator. It's useful when you want to do something hacky and dumb like for(;;)alert('a'),alert('b') where you don't want to use any braces. Basically, it executes both arguments and then returns the second one.



  • @MiffTheFox said:

    @morbiuswilters said:
    @MiffTheFox said:
    That's pretty much what a tuple is in a lot of dynamically typed languages anyways. Tuples are just the JS/Python nerds compensating for the fact that their language doesn't have real multiple return values.

    What's so hard about just using an array in the first place? Why even have multiple return types? (And don't anybody mention Go's dumb-dumb error codes..)

    Go's error codes are bullshit, but the problem with an array is that you can change the return values and not immediately break all the other code, and then you have to deal with a "your array's too short" error vs a "not enough output items" error. Consider the three ways to have a function that gets in C#:

    // Using an array
    int[ range = GetMinMax();
    int min = range[0], max = range[1];
    
    // Using a tuple
    Tuple range = GetMinMax();
    int min = range.Item1, max = range.Item2;
    
    // Using out parameters
    int min, max;
    GetMinMax(out min, out max);
    

    I like how out parameters are so specific: you can say in the function definition "the two values this function returns are called min and max". Compare to the second that says "this function returns two values" or the first that says "this function can return any number of ints, between 0 and Int64.MaxValue".

    // Using Go's actual real multiple-return-values-from-a-function feature
    min, max := GetMinMax()
    


  • @Ben L. said:

    // Using Go's actual real multiple-return-values-from-a-function feature
    min, max := GetMinMax()

    Did not take long to bring Go in a javascript thread, I'm impressed.



  • @Ronald said:

    @Ben L. said:
    // Using Go's actual real multiple-return-values-from-a-function feature
    min, max := GetMinMax()

    Did not take long to bring Go in a javascript thread, I'm impressed.

    Ben brings Go up in all the wrong situations, like a closeted gay teen who keeps asking his girlfriend for anal before he's even tried out the front door.



  • @morbiuswilters said:

    @Ronald said:
    @Ben L. said:
    // Using Go's actual real multiple-return-values-from-a-function feature
    min, max := GetMinMax()

    Did not take long to bring Go in a javascript thread, I'm impressed.

    Ben brings Go up in all the wrong situations, like a closeted gay teen who keeps asking his girlfriend for anal before he's even tried out the front door.

    There are doors?



  • @Ben L. said:

    @morbiuswilters said:
    @Ronald said:
    @Ben L. said:
    // Using Go's actual real multiple-return-values-from-a-function feature
    min, max := GetMinMax()

    Did not take long to bring Go in a javascript thread, I'm impressed.

    Ben brings Go up in all the wrong situations, like a closeted gay teen who keeps asking his girlfriend for anal before he's even tried out the front door.

    There are doors?

    More like windows, although this is a case where maximized is bad.



  • @morbiuswilters said:

    @Ronald said:
    @Ben L. said:

    // Using Go's actual real multiple-return-values-from-a-function feature
    min, max := GetMinMax()
    

    Did not take long to bring Go in a javascript thread, I'm impressed.

    Ben brings Go up in all the wrong situations, like a closeted gay teen who keeps asking his girlfriend for anal before he's even tried out the front door.

    Ben has a girlfriend?

     



  • @drurowin said:

    Ben has a girlfriend?

    Yes, her name is Kitty. He sees here twice a week at the cat shelter.



  • @Ronald said:

    @drurowin said:
    Ben has a girlfriend?

    Yes, her name is Kitty. He sees here twice a week at the cat shelter.

    You really don't like cats, do you?



  • @Ben L. said:

    @Ronald said:
    @drurowin said:
    Ben has a girlfriend?

    Yes, her name is Kitty. He sees here twice a week at the cat shelter.

    You really don't like cats, do you?

    The problem is that I now have this image in mind of Al Yankovic getting to fifth base with Garfield.



  • @Ben L. said:

    @Ronald said:
    @drurowin said:
    Ben has a girlfriend?

    Yes, her name is Kitty. He sees here twice a week at the cat shelter.

    You really don't like cats, do you?

    I think it's more probable he just likes making fun of you.



  • @morbiuswilters said:

    @Ben L. said:
    @Ronald said:
    @drurowin said:
    Ben has a girlfriend?

    Yes, her name is Kitty. He sees here twice a week at the cat shelter.

    You really don't like cats, do you?

    I think it's more probable he just likes making fun of you.

    So,

    how's the weather?



  • @Ben L. said:

    So,

    how's the weather?

    Mid-60s, same as always for this time of the evening.


Log in to reply