« first day (967 days earlier)      last day (3987 days later) » 

3:00 PM
@BenjaminGruenbaum - I'm all in for the design patterns you outlined in your answer.
@BenjaminGruenbaum - However @redline's jTypes library takes classical inheritance in JS to a whole new level.
That's not necessary.
That's overkill.
 
@AliTrixx These statistics are suprising for me too. Try looking for a mod (is @ThiefMaster here?)
 
That's what I'm against.
 
It's not overkill, it's an outright mistake.
 
@AliTrixx Well, you really have two options: Continue giving good answers, or if you truly think it's undeserved, try contacting a moderator
 
If JS was like LISP then I wouldn't mind.
The point is that JS was not designed to be extensible like LISP was.
Hence trying to implement something like classical inheritance in JS is not feasible.
 
3:01 PM
@AaditMShah All I'm asking for is clarification - that while implementing classical inheritnace is often an incorrect approach, as a design pattern it's still solid. That a lot of times people implement classical inheritance because they don't understand how the language works,
 
Okay thanks. but I'm not really sure how to contact a moderator in here?
 
@BenjaminGruenbaum - That I can agree with.
 
@AliTrixx looking at your profile, I see two -4/C questions
 
@BenjaminGruenbaum - See, I don't hate classical inheritance. I think it's an amazing pattern.
 
3:02 PM
I'm sooooooooooooooooooooooooooooo bored right now
I'm gonna think of cool ideas for the bot
 
The only problem I have is trying to implement classical inheritance in JS which is not meant to be classical.
 
@AliTrixx why would you want to contact one?
 
!!help nudge
 
@Gacnt nudge: Register a nudge after an interval. /nudge intervalInMinutes message, or the listener, nudge|remind|poke me? in? intervalInMinutes message
 
I love classical inheritance in Python. IMO Python has the best classical inheritance system there is.
Umm, maybe after CLOS.
 
3:03 PM
@FlorianMargaine I got a question ban and I think it's sort-of undeserved.
@JanDvorak Yes indeed. two closed questions with a -4 reputation.
 
@AliTrixx then bring it on meta.stackoverflow.com
 
it's the right place for this kind of stuff
 
The point is that there a place for everything. JavaScript is not the place for classical inheritance.
 
I have a mention. What is going on here. I really need to learn how to use this chat.
 
3:04 PM
Okay thanks for the help everyone.
 
@AliTrixx I can see three closures (2x-4, 1x0) + 1 duplicate. This could count heavily against you (the closures, not the duplicate)
 
I'm sick of typing the at symbol all the time...
 
hey all - does anyone think they can help me identify a theme? :D
 
@AaditMShah sup
 
@redline you can click on the arrow at the right of the message to "reply" to this message
 
3:05 PM
Yes you can benefit from using classical inheritance patterns. However that's like salt. You only need a little bit of it in your food. Don't go over the top with classical inheritance in JavaScript like jTypes does.
 
@FlorianMargaine thanks
 
@redline - Hey.
 
@redline yep, like this.
 
@JanDvorak I guess then I'll wait a few days, answer a few questions in the hopes of getting unbanned. If I don't, then I'll try to contact a moderator.
 
@FlorianMargaine is there any shorthand where I don't have to use my mouse...cause when I type the at symbol I still need to click on the name...
 
3:06 PM
this brings a little arrow on the left of your message which directs to the concerned message
 
@AliTrixx Your 1 question, is 3 lines long, and unclear, your second question, is more of a, I can't google and I don't understand the docs provided, somebody explain them to me, or give me a way to understand it without learning the actual code behind it
 
@redline oh, that
@redline you start typing the name and hit tab
 
@FlorianMargaine boom
@FlorianMargaine perfect, thanks so much
@FlorianMargaine now i don't have to move my hands from my keyboard :P
 
you shouldn't ping people on every line though
it gets annoying
 
PING PING PING
 
3:07 PM
can you enlighten me on the protocols here then?
 
