« first day (920 days earlier)      last day (4040 days later) » 

12:01 AM
@jAndy Yeah, but without hindsight, how does setTimeout know it is time to be executed if it is stuck in a queye?
 
@OliverSchöning it doesn't. If the for some reason the ui thread is busy with heavy operations, setTimeout won't get executed also
 
there is no guarantee in a setTimeout/setInterval timed event
 
I was afraid of that xP
So, it will check when it its time in the queue, and if the time aint right, it goes to the back of the queue?
 
thats the caveat of praemtive multitasking / single threaded environments :)
 
12:03 AM
amen.
Which is why I start to get that processing tiny pieces of code and passing it on is often the way to go in JS
 
well, look at it like this, setTimeout will inject the code into the queue, after the specified delay (if possible). Browser are very accurate on that, but if the process is busy, this will get delayed more and can cause unwanted behavior
like executing multiple delayed code blocks instantly, when a busy process gets available again
or it may even skip code, thats up to the interpreter
 
skip code?!
Well that could be usefull in some cases I guess
I like the fact that I am able to chose to do things in sync or async though
 
if we have like a fast setInterval running, lets say with 200ms intervals, and each of those executing code blocks runs for about 500ms, afaik there is no entirely specified behavior. Some browsers/engine will just queue the jobs forever and others will skip outdated blocks
 
Good evening guys, i have a quick question, im trying to convert string to Int so i can use maths to create an equation for a column but i am struggling to do so, is there any way to do this. i have this function formula(bronze,silver,gold,population,x,y,z) {
return Math.round(x+bronze+silver+gold+y+x); //my equation, rounds to nearest integer
} and also here is where i call it $("<td>"+formula(Country[i].bronze,Country[i].silver,Country[i].gold, Country[i].population ,$('#x').val(),$('#y').val(),$('#z').val())+"</td>").appendTo('#row'+i);
 
Oh yeah.. I forgot about that. Although, setInterval coulndt really "block" the entire browser. Everything would just get more and more delayed as more and more intervals would get put into the queue? am I right?
@user2201189 You have to format that code, or it gets deleted
 
12:11 AM
@user2201189 format your code, also, parseInt("string") , also, +"numString"
 
I think
But that answers my question. cheers @jAndy
 
var run = 0,
    id = null;

function block() {
    var loop = 5350000;

    while( loop-- ) {
      var foo = Math.sqrt(16);
    }

    console.log( 'executing #', run );

    if( run++ >= 10 ) {
        clearInterval( id );
        console.log('finished');
    }
}

id = setInterval( block, 50 );
firefox seems to queue outdated/late tasks forever
 
I make sure that whatever I programm I will always add a massive, GET CHROME sign :p
 
just follow the number #1 golden rule of ECMAscript, don't let a single block of code run for longer than 50ms and you're fine
 
Thanks for the help guys really it WORKED!
 
12:18 AM
16*
@user2201189 sure
 
if there is a need that you have to loop masive data and block for longer than ~100ms, you need to split the tasks into asyncronous run-away-timers
 
I never will (add an advertisement for chrome) :) I'll add a get firefox one, never support the most popular browser, that encourages stagnation :)
 
or use web-workers
the magic number is 100ms
human eyes won't recognize a lag below 100ms delays
above 100ms, it will feel laggy and unresponsive
 
@jAndy 16, not 100 -_-
100ms is 10 frames per seconds, that's way too low
 
@BenjaminGruenbaum nope, its indeed around 100
 
12:20 AM
@jAndy Gotcha :) Although since I am doing NodeJS stuff right now, ill better go for asyncronous straight away! else a 50ms task might not scale to well
 
@jAndy The Game.
 
if course, the lower the better, but up to 100ms, we can't really distinguish
 
@OliverSchöning well, in a non GUI environment thats of course not that important
 
I'd bet you 10$ if it wasn't too much of a hassle you can tell the difference between setTimeout and requestAnimationFrame
Also, using node.js you have a lot less than 16ms
 
12:21 AM
Aint movies still in 24? ^^ well unless you count that shit Peter Jackson is trying
 
anyways, you don't want to block the thread for that long there either
 
