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

11:02 AM
I think that guy is in love with his on face
 
DOes it seem to me or does he really have not one but three background musics?
 
Try right-clicking
 
OK, so I have to enter the menu to inspect his DOM?
 
user1125394
some colleagues fought to deth about spaces, don't mess with that
 
I'm wondering what's there to hide, but the musics (SIC) deter me
*death
 
11:08 AM
Oh the drama
Benjamin, your post is simply awesome. I could not have said it any better myself. I built that jTypes library that Aadit hates so much, and I think you hit the nail on the head. Classical inheritance is simply a design pattern, and a very good one at that. jTypes simply converts classical inheritance-like definitions into a prototype-chained instance matrix for you. It does all of the dirty work of moving throughout the instance matrix, and lets you focus strictly on your class implementations, while still working in a very powerful language such as JavaScript. — redline 41 secs ago
 
haha, a fail within a fail: ibnlive.in.com/news/… (scroll to the end)
 
c'mon, one extra level of escaping cannot possibly hurt, or can it?
 
Will emailing them accomplish something?
 
maybe they'll sue you for hacking their website :-)
 
@Zirak the problem is with you. @copy looks at that script tag and sees what the resulting script would look like, you're just not zen enough.
 
11:15 AM
they're offloading your browser's work to you.
 
@BenjaminGruenbaum You reminded me of steve-yegge.blogspot.com/2010/07/…
That one's just brilliant
 
this is like the 6th time you've linked to that article in this chat room since I started frequenting. I like it too :)
Wait, that's another one maybe?
Dammit, I'll have to read it
@Zirak that's not what I was expecting at all :) That's pretty damn funny
I thought it was the same one you linked to on the JS inheritance post
> Agile Java Developer Johnnie Garza of Irvine, CA condemns the move. "They have no right to do this. Open Source does not mean the source is somehow 'open'. That's my code, not theirs. If I make something private, it means that no matter how desperately you need to call it, I should be able to prevent you from doing so, even long after I've gone to the grave."
K, I don't like that guy anymore:
Then you are completely missing the point like many others. There is more to coding than just performance. Design patterns and frameworks are created to make things easier. Having abstract/virtual members is a big part of the classical inheritance design pattern. When you try to scale up a framework in JavaScript, it quickly becomes a daunting task to organize and separate your code. Classes, along with the concepts in classical inheritance, solve these problems. So if you can use both prototypal inheritance for performance and classical inheritance for design, what's stopping you? — redline 1 min ago
That's just stupid
 
jTypes is stupid.
 
>except those required for hacking around the 15-year-old Java language's "fucking embarrassing lack of closures."
Haha
 
@phenomnomnominal - Tell me about it.
 
11:25 AM
@Zirak To be honest every time I see a link to that blog I expect that one
@AaditMShah Yeah, all my point was is that's it's just another design pattern. jTypes looks horrible.
 
yeah that's a classic
 
It's fucking awful
 
oh my...just looked at jtypes.com .
blegh
 
var Employee = $$(Person, function($fName, $lName, $age, $salary)
{
    this.__base($fName, $lName, $age);

    this._salary = $salary;
},
{
    'protected _salary': 0,

    'public override triggerOneYearOlder': function()
    {
        this.__base.triggerOneYearOlder();

        this._salary *= 1.03;
    },

    'public salary':
    {
        'get': function()
        {
            return this._salary;
        }
    }
});
Holy fucking jesus that is the ugliest fucking thing I have ever seen.
8
 
@BenjaminGruenbaum - I know. I use the classical inheritance pattern all the time. Look at my augment function: github.com/javascript/augment
 