@Gacnt Well yes. I understand my faults in asking those questions. I kind-of got a hold of which questions SHOULD be asked after I got banned.
 
and who is a bot and who isn't? I hate not knowing >_<
 
@Esailija - BTW I never said that classical inheritance has a bad performance. Classical inheritance allows the compiler to optimize your code far more than prototypal inheritance does. However trying to implement classical inheritance on top of prototypal inheritance like jTypes does is slow.
 
start pinging so that the guy knows you're talking to him, then don't reping on every message
and only @CapricaSix is a bot.
 
@Esailija - Also, don't you use Object.create?
 
3:08 PM
@AaditMShah yes it is slow, but there is more to it than that
 
hell no, just for establishing inheritance chain
 
user1596138
@redline Just @CapricaSix
 
A botsnack should probably be implemented
 
@AliTrixx Had you read the guide for asking questions, you would have known right away!
 
There's also Ninja Echo
 
3:08 PM
Ninja echo is just a wannabe
 
I see no reason for Object.create(asd).init() vs new Asd()
 
@NinjaEcho Right?
 
@Gacnt Indeed. Completely my fault. I just think that a ban is kind-of too harsh.. but I'll try my best to answer some questions in the hopes of getting unbanned in the future.
 
nah, Kendall had some good ideas.
 
@redline - If you're going to talk about how classical inheritance solves the problem that prototypal code is not maintainable then I suggest you hold your horses. That's not true.
 
3:09 PM
@AaditMShah I only use Object.create() for prototypes, otherwise I agree with @Esailija
 
@Zirak I know, it's pretty neat, I just like comparing bots, fetish of mine
 
@AaditMShah you already missed a big discussion when you left
not going into that again
 
@Esailija Because it's a different way to structure your data. I already yelled it at you.
 
it's not
 
@AliTrixx You can edit your questions, and they can be re-upvoted
 
3:09 PM
it is
 
there is absolutely no advantage
 
@Esailija you really want Zirak to yell at you?!
again?!
 
@redline - It's a pity you can send me a transcript. Can you?
 
Let errrrrrrrrrrrr rip!
 
except some weird puristic ideologies that are wrong
 
3:10 PM
So the whole magic of constructors just doesn't matter?
 
@AaditMShah transcript?
no idea
 
there is far less magic than Object.create.. that's why it's even inlineable
 
@redline Chat history link
 
are there private chats on here?
 
it's inlineable because it's so simple
 
3:11 PM
@Esailija - Define inlineable.
 
@redline define "private"
 
@AaditMShah
Did not inline create called from test3 (target not inlineable).
 
@Esailija - Native Object.create is pretty fast.
 
@JanDvorak haha
 
no it's not, I get 500 calls per ms
 
3:12 PM
@redline click a users name, 'Start a new room with this user'
 
@Gacnt I will do my best. Thanks for all the help.
 
no prob
 
btw, make sure you run optimized code
 
Say whaat?
(1)Setting a prototype link
is more complex than
(1)Setting a prototype link from the (horribly named) `func.prototype`
(2)Calling the constructor function
(3)Deciding what to return
 
@Gacnt that doesn't work
 
3:12 PM
there is no point in comparing code that is not optimized by the compiler
 
Wrapping it in objects makes more sense to me than wrapping it via a constructor function.
It's a different way of doing it, but it does achieve the same end result
Sort of
 
@Esailija so you're telling me from the compiler's perspective Object.create is significantly slower than directly setting the prototype?
 
@redline don't quote me, but you might need more rep
 
@Gacnt probably the case, i wouldn't be surprised as i'm new around here
 
3:16 PM
yea i'm at 91
 
@redline what does directly setting the prototype have to do with object.create?
 
@AliTrixx a lot of stuff like that gets downvoted pretty quick, it's usually linked to a chat tagged [cv-pls] (close vote please)
 
@Esailija maybe i misunderstood what you are talking about with Object.create, i thought you said it preforms really slow
 
well yes because it cannot be inlined, which enabled other optimizations
another trick is that
 
@redline Object.create is more than setting a prototype though
 