16ms of synchronous handling time per core per request is way too much
 
I'm not talking about fps
 
You're talking about miliseconds per reflow, are you not?
 
I'm talking about responsivness in general
 
12:23 AM
The browser has an animation frame every ~16.6 miliseconds
If these lag, even by the slightest bit, you notice the lag.
If you use a setTimeout with 20 miliseconds, or 16 miliseconds, or even 1000/60 miliseconds directly, you'll still notice lag
Especially if the JS itself takes more than 16 miliseconds, which it shouldn't anyway
 
no you don't get it
 
Even if you do your animations or whatever processing has to happen before the reflow with a requestAnimationFrame, if it's more than 16 miliseconds you'll still see lag
 
i'm talking about a study which was made in the '60's I guess, where they had an experiment in which delays the human eye "feels" or recognizes a laggy or skippy environment
give me a second
not talking about animations afterall
 
But he means, how long something takes to load until you get frustrated @BenjaminGruenbaum
 
12:27 AM
study was "Reponse time in man-computer conversational transactions" from Miller, R.B. 1968
the conclusion was, that an interface which responds in within <100ms, feels fluent for an user
 
^I can back that up
Zakas talked about it in High Perf JS
 
like, if you click a button and its GUI updates and renders in within <100ms
anything above 100s, feels laggy
thats why you want to decouple long running (blocking) code, which causes the UI thread to freeze for longer than 100ms
 
Hm.. I wonder if that study should be done in our time though.. Coz I had no problem waiting 2 minutes to load some games/interface/images years ago.. but now.. Ill get pissed at loading time :p
 
its not about loading times, its about the direct response an interface gives you
when interacting (clicking around for instance) with it
 
Oh, you're talking the response to an action, not the frame-rate
 
12:30 AM
yea of course, we were talking about the UI queue
oh nice, its still available
 
It took me more then 10 seconds to read that article, so my attention broke.. Good to keep in mind though.
 
lol
 
@jAndy Hey, I don't think you ever confirmed if it was right that if setTimeout is in front of the queue, but the timer is not reached, that it moves to the back of the queue again
 
That's implementation detail iirc
it's not a part of the language spec iirc
 
alright
 
12:42 AM
I would agree. Its up to the engine what happens in that case
 
Ill go for: lots of tiny async processes then and hope the timers get hit somewhat right
 
however, it should never happen and if we have to worry about such cases, we should re-write the code and/or decouple it more
 
btw, using nodeJS, go with .nextTick() all the way
 
12:43 AM
^this is node
 
instead of setTimeout
 
@jAndy They recently added (v 10.0.0) setImmediate
8
Q: setImmediate vs. nextTick

Benjamin GruenbaumNode.js version 0.10 was released today and introduced setImmediate. The Api changes documentation suggests using it when doing recursive nextTick calls. From what mdn says it seems very similar to process.nextTick When should I use nextTick and when should I use setImmediate?

 
I read an article a while ago about that topic
 
setImmediate queues it in the back, nextTick in the front :)
 
the behave differently afaik
yea something like that
 
yeah that I know ^^ I probably found out via that question. Because my nodeJS went haywire when I did a recursive function with process.nextTick, telling me to use immediate
 
@SomeKittens that's outdated now that we have setImmediate :)
Yeah, node.js warns on nextTick when it detects that the caller to nextTick was executed right before the callee iirc
> Callbacks passed to process.nextTick will usually be called at the end of the current flow of execution, and are thus approximately as fast as calling a function synchronously. Left unchecked, this would starve the event loop, preventing any I/O from occurring.
 
I guess because it is blocking, from the nextTick to forever? ^^
 
so, effectively nextTick would literally block the process forever?
no, not really ?
 
No
nextTick executes as the first thing in the event loop
 
12:48 AM
so in one line
 
You're putting it in the head of the queue, instead of at the end of the event queue like with setImmediate
 
why would I prefer setImmediate over nextTick?
I always thought nextTick was the most precise way to decouple code and keeping it async
 
I think the answer is short enough to be considered stackoverflow.com/questions/15349733/setimmediate-vs-nexttick , however in one line:
 