11:27 AM
> League of Agile Methodology Experts (LAME)
@AaditMShah Then why does your answer say that classical inheritance is stupid in this context? (p.s. you don't really need an Augment function)
 
you don't need any library or function to do it
 
That's what I said
 
I use 2 simple macros
 
That works.
 
@BenjaminGruenbaum "Have you ever legalized marijuana" is also a great one
 
11:31 AM
@Zirak LOL, seen this response? What an idiot.
 
holy shit are those performance charts for real
7 milliseconds to create one instance? wtf
 
@Zirak at work. I'll read it later.
 
@BenjaminGruenbaum - My answer never says that classical inheritance is stupid. Read it carefully. What I'm trying to say is that trying to implement classical inheritance in JavaScript is a bad idea.
 
@AaditMShah " it's a really bad idea to try to implement classical inheritance in JavaScript."
No, it's not
 
You've already seen jTypes. That's what I'm referring to when I say that it's a bad idea.
 
11:34 AM
@AaditMShah that's not what your answer says though
 
@BenjaminGruenbaum - I'll go and edit it then. I'm not against classical inheritance.
 
function getBase(){
    return {x:5};
}
function getSub(){
    var b = getBase();
    b.y = 6;
    return b;
}
^ That is subtyping.
That's classical inheritance, didn't need anything, no keywords, no special functions nothing.
There is nothing any less class based inheritance here than in Java, or C#. The classes are just less explicit.
 
s/getbase/getBase/
 
@BenjaminGruenbaum - Precisely. What the OP wanted was a way to create actual classes in JS. That's what I was warding off.
 
lol closures is not the same as private variable
 
11:36 AM
@BenjaminGruenbaum haha, that's great. I love how he bases most of his argument in "I need someone to blame"
 
@AaditMShah He has a way, that's what my answers say
 
please just use underscore prefix
 
@Esailija They're very different, I think my answer clarifies that.
 
@Esailija __proto__
 
@Esailija read on :)
 
11:37 AM
it's not just performance and memory, your objects become inflexible as fuck
and JIT is not magic, it will not do anything to code that uses dynamic features gratuitously
 
Right, but it will optimize closures very well.
 
no
 
What I mean is. Even if you assign the same function to multiple objects and that function has access to closure, it won't have a copy of that function for each object.
 
@BenjaminGruenbaum - Then I don't think we have anything to fight about. We're defending the same argument.
 
but that's not an optimization but normal semantics of any object
when you assign any object, you don't copy that object
 
11:39 AM
@Esailija Right, but you create a new function every time
function getA(){
    this.somefunc = function(){};
}
 
yes, the standard function object will always take at least 80 bytes
like at minimum
then you have, say, 20 methods
 
This creates a new function object on every call to getA but I'm pretty sure that if you create a thousand 'A's with calls to getA it won't store a thousand different functions.
 
object with 3 fields now takes like 2 kilobytes per object
yes it won't create 1000 different stubs of code of course
but it will create 1000 function objects (including the prototype object of each one with constructor pointer)
 
Of course, it has to
 
and you multiply that by N
and this is just memory
in performance, this style restricts inlining a lot
and
semantics
your class is inflexible now
 
11:43 AM
What, why?
 
well how do you do inheritance or delegation with this?
 
I can pass methods around without the actual object now. I like that.
 
if a function references a variable inside its closure it cannot be reused
why is that useful though
 
No, but it can be passed around.
 
Oh boy, what a Sunday! First the UCI Downhill World Cup run in Fort William and then the Formula 1 Grand Prix in Canada! (ノ^_^)ノ
 
11:44 AM
you are paying the price of Function.bind without necessarily needing it
 
I think funtion.bind is more expensive than a normal closure. I agree that privates are an overused and usually not needed concept, however I think we're talking about completely different levels of performance magnitude.
 
Re-reading the marijuana article makes me realize and thank a supreme entity that I don't have to work with money.
 
you don't need to use the native Function#bind though, a simple custom version is enough in this use case
 
It'd be easier and less touchy to write software for an AI machine gun than to navigate the financial mine field.
 
If OP is coding anything that is not super performance sensative, like 99.9% of JavaScript in the world, it's really not a big deal to use that style.
Just like I'd use .filter(...).map(...) over a simple for loop although a simple for loop with an if check with creating a new array myself is much faster.
 
11:46 AM
node.js is extremely performance sensitive
 
user1125394
var o_o=true
for (;o_o;)
 
I gotta go now. Bye.
 
Right, node.js is performance sensative, I wouldn't use closures like that in node.js without a very good reason.
However, even in nodejs, usually that sort of thing isn't usually the bottleneck.
 
ok so we have CRUD ui widgets then or something
then what is?
 
