« first day (970 days earlier)      last day (3984 days later) » 

user1596138
9:00 PM
Home time!
 
look at that it is.
sweet.
 
user1125394
o right, I'm a blond
 
anyone a way to set a function that detects scrolling without overflow in jquery?
 
@redline I am not benchmarking it
 
@TrevorRudolph without overflow?
 
9:01 PM
yes
 
I am just looking what it looks like in assembly to fetch deeper closure vs closer closure variable
 
user1125394
infinite scolling is fun, no it sucks actually
 
@TrevorRudolph what do you mean?
 
@Esailija ah ok
 
the mouse scrolling without overflow being present in the window
 
9:02 PM
I think I am recognizing the pattern, I'll compile even deeper variable to make sure
 
@Esailija sweet, that was fast :P
 
hold on
 
lack of audio might be a codec issue for me
well no, it works in FF...
 
ok yea
so the deeper I go
the more I get this
067342F9   185  8b75f0         mov esi,[ebp+0xf0]
067342FC   188  8b460b         mov eax,[esi+0xb]
067342FF   191  8b480b         mov ecx,[eax+0xb]
06734302   194  8b5117         mov edx,[ecx+0x17]
06734305   197  8b490b         mov ecx,[ecx+0xb]
06734308   200  8b4917         mov ecx,[ecx+0x17]
basically doing context.context.context.context
 
We need to go deeper
 
9:09 PM
ONE MORE DREAM DEEPER!
 
@Esailija I think you've gone too deep...
 
that's what she said
 
@redline wow. that's deep.
 
haha
 
so you can see it's shitload of indirect memory access = bad
when you do linear memory access you benefit from processor cache
 
9:10 PM
so for example
which is the whole reason i brought this up
 
!!s/that's deep/that's deep man.../
 
but when you go all over you need to wait ram
 
@Shmiddty @redline wow. that's deep man.... (source)
 
what javascript engine did you get that assembly from?
 
@Esailija OTOH you benefit from temporal coherence here
 
9:11 PM
what's temporal coherence
 
@TrevorRudolph Yeah, I was wondering how on earth you compile Javascript into assembly...
 
with V8
 
you keep accessing the same variables over and over again
 
Node.js, or is there a native Javascript compiler out there?
@redline Oh duh
 
I am accessing the variable once
 
9:11 PM
this is just one JavaScript compiler though
it doesn't tell use what it would do in FF for example
 
var d = function finalFn() {
        var local = Math.random();
        if (insanely_deep > so_deep_it_hurts) {
            return Math.random();
        }
        return notsodeep > deep ? local : deep;
    };
 
spatial coherence = variables you access together live close together
 
no these are not variables
they are closure variables or whatever
 
lovely
 
9:12 PM
@Esailija so for example
 
thank you @Connor
 
@Esailija if you had a bunch of global variables, maybe it's better not to separate them out (not the literal global)
@Esailija global closures for like a 3rd level IIFE
 
let's try this:
var d = function finalFn() {
        var a = 0;
        var l = 1000;
        while (l--) {
            a += so_deep_it_hurts;
        }
    };
return a
 
np
 
@Esailija OR you could have put all those variables in ONE object and had a much faster access cause you don't have to iterate up the closure chain for EACH variable, only for the "global" closure object
 
9:14 PM
isnt it annoying that when you try to make a google chrome plugin they make you pay 5 bucks, but then that 5 bucks needs to be with google wallet so you need to sign up for google wallet, its all a big hastle to make them get you to use more of their services
 
I'm pretty sure IIFE works differently
 
ok then nvm bad example
 
0
Q: Is there an alternative to jsfiddle that allows us to upload multiple JS files?

Dan Rossjsfiddle allows you to choose from a predefined list of libraries, but I want to upload and use a fairly obscure library that isn't on the list (bootstrap-select). Is there a site that allows this, or do I have to copy-paste the entire thing into the JS and CSS panels and remove some <script> and <...

 
here:
var closureVar1 = 'a';
var closureVar2 = 'b';

var funcVar = function()
{
    return closureVar1 + ' ' + closureVar2;
};
var closure = { Var1: 'a', Var2: 'b' };

var funcVar = function()
{
    return closure.Var1 + ' ' + closure.Var2;
};
now imagine funcVar is, to use your words, so deep it hurts
which is better
 
yes
 
9:18 PM
for a low level library
accessing ONE closure, then property accesses
or accessing a couple closures, no property access
 
I am still figuring out what happened with the loop
well that's easy, no closures, always property access
 
well what if it isn't so deep it hurts
it was just as it is here, 1 level only
so maybe not having to do that assembly over and over and over, makes, for example, level 1 and 2 perform better than using property accesses, but going for level 3+ is worse, who knows, see what i am saying? there are two variables here, the time it takes for each level increase, and the time it takes for a property access
 
@BOb Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
but that's hardly likely given that you have already loaded the object from memory and its properties are stored right next to it so they are in cache
but you can always benchmark it :P
 
omg @rlemon, really cool !
 