Yeah, but I called the function recursive with nextTick, so that would be blocking because it would keep pushing itself in front?
 
it can't really block actually
since nextTick also "waits" for one complete queue cycle to finish
 
12:50 AM
Ah, yeah.
 
"nextTick runs in front of your other events, setImmediate lets them run"
 
mhh fair enough
still wondering about.. if there are any real different usecases
 
But in both cases, if the functions are fast enough there wont be a big difference I guess?
 
Yes, want an example?
 
jAndy: yes
 
12:52 AM
lol
 
I'm thinking about.. decoupling a huge array processing for instance, into multiple small run-away timers, probably allow each loop to process for about 50ms or something
then I would prefer nextTick since I want to execute the next cylce asap
but still don't freeze the process
 
before I/O?
 
define that
 
Let's say I have a code that runs on the last event in the event loop that adds a handler to nextTick, that code would get executed as the first thing in the next iteration over the event queue.
 
if there are like 4 calls to nextTick, it would not allow the I/O events to execute ?
 
12:54 AM
So, in fact I got synchronous code, with no chance for I/O events (like incoming requests) running
 
after the last call to nextTick ?
 
It would
 
now you confused me :P
 
If I call a function with nextTick in the last event in the event loop, that function would execute before I/O
 
you just said it wouldn't
 
12:55 AM
Let's say my event loop is like this:

1) Check for special stuff
2) Check new HTTP requests
3) Do intensive 50MS calculations
 
so its like
nextTick() -> code -> (cycle) -> nextTick() -> code -> (cycle) -> nextTick() -> code -> (cycle) -> I/O and other async events
 
Now, inside do intensive 50ms calculations, I have a nextTick handler, also calling do intensive 50ms calculations. I check for stuff, handled new HTTP requests
and now what actually happened is
1) Check for special stuff
2) Check new HTTP requests
3) Do intensive 50MS calculations
4) Do intensive 50MS calculations
5) Check for special stuff
6) Check new HTTP requests
 
whereas
setImmediate() -> code -> (cycle) -> I/O and other async events -> setImmediate() -> code -> (cycle)
 
setImmediate would result in
1) Check for special stuff
2) Check new HTTP requests
3) Do intensive 50MS calculations
4) Check for special stuff
5) Check new HTTP requests
6) Do intensive 50MS calculations
Which is what I wanted
 
ok I think I got it
interesting
 
12:57 AM
:)
 
Now that was a good example.
 
now I'm wondering about usecases for nextTick then :p
when you WANT to not allow other sync tasks to execute
while in a "nextTick interation loop"
even if you don't freeze the node process, its pretty much the same as freezing the process since no other task may execute
 
Wasn't this all about the order of execution?
 
s/sync/async
 
what is the s/ ?
 
1:02 AM
well if we look at @BenjaminGruenbaum first list example, our decouple loop using nextTick will stay 'in front' of the queue until we finished
so there is no time to execute other queued async tasks for that period
 
@OliverSchöning For s/$0/$1, replace the last instance of $0 with $1
 
@OliverSchöning I wrote "sync" instead of "async" above, using a substitute to make that clear
 
The reasons setImmediate was added and nextTick discouraged are two. First, usually when people called nextTick they meant setImmediate, second they wanted to stay more uniform with browser JavaScript which is also getting setImmediate
 
@BenjaminGruenbaum yea
 
is getting? like in ECMA6 ?
 
1:04 AM
In my example above, chances are most developers wouldn't notice the difference in 99% of cases, which makes debugging the 1% remaining a living hell
 
but still, is there any legit usecase using nextTick then ?
and literally block the event queue
its like.. blocking the queue without blocking it
lol
 
It worked pretty well, for 99% of cases it was good
 
maybe I got a idea for a usercase :o
 
First, nextTick is faster, it doesn't actually hook it to the queue
 
and another question could be setImmediate() === setTimeout(fnc,0) ?
in node environment
 
1:05 AM
no, setImmediate is waaaay faster
 
@jAndy It is implemented differently, but in terms of what is getting done, yes
 
after reading all that, I'd state that nextTick is pretty useless then
(at least, for usecases we used above, decoupling large processing)
 