If your argument is that you don't need privates, I pretty much agree. I even cite TM's answer in the end and agree with it.
 
11:48 AM
well I mean, underscore prefix is just so awesome
you can even have simple script checking that all ._prefixed are on this
 
I don't even underscore prefix. I just define my APIs clearly with testing and documentation.
 
I.E. asd._value would be error but this._value not
 
If you want to access an undocumented property on my code? Be my guest, but you get no guarentee if you're using something that isn't a part of my API
 
@BenjaminGruenbaum but then you'll probably be forced to document it
 
I dunno I kinda want it to be at least somehow in code
 
11:50 AM
@JanDvorak Nope
 
@BenjaminGruenbaum __proto__
 
@Esailija Why?
@JanDvorak Mutable proto (outside the Object.create case) is a horrible idea. Guess who said it.
 
The guy who invented JavaScript.
 
if you "learn the api" by inspecting objects in console or source code then there is no confusion
not everyone goes through documentation
 
I thought Javascript was meant to have mutable prototype chain?
 
11:52 AM
@redline two points.
 
Damn right.
Thanks.
 
@Esailija If you have to "learn the api" by inspecting objects in the console, someone was lazy.
 
I see you hate me now though, since I made a bad remark about performance...
 
@JanDvorak I have a dog, my dog is an animal. Does it make sense that my dog suddenly stops trying to be an animal? None.
@redline We don't hate you, your library looks like overkill though :P
 
@BenjaminGruenbaum well I don't care about how good your documentation is, I want to know exactly what is going on
 
11:53 AM
@redline You can pretty much accomplish what it does without it. I agree with you and not with @AaditMShah on classical inheritance being useful :)
 
Well I'm sorry you think it's overkill.
Based on some of the giant libraries I have had to put together at my past job, I couldn't have lived without it.
 
@redline If you like that, why not use TypeScript? It's designed to solve these sort of issues.
 
No.
Typescript sucks in comparison.
 
@Esailija I'd really like interfaces in JS.
 
No virtuals, no overrides.
No abstracts.
It's pre-compiled and hard-typed.
Old school way of thinking.
With jTypes, I could technically created an override, but just for MSIE. Since it's all at runtime...
 
I know what Typescript is.
I saw it a long time ago.
 
That's not a link to typescript, it's a link to the work item on abstract support
 
But I just said, it's hard-typed and I find that to be counter-intuitive to JS.
Oh ok, sorry. It cut off the end of the URL.
 
it's only typed while you write it
 
and it's optionally typed
 
11:56 AM
I understand that. But I couldn't wrap a method definition in an if-statement now could I?
 
@redline I find hard-coded classes counter intuitive to JavaScript
 
@BenjaminGruenbaum you mean explicit interfaces :P
 
@Esailija You know damn right what I mean :P
 
The classes aren't hard-coded. You can make them expando using the expando modifier.
 
I can make you a tool that extracts out interfaces from functions :P
 
I think "jtype" will be cool. as I am from background of C#
 
and still set members on the prototype chain. They are just normal JS classes.
 
@redline I don't think that classical inheritance isn't useful. I do think that it's unnecessary in JavaScript. That being said I do use the classical inheritance pattern in JavaScript all the time.
 
Exactly. Many people do.
But Typescript is not the answer.
It's taking the JavaScript out of JavaScript.
 
@AaditMShah So let me get this straight. You think it's not useful but you use it all the time?
 
11:58 AM
@JonKoops 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.
 
the problem is people think classical inheritance is using the word New
 
I love prototypes, and I can make a way better version of Typescript using just prototypes.
 
Hey guys
 
Right, and you can choose not to use the "new" keyword with jTypes.
 
@JonKoops Hi
Wow, everybody came ^_6
 
11:59 AM
It just doesn't call the constructor. So this gives you more flexibility if you want to design it that way. I also have a setting for restricting that. But the point is, it is as open as it can be, giving you complete control over your development.
 
@BenjaminGruenbaum - I don't think we're talking about the same thing here. I use the classical inheritance pattern like the ones you described in your answer. I don't use actual classes or interfaces, etc.
 
> It's taking the JavaScript out of JavaScript.
 

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