9:22 PM
well, you need to consider the closureVar content itself
you could have a few properties chained
maybe the settings aren't flat in a single object
i dunno
i'm just throwing out random shit
to get different outputs from you :P
 
Hey folks
 
if the object is not in hash map mode the properties are stored linearly in it tightly like a C struct, that's the point of it
 
and if it is in hash map mode?
 
well in hash map the keys are spread out randomly by design
 
@Esailija in what format are javascript variables stored? byte type + union?
 
9:26 PM
In computing, a hash table (also hash map) is a data structure used to implement an associative array, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the correct value can be found. Ideally, the hash function should assign each possible key to a unique bucket, but this ideal situation is rarely achievable in practice (unless the hash keys are fixed; i.e. new entries are never added to the table after it is created). Instead, most hash table designs assume that hash collisions—different keys ...
 
or *object + is_primitive?
 
@JanDvorak array of jstypes
 
so like consider a deep function
and having Object.freeze, Object.something or whatever all over the place
think about all those global accesses technically
that's the farthest up the chain you can go
or is global treated special?
i would assume not since it has to iterate the chain first to make sure it doesn't find something else with the same name at a lower level
 
global is special it's not a closure
 
but how can they do that?
 
9:29 PM
global is slow to access though
 
what if i had var Object right outside my scope
Object.blah is no longer global
 
@redline bad idea
 
and it HAS to know that there is no var Object to GIVE me the global
 
right outside? 1-level closure?
 
@JanDvorak well duh, this is for the example
@Esailija yes
 
9:31 PM
what is your point
like how would that be different from having any other named variable in closure
 
because it masked a global
and you said global is special, not a closure
but i'm saying, i could mask a global, and it will give me the mask first
so it HAS to iterate the scope chain to know there is no mask
right?
 
you are thinking like interpreter
 
ok so how should i be thinking about this?
where am i going wrong?
 
like a compiler
 
think about the generated code
 
9:33 PM
It's possible to analyze the scope chain statically
 
you have fully analyzed the situation
what do you generate?
 
i would generate a map
what var name is what scope level ect
but does it actually do that?
 
@Esailija why not hold the parent scopes in an array instead of a linked list?
 
@redline it assumes Object will always be the same
so there is just quick check
that the assumption still holds
 
so in theory
you could have a super deep function, and a global access is faster than something in the scope chain
 
9:36 PM
@Esailija I guess with throws that analysis completely off?
 
"global" isn't literally treated as the end of the line
 
@JanDvorak the optimizing compiler ignores functions with with at very early phase yes
 
that's what i'm getting here then...right?
which is why WITH is horrible
 
this is in firefox too, where it was used as a trick to get a function working
 
yep
 
9:37 PM
because the optimizer had a bug
so they just added with statement and the function worked again
 
was that a stable version of firefox?
I'd say "let's ignore nightlies"
 
I can try to find the bug report
and for the record, so far try/catch and direct eval have same effect as with too
 
try/catch :(
 
try/catch?
Or just try/catch with eval?
 
Try/catch is just a with
That's how it's implemented
 
9:40 PM
,= (x_x)
 
@JanDvorak i know, right
 
Also, don't avoid with because it's slow... Avoid it because it's evil
 
there is one bad ass trick with with
 
i do avoid it because it is evil...i remember reading an article somewhere about how it is just horrible and to never ever ever EVER use it
 
It's perfectly possible to optimize it, just not worth the time
 
9:42 PM
for( var i = 0; i < 10; ++i ) {
    with({i:i}) {
        div[i].onclick = function( ){
            alert(i);
        };
    }
}
 
Shouldn't every library try the handlers?
 
@Esailija IIFE FTW
 
Yay for block scope :p
 
Nay for zero performance
 
@redline but this is far less verobse
:P
it's just badass, that's all
 
9:42 PM
>_<
 
not for real use
 
yea i know i get it
it is cool
 
@Esailija coffeescript
 
i WISH i could do it
i really do
alright i gotta get back to work
@Esailija always fun talking this shit with you dude
 
Performance is not an issue in 99% of times. Most of the time the bottleneck is not a 'try' clause. Don't let any particular user of this room confuse you :p (I wonder who :p)
 
9:44 PM
ok bye
^^
 
I love the dirty compiler talk though.
 
for i in [0..10] do (i) ->
  # i is now local to the IIFE
 
Be back later :)
 
Firebug console evals code within a with. Screws with function hoisting for some reason.
 
@JonTravis Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
9:47 PM
function declarations must be top level
afaik
like doing if( true ) { function asd() { } } is like completely random what happens
 
@Esailija But what if it's within eval()?
 
doesn't eval have its own scope for these purposes at least
 
@Esailija should be hoisted
 
so eval( "asd(); function asd() {}" ) is legit
 
@Esailija should work
 
9:49 PM
should work
 
I reckon it could be a bug in SpiderMonkey. I never tried testing it in other browsers.
 
!!>asd(); function asd(){console.log('asd')}
 
@Shmiddty "SyntaxError: function statement requires a name"
 
oops
 
