« first day (1529 days earlier)      last day (3419 days later) » 

9:02 PM
umm, can someone remind me why extending the DOM is a bad idea? :/
(If I don't have to support IE6 and 7...)
 
@AwalGarg extending anything that you didn't create is (usually) bad, because other code won't expect it.
 
@ssube "other code"?
 
@AwalGarg say a library enumerates properties on the DOM element or whatever you've extended, but does so in an unsafe way.
Unless you need your methods to be extremely public, it's often better to keep them in a utility class.
 
@ssube I am trying to understand the why it would be "unsafe"...
 
Utility classes only become a problem when you're in an "enterprise environment" with 25 years of rotten code built up and 12 different com.*.utils.StringUtils
@AwalGarg Extending things you don't own can cause naming collisions, primarily. In JS, a second risk is added because anything can be enumerated very easily, and without proper hasOwnProperty and related checks, you may end up with someone else's method.
 
9:10 PM
My only problem with utility functions is readability, in comparison to other code. myDomEl.hide(), suits the rest of the code. Not so much with utility.hide(myDomEl)...
@ssube One can extend with defineProperty?
 
Yes, but if there is a naming collision (more likely on a common name like hide), you may not notice until your CDN updates and two scripts are delivered in reverse order.
(depending on how the scripts are included in the page)
 
@ssube mmkay. If the names are specific and unlikely to collide with other code?
 
It's good practice not to mutate anything you don't own, because if everyone does it, they will step on your toes.
It may work, but it's still not a good idea. What if a browser update locks the prototype for that object (or makes it native) and your extension now throws? What if those elements become ephemeral/weak references, and your extensions vanish?
You end up binding your code to someone else's, or putting it in public with the risk of conflicts, because you're losing modularity and the safety that infers.
Not to mention that by changing the structure of a common object, you may trigger a deoptimization. If that happens on DOM elements, it could be quite bad.
 
Agreed.
 
Can you avoid most of those issues most of the time? Yes. Do you want to bet on that and wake up every day hoping your code works in prod? Probably not. That's what best practices exist for. ;)
 
9:17 PM
true. I will keep this in mind.
 
Bear in mind that, working with Java EE stuff a lot, I am very biased towards keeping things hidden, perhaps more than is normal for JS.
 
@SterlingArcher where do you subscribe for these images?
or is it the same reddit thing from where you can browse for them?
 
reddit front page
 
Reddit, or imgur if you just want the funny images.
 
9:28 PM
I don't ... want. I sometimes wonder how and why you guys find them and things... and the same with YouTube videos.
 
when life gives you lemons... /cc @rlemon
3
 
9:44 PM
^ lol
Turns out I'm a domain admin here at work.
So I posted a He-Man gif
I think he's removing me now :(
 
With great power comes great potential for posting funnies.
 
Turns out screaming I HAVE THE POWER in chat isn't the smartest thing to do
 
10:11 PM
@SterlingArcher huh, whoddathunk?
 
10:23 PM
you gotta be quiet about the privs you have, until something goes horribly wrong (and it's someone else's fault), then jump in and save the day.
 
11:03 PM
!!write ugly code in 5 minutes and sleep or make module in 15 minutes, use, and sleep?
 
@AwalGarg make module in 15 minutes, use, and sleep
 
@CapricaSix for great justice
 
cap doesn't like me at all, even though she is a bot :(
Imma write ugly code now in 5 minutes, and sleep. Then make a module later.
... fuck it will be too messy.
Imma do both the things later!
good night gentlemen!
 
Ok, this one is interesting
2
Q: Javascript array access with commas

SimpleJWhy does this not throw any syntax errors: var a = [1, 2, 3, 4], b = a[2, 1, 0, 1]; console.log(b); See fiddle: http://jsfiddle.net/2eng5typ/

!!> [1,666,3,4][3, 1, 0, 1]
 
@Jonathan 666
 
11:17 PM
!!> (3, 1, 0, 1)
 
@copy 1
 
!!wat
 
Comma operator
 
!!>[1,1,666][0,2]
 
11:20 PM
@Jonathan 666
 
Ah I see
 
user457812
I really hate node.js.
 
So don't use it
 
user457812
Just felt like sharing that.
 
user457812
Easier said than done when I have to clean up after the people who used it at work.
 
11:21 PM
I don't particularly like it either
 
user457812
Perfectly happy with JS in a browser, but writing system code in JS just devolves into callback hell, and the stuff I'm working on is unmanageable, undocumented, and where there is documentation, I still can't tell what variable has what type(s).
 
user457812
So, people who code for node.js and do a bad job of it need a swift kick to the genitals.
 
Well, callback hell is basically a fixed problem
 
user457812
Fixed aside from every damn node package I've seen using it.
 
You just wrap them in promises
 
user457812
11:24 PM
That's still technically callback hell, it's just one level deferred.
 
No it's not
Because you can pass promises around
Synchronously
Only the last step that requires the value ("unpacks the promise") needs to be asynchronous
 
user457812
You can, but to do anything meaningful with most implementations of promises, you must hand them a callback
 
Does any one have any neat suggestions on how i can improve frame rate for this fiddle for the same amount of particles: jsfiddle.net/cqhrrccs
 
Try updating the particle objects instead of creating new ones
Oh, I read that wrong
 
predraw the particles and use drawImage
 
11:35 PM
Yeah, it spends 60% of the time in fill()
You could also work on imageData
 
Where would you pre draw to ?
 
another canvas
 
I'm not following how simply drawing to another canvas reduces frame rate?
would you not still have to draw all particles + drawImage
 
because then inside of the render loop you just draw that canvas and not re-draw (arc and fill) the image
you draw the particles once and then draw your drawing of them later
 
but if each particle is moving i have re-draw them anyway ?
if i drew them once they would be static
 
11:39 PM
no you are misunderstanding
 
I think he means draw it to a canvas the first time, save that as an image, and use drawImage from then on
Instead of drawing it every time
 
^
every particle has its own tiny canvas
 
so i would be drawing lets say 5000 images rather than fillRects
 
slower at the start, but then renders faster
 
i think i get it now
 
11:41 PM
you are not using fillRect, that is also the issue
filling circles is more expensive than squares
it's a shame
 
see that as a caching process
 
Images are probably only slightly slower than squares
The boundary is pretty quick to calculate
Circles require more math
 
yeah but with a lot of particles, rendered a lot of times, that is a big diff
 
Does this fiddle use GPU or CPU ?
 
iirc images are faster than fillRect
for small stuff
but I could be wrong
 
11:44 PM
how fast is imagedata?
 
Probably the fastest
 
it's a slowish operation, but the bonus is you only need to get/set it once
 
Since when do people here actually talk about helpful stuff, what did I miss?
 
Well, you would do putImageData once per rAF and the rest is just writes to memory
 
@Jonathan well - i think its interesting finding neat ways to improve performance of javascript
 
11:47 PM
It is! But I kind of thought this channel was mainly for programming related trolling -.-
 
So it's late, and you're all on!
East Coast 4 lyfe
 
ok so fillRect gets me 10,000 @60fps jsfiddle.net/7a32qazk
so circles are a big factor there then xD
lets see what i get with little canvases next
 
@Jonathan I just don't like boring questions, that's all
Cannot speak for other people
 
user image
3
 
I'm not here to help
 
11:51 PM
fscking sysadmins
 
☠DEATH TO DEVOPS☠
 
@rlemon designers seen by sysadmins is my fav
 

« first day (1529 days earlier)      last day (3419 days later) »