3:18 PM
String.fromCharCode(x) is inlined
but String.fromCharCode(x, y) is not
 
@FlorianMargaine can you elaborate?
 
so calling it twice separately for x and y is far faster
 
@redline see the second argument of Object.create
 
@FlorianMargaine ahhhhhhhhhh
 
!!youtube Feels So Good - Logistics
 
3:19 PM
so is it faster to set all the property descriptors yourself using Object.defineProperty, or is Object.create still faster?
 
And what about Object.defineProperties?
 
@Darkyen ^
 
dunno, never had a bottleneck there so I didn't really profile
 
@Esailija does it not inline because of the property descriptors?
 
3:21 PM
@Zirak What you workin on, I need ideas
 
if you don't have simple properties then your object accesses are hash map accesses
e.g. Object freeze was fixed in v8 just a few weeks ago
 
@Gacnt Ideas for what?
 
before that frozen objects were 20x slower to access because they were forced to hash map mode
 
I don't know man, @Zirak I'm A.D.D'in like crazy over here
 
and by simple you mean wouldn't constitute a variable name right? [_a-z]+[_a-z0-9]* ...right?
 
3:22 PM
simple property is legit identifier name, dot access, without any attributes about it
like .name = "hi"
 
sorry, I meant would constitute (note my regex)
so those are actually stored internally in a separate access that doesn't use hash mapping?
 
there are a lot of heuristics for it but generally any magic will cause hash map mode
and too many properties e.g over 14
 
!!/mute Gacnt 1m "You are annoying me"
 
just basically think what you can do in Java
you can do .name in Java
but not ["nam" + d]
 
@Esailija and are you talking about V8 though when it is compiled or regular JS? (sorry, I entered this convo late)
 
3:24 PM
3 messages moved to Trash can
 
@Gacnt Bot doesn't listen to itself
 
Oh damn
Would have been a nice command
 
I am talking v8 but all modern engines do this afaik
 
5 messages moved to Trash can
 
@Esailija yes but that doesn't clarify, do you mean JS -> language or JS is included in that statement?
 
3:26 PM
@Zirak What do you think about a !!/me command for the bot, so it has an option to listen to its self?
 
as in just using Object.create and Object.defineProperty in native JS
in a browser...
 
in JS as a language, the objects semantics are basically hash maps
 
all the time?
 
@Gacnt Why?
 
@redline no, not in practical implementations if you write code in a certain way
 
3:27 PM
even .name and not just [name]?
 
!!/youtube Honky Cat - Elton John
 
Dunno, could short hand certain commands
 
@rlemon o/
 
not here, just leaving a song and bailing
\o
 
3:27 PM
Now I'm sad
 
runs
 
@Esailija i'm just trying to figure out if I should not use object[property] as often and opt for object.property as often as possible...i guess that's what i'm getting at...is JS itself using a hash map all the time or does it separated the two different types of properties as well?
 
if you have stable types with simple properties then you will get optimizations
 
and if a property descriptor is thrown into the mix?
 
3:29 PM
if you have magic and unstable types (i.e adding and removing properties or changing types of properties etc)
 
is that the end of it?
 
@AaditMShah Don't do that in Java either :P That's why Java programs look like crap. You overuse that pattern.
 
I'm gonna go drown myself in the mud puddle outside brb
 
it depends, it's best to compile v8 and run diagnostics on the code
 
@redline property descriptors are pretty very slow at the moment.
 
3:30 PM
@BenjaminGruenbaum yea tell me about it >_<
 
They cause immediate fallback to hash map mode in V8, and almost certain fallback in SpiderMoney, last time I checked at least.
 
that's why i want to know about this more so i can optimize better
 
@redline Not as slow as taking 2 miliseconds for creating a single object though :P 700K property accesses per second
 
Hello EveryOne
 
but i'm not talking about V8, i'm talking about JS in a browser, not V8
 