Yes, for breaking big calculations to smaller ones, setImmediate should be preferred
Generally, "process" should not be touched that much
 
Yeah, what I was thinking of didnt make much sense either.
 
You can listen to maxTickDepth btw, which might be interesting
setTimeout(x,0) is the same as setTimeout(x,5) since the timer queue is different (at least in chrome/v8) and 5 mili-seconds is the minimal delay iirc, setImmediate isn't susceptible to that.
It's also pretty new
 
1:11 AM
@BenjaminGruenbaum Out of curiosity, what's TipRanks like?
 
@SomeKittens In what sense?
 
development (JS) side of things. Mostly libraries? Lots of cool code, or mostly slog? (etc, etc)
 
Whew. Enough learned. Time to implement. thanks
 
@OliverSchöning Above all, have fun!
 
@SomeKittens Most of our development isn't in JavaScript, a lot of the code is NLP (natural language processing) code in other formats. Then we have tons of C# code, mainly complicated algorithms the professor from Cornell on our board came up with.
JavaScript is used mainly (but far from only) on the browser extension, website, and intranet
 
1:14 AM
Ah. So why are you looking to hire a JS guy?
 
I coded the intranet administration console, it's a big system that handles alerts, every time we're processing an article we're not 100% sure about we generate an alert the nice QA people handle in the console.
It works well, it's a very straightforward asp.net mvc3 application, not complicated enough JS to need anything fancy, bit of jQuery because of a plugin, mostly straight up JS
The website is a bit of mix&match, the design changes frequently because of A/B testing.
The extension has a lot of JavaScript, built up using some MVC pattern, talking to restful APIs, handling more advanced coding logic.
 
So you're looking for someone to spruce up a internal app?
 
No, I already coded that :)
We're looking for someone to work on several things
a browser extension, a more advanced website, and probably a mobile phone app in JavaScript
 
is rowspan depreicated?
 
@qwertymk What does the spec say?
 
1:18 AM
@BenjaminGruenbaum How would I find that out?
I don't know what to search for
 
@qwertymk How would you start solving any problem?
 
@qwertymk HTML specification rowspan
@qwertymk Which would get you asking, "Is rowspan valid in HTML X" where X is the version of HTML you're talking about
For example, without checking, I'm sure rowspan is legal in HTML 4.01 , but that's usually not interesting or too useful
 
so html5 rowspan?
 
@qwertymk I tried "HTML5 specification rowspan"
Remember, w3.org good, w3schools evil
 
tml5?
oh
 
1:21 AM
H
 
download died at 98.2% sigh
 
@qwertymk As you can see, it's in the specification:
> The td and th elements may also have a rowspan content attribute specified, whose value must be a valid non-negative integer. For this attribute, the value zero means that the cell is to span all the remaining rows in the row group.
So the answer is no, it is not deprecated , that doesn't say anything about whether or not you should use it though :)
Especially not for design
 
Ok I see what you mean, btw "HTML5 specification rowspan" doesn't bring up w3 specs on the first page for me
 
Wait no, that's the 4.01 one
@qwertymk This is the correct one w3.org/html/wg/drafts/html/master/…
Usually, when people use rowspan/colspan, it's because they're trying to design a webpage with tables, which is usually very bad
 
well I'm using it for tabular data
 
1:25 AM
In that case, the answer is no, it is not deprecated. It is valid in HTML4.01, and up to the current draft of HTML5 it is valid syntax
 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="http://www.epic.com/inc/jquery-1.8.0.min.js"><\/script>')</script>
Can anyone tell me what's that for? Checking if Google's down?
 
Yes
If the download failed for the first one, window.jQuery would be undefined
Which would cause the short circuit statement to look at the right part, which writes a request to jQuery from another location
It's an ugly hack for people who still use <script> tags to manage dependencies :)
 
No wonder my "Shouldn't there be a better way?" alarm was going off.
 
There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies. [C.A.R. Hoare]
 
@BenjaminGruenbaum if you go to trentrichardson.com/examples/timepicker and click the first sample how would I get .ui-timepicker-div to be to the right of .ui-datepicker-calendar ? should I add a th and give it a large rowspan?
 