@Shmiddty "undefined" Logged: "asd"
 
9:50 PM
function foo(){} is hoisted. var foo = function(){} is not.
!!>asd(); var asd = function(){console.log('asd')}
 
@Shmiddty "TypeError: asd is not a function"
 
I don't like hoisting
 
me neither
 
@Shmiddty no it should not
 
@Esailija I didn't mean should on principal...
 
9:52 PM
function declaration is not a statement, it cannot be inside blocks
but yeah, what actually happens is different between implementations
> Several widely used implementations of ECMAScript are known to support the use of FunctionDeclaration as a Statement. However there are significant and irreconcilable variations among the implementations in the semantics applied to such FunctionDeclarations.
 
!!>asd(); if(true){function asd(){console.log('asd')}}
 
@Shmiddty "ReferenceError: asd is not defined"
 
> ecause of these irreconcilable differences, the use of a FunctionDeclaration as a Statement results in code that is not reliably portable among implementations. It is recommended that ECMAScript implementations either disallow this usage of FunctionDeclaration or issue a warning when such a usage is encountered. Future editions of ECMAScript may define alternative portable means for declaring functions in a Statement context.
 
hoisted in chrome
not in ff
 
warning: never use setInterval when you mean setTimeout
had to close the tab
 
9:53 PM
@JanDvorak just never use setInterval
 
@Shmiddty why not? it prevents clock drift (unless you manage to skip a call)
 
it's not about hoisting, it is a flat out syntax error
per spec, but yeah what happens in practice is what happens
 
@Esailija ah
@JanDvorak use Date.now() for delta time
 
performance.now
 
'use strict';asd(); if(true){function asd(){console.log('asd')}} chrome doesn't care.
 
9:57 PM
chrome has bug with regex syntax too
function test() {
    /(/
}
that causes a syntax error correctly in firefox, but not in chrome
it is only until you call test()
 
@Esailija negative. It throws an exception for me
 
Version 27.0.1453.110 m
 
same
tested in the console
SyntaxError: Invalid regular expression: /(/: Unterminated group
 
function test() {
    /(/
}
undefined
 
function test() {
    /(/
}test()
SyntaxError: Invalid regular expression: /(/: Unterminated group
@Esailija is correct
 
10:01 PM
(function test() {
    /(/
})()
throws
 
right
 
@JanDvorak you are calling the function
 
but if you just have the function declaration, it doesn't throw
 
Just used Chrome to download IE10. Feel dirty.
 
the point is not to call it
 
10:01 PM
@Esailija should it throw before even calling?
 
syntax errors should always be caused by static analysis already
yes by spec
and by common sense
I shouldn't have to run my code to see that there is a syntax error
like say if your code has 1% chance to call the function test()
 
Chrome seems to do that at regex construction time (which it defers until its first use)
 
then you will not see the bug so easily
because you have to hit all the conditions to see the errors
basically the down side of dynamic languages in general for many errors
 
just declare your regexes in the global scope
then you know they'll be evaluated
 
ah I don't have a practical problem with it
just saying why it is stupid in principle
 
10:04 PM
aye
 
10:17 PM
the sky is gray and ashes fall from the heavens
also, it smells like a campfire
 
@Shmiddty what's that from?
 
@JanDvorak the forest fire in colorado?
 
Man.. So it works fine on every comp I have access to with the exception on the XP SP1 box which has so little memory it crashed.
 
@Shmiddty I hoped you didn't describe your real-life weather
 
yep, it's real-life
 
10:20 PM
ow
 
@Shmiddty, yea man.. So for the life of me I cannot reproduce your issue with no (audio|video)
 
@rlemon doesn't make sense to me since it's working just fine in FF
so it couldn't be a codec issue
 
Everywhere I read says it has to be a codec, or missing from the source. Which we can see it is not.
Bugged chrome? Do other video tag medias work for you?
 
haven't tried
 
If you can debug the Web, you can probably debug anything.
 
10:31 PM
Except the web
 
Yeah, especially not that!
 
audio is not working on any video tag in chrome
 
@Shmiddty, sounds about right
 
ok so I can stop scratching my head over this. phew
 
this is also regardless of video format
maybe it has something to do with having hangouts installed
yup
google hangouts plugin
blocking audio
for some reason
 
10:36 PM
sweet.
 
weird
I can't recreate it
can you use the audio api to get the levels from a video?
 
@MikeW Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
user1864610
@CapricaSix Thanks - have read the rules. Just dropped in this time to get the feel of the place. Will be back sometime :)
 
user1125394
art ^
 
10:50 PM
I just wrote some really ugly code. Someone cheer me up
 
@BenjaminGruenbaum I hear hell is where all the hot people are.
 
Already CV'd
 
yay!
 
10:58 PM
@KendallFrey Except for Vista users, fuck them.
 
@BenjaminGruenbaum, your ugly is probably a lot better than most
 
adios
 
user1125394
gotta call my Java class Script
 
@SomeKittens That's just work humor, don't mind them. Find something else to mock them about :P
 

« first day (970 days earlier)      last day (3984 days later) »