3:31 PM
for instance look at this
function Cat(age, name) {
    this.age = name;
    this.name = name;
}
var l = 100000;
var a = new Array(l);
for (var i = 0, len = a.length; i < len; ++i) {
    a[i] = new Cat(Math.random() * 3140 | 0, "missy");
}
 
@Esailija V8 loves you right now
@redline V8 is the JS engine Google Chrome uses.
 
@BenjaminGruenbaum yes, it's what node uses
 
@redline And Chrome, yeah. Those are browsers, that run JS, like you asked for :P
@Esailija I thought missy was missing :(
 
now
 
but i'm trying to find out if regular old JS has these problems as well, isn't Object.defineProperty using the same semantics as defining a regular property with object.prop where it just sets configurable and enumerable and writable for you?
 
3:33 PM
The cat is lost in negative space.
 
ohhhhhhhhhh
wow that was a big brain fart
I was under the impression V8 was just for compiling JS outside of browsers and that chrome didn't use it
 
V8 was developed for chrome. Node just used it because it's awesome
 
i have no idea why
but that's what i thought
 
@redline Also, if your C++ is good the V8 source is nothing short of awesome , it's a nice read.
 
Chrome uses blink as its html/css rendering engine and v8 as its js interpreter
 
3:34 PM
yes V8 is awesome, i just thought webkit took care of it or something like that
 
webkit took v8 out back and gave it a beating
"Gimme your lunch money, dork!"
 
@redline Webkit has their own JS engine called JavaScriptCore, Chrome doesn't use it
 
chrome doesn't use webkit
 
@FlorianMargaine Yeah it does, inb4 blink it's still a webkit fork
 
@BenjaminGruenbaum exactly, that's why i thought chrome didn't use V8 for some reason
 
3:35 PM
@redline all the optimizations are based on the fact that you are writing code like you would write in Java or C, then they can get away with less dynamic semantics and thus can optimize
there are some heuristics though like .apply( this, arguments )
in some case that is optimized
even though it's magic
 
@BenjaminGruenbaum yeah with 8 millions lines stripped out :P
and they're experimenting with a DOM garbage collector
blink is going to be real nice.
 
@Esailija i will have to give the V8 source a look-over then
 
@Esailija I think that's a misleading statement "write code like you would write in Java or C" . Also, I think optimizing for optimizers is pretty stupid in 99.9% of cases. I think you fall under that 0.01 though from what you're talking about.
 
well I don't think I worded that well.. I mean you need stable types and avoid dynamic shit like with and eval etc
 
This sums up nicely why I dislike the concept of optimizing for v8
@Esailija Didn't we just see an example the other day where eval provided for an awesome optimization?
 
3:38 PM
I am talking about direct eval
 
I know, I'm just being a jerk now :P
 
that is very different from global eval or new Function
:P
 
I love v8's optimizations, and JIT in general I find the whole field very fascinating.
I'm just saying you shouldn't think about it in 99.9% of cases.
 
i as well, i would definitely like to look into all of that
 
Even in node, that's still 99.5%
 
3:39 PM
@BenjaminGruenbaum but it's not like ASM.JS, 70-80% of the time you do have stable types and have essentially statically typed code
 
it's nice to know about it, but you're coding for humans, not for compilers. Write semantic code for humans.
 
you don't need 100% dynamic everywhere
 
I think that as long as you're reasonable V8 optimizes well.
If you use stuff like the delete operator you're writing code that doesn't make sense to begin with and deserve no optimizations
 
exactly
 
I never use the delete operator but it just seems counter-intuitive in JS to define a property as undefined but still have the property defined in a for-in loop, ect.
 
3:41 PM
you don't need for-in loop for objects that are actually objects and not hash maps
 
i would have thought that null would be used to make the property exist and undefined to remove it when you set the property
(in terms if i had to guess before i learned JS)
 
@redline An undefined property is still a property. It still answers truthfully to in or hasOwnProperty. However, an object doesn't just "stop" having a property.
That never happens, it wouldn't make sense for it to happen.
 
well it does if you delete it ;)
 
That's why I hate mutable proto, and I hate that it's getting into the language.
A dog doesn't just "stop" being an animal, that would make no sense
 