1:41 AM
just finished the new tank plumbing and all is running smooth..... I can't believe it!
I fully expect to wake up to a flood
 
Don't know, don't have experience with that specific jQuery plugin, it depends on the way it is coded. @qwertymk
@rlemon If you have a desktop, and don't have water cooling, that'd surprise me. Since you have all the equipment and all
 
@BenjaminGruenbaum doesn't matter how it's coded, I first mess with it in chrome inspactor then see how it fits in the code
 
nope
lol
no water cooling
just lots of fish tanks
I do have a few extra feet of 3/4" pvc
 
@qwertymk I'm sorry, while I have no problem helping users who come here with theoretical questions about HTML (although this is not the HTML room), or in general, I don't like answering questions that sound like "How do I get jQuery plugin X to display right" since that requires me to read code jQuery plugin that is usually poorly written and never interesting
 
decided on a flex line for the return (MUCH easier)
 
1:45 AM
@rlemon I had a goldfish once :P
 
lol
 
Actually, we had a big aquarium when I was in the army, built it ourselves
 
@BenjaminGruenbaum you said that using colspan isn't the way to go, I thought maybe you there would be a simple alternative
 
Used hydraulic equipment we ripped from old/unused guns
 
that was all I meant
 
1:46 AM
@qwertymk For what specific layout problem?
 
tl;dr my first attempt at building a sump w/ refugium and it was a nightmare. however just turned it all on and it works perfectly. (asides from pvc free floating which I will fix in a day or two)
 
(A specific layout problem isn't 'how do I get jQuery plugin X to do Y')
 
I can take pics if need be. but it isn't pretty
 
for that one, I'm trying to tweak the plugin to do something like that but no amount of css I try has the desired effect @BenjaminGruenbaum
 
@rlemon Resisting... That's what your mom said... joke...
 
1:49 AM
ahh got it
finaly
 
lol
 
Dynamic typing brings 70% more happiness units
 
 
2 hours later…
3:32 AM
@beenhero 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.
 
Vin
3:43 AM
Can anyone help me figure this one out? I've got a php file on my server that returns a json. How can I get data from that json into a javascript variable?
 
If you're using jQuery, look into $.ajax (most lowlevel), $.get or $.getJson (most specific)
 
Vin
@JanDvorak Many thanks
 
If you're not using jQuery or any other framework/library: make a new XmlHttpRequest, set its onload (or onreadystatechange, if you need IE support) handler, set the URL and send the request. The handler should then read the request's responseText (I think it's named this) and use JSON.parse to parse the response.
 
Vin
4:03 AM
@JanDvorak So it's simpler with jquery?
 
@Vin yes, quite a bit :-)
 
so, does anyone here have an opinion on how granular coding style guidelines should be for javascript? I'm having this issue at work where (at least to me) it feels like every week we are coming up with some new rule. I recently got everyone to agree upon JSHint settings, which has made it a little better, but I still see rules creep up. Some of these rules are like: "oh yea you should add a space before every function as well as after it", or
"lets make multi function _.bindAll() calls have the function names on separate lines"
or... i dont know whatever. I personally just find it annoying and just want to code and shit. Am i being immature about this? Is this a common place of contention? Or are these rules actually in the way?
 
@Parris I think worrying about putting spaces next to function name is going to slow down your project forever
you should just get all the things done first and worry about refactoring your code
 
^ I like that level of control.
 
Let them play. Just explain that: 1) it's hard to remember (and apply) all the rules and 2) if you're going to go over the code you have already written to conform to the new rules, it's going to take some time
 
4:12 AM
The object-oriented model makes it easy to build up programs by accretion. What this often means, in practice, is that it provides a structured way to write spaghetti code. [Paul Graham]
 
Thanks all :)
 
4:32 AM
@all hello
 
> thou shalt refer to )}; as "sad mustache guy".
 
4:56 AM
@all Hello!I am new to Javascript/PHP. I have a php form with many elements[inputs, select etc] but i want to load this form whenever a selection is made and execute some php code. This is possible and so easy when the PHP script only accepts on variable however with a script that takes two variables I am not able to use javascript
 

« first day (920 days earlier)      last day (4040 days later) »