well based on the word "undefined", i find it to be a little bit of an oxymoron, since the property is defined, for inline variables though it makes sense
 
3:44 PM
The only use for mutable proto is mocking, and even then it's stupid and indicates code that was not testable to begin with.
 
@redline The value is undefined, the key is not
 
^ Ninjad. It has a value, but that value is not well defined,
 
I can see uses for a mutable proto, but i don't agree with it as well
 
delete makes the key undefined.
 
yes, in hindsight i know that now, but when i was learning it was counter-intuitive to my thinking
 
3:44 PM
@redline I can not see mutable proto outside the Object.create and Object.getPrototypeOf case.
 
the source of this problem is that objects and hashmap semantics are squeezed togheter
it is huge error to reference undefined property in an object
but not so in a hashmap
 
!!s/of this problem/of this awesome/
 
@BenjaminGruenbaum the source of this awesome is that objects and hashmap semantics are squeezed togheter (source)
 
0
Q: Review my jQuery plugin structure

AlexI'm trying to learn learning javascript and jQuery plugin standards, and after some googling and testing I've come up with this pattern: ;(function(window, document, $, undefined){ var plugin = function(element){ var instance = this, somePrivateFunc = function(){ console....

 
@Esailija An object isn't an hash map, it's an object. Using objects as hash map is for the lack of a hash map type. I use Map objects when I am able.
 
3:46 PM
That's why people don't get things like new Array(6), and frankly a lot of other things related to programming a lot of stuff. There's the difference between having a 0 value, and not having a value.
 
people don't get new Array(6)?
 
The reason you can't do (new Array(6)).map(...) and the likes
 
well yeah .map etc is also specified impossibly
like when do you actually need the semantics there?
 
yea
i'm confused here
 
like if you want to iterate over holey array, you will not use a loop like is used in .map
if you want to iterate over dense array, you will not check that the index is defined
 
3:48 PM
of course not
for > map
 
but .map has worst of both worlds
it iterates over every index and also checks that the index is defined
xD
 
There's something that really bothers me with the array extensions...I think I mentioned it before. Why is .reduce the only array function which doesn't accept a thisArg?
 
I need to dynamically change the colspan value of a <td>: $('#ColLabel').attr('colspan', Span);What's wrong with that syntax? The span value increases by one each time a column is added to the table but it has no affect. Do I need to escape the Span variable value?
 
ewww
 
yeah that's just weird
 
3:50 PM
i never noticed that
 
There are several good theories, but I asked the es5 mailing list and didn't get an answer.
 
i can't understand why you wouldn't want it
especially since it's everywhere else
 
For instance, specifying thisArg but not an initial value (or the other way around)
 
use custom .map
 
why force yourself to use closure of your own?
 
3:51 PM
custom everything in fact... the es5 semantics are almost always stupid
 
or .bind or something
 
It's not difficult to reproduce...I just have to wonder
 
i agree that that is retarded
i'm big on organization and that just doesn't match anything
 
all the array natives need to take into account dense and holey arrays
 
@redline Not entirely. Say the signature is reduce(func, initialValue, thisArg). How will you specify a thisArg without specifying the initialValue? You can't not pass in an initial value, and both undefined and null are valid initial values.
So maybe they thought hacking around thisArg is easier than hacking around initialValue (which it is)
 
3:54 PM
good point
or you can just provide different methods
 
But I don't know that for sure, which is sooo annoying
 
but that might be even worse
 
thisArg is useless in map/reduce/filter
 
you can't know that for sure
that is entire up to the coder
 
I stand by the above statement.
 
3:57 PM
what if you used an object to specify settings for the reduction function and used thisArg to do so, or something
 
@BenjaminGruenbaum it's just as useless/ful as in forEach
 
exactly, this is about giving the option to use it
which all the others do
 
forEach is redundant anyway
 
@FlorianMargaine not useful there either
@Zirak I like forEach, it's a better for... of
 

« first day (967 days earlier)      last day (3987 days later) »