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

12:00 PM
@AaditMShah Let me ask you a question, what is a class? Isn't a class just a type?
 
That's like saying jQuery takes the DOM out of the DOM.
 
@redline You wrote jTypes and you can say that about TypeScript with a straight face?
 
@AaditMShah Aren't you using classes in your code, but are doing so implicitly all the time?
 
There are no classes, only objects.
 
@AaditMShah And if so, aren't you doing classical inheritance, but in a way that's different from Java's?
 
12:00 PM
Exactly, there is no such thing as a class in JavaScript. jTypes doesn't make classes. It is a prototype instance matrix builder.
 
In the most god-awful, un-JavaScript looking way possible
 
It's in a way for C# devs to transition.
You are an excellent JS programmer. You don't need classes.
I was a C# dev for ASP.NET
this will be helpful to people like that
it is not designed for someone such as yourself
which I why I used the same modifier keywords as C#...that was ON PURPOSE
 
okay sure, but why is it like this:
'public override triggerOneYearOlder': function()
{
    this.__base.triggerOneYearOlder();
    this._salary *= 1.03;
},
 
how else would you like to easily specify access modifiers in a name?
 
Let me blow your mind. JavaScript has classes just like any other OOP language, they're just implicit. The notion of typing is there, you can create objects, extend them in a way that respects LSP and so on, and don't have to use JavaScript like another language to do it. Just because you don't use the class word to define a type doesn't make it any less of a class.
 
12:02 PM
I personally would prefer it to look something like...
 
I don't think that using a language in an unidiomatic way is ultimately helpful.
 
btw anyone read the blog post by Steve Yegge where he implements prototypal inheritance in Java? :D
 
triggerOneYearOlder: public(override(function() {... }
Which is still fucking awful
 
Well I am opening to implementing any kind of defintion. There is no restriction on the types of definitions you could input to the jTypes compiler.
 
12:03 PM
But in CS it would look like: triggerOneYearOlder: public override ->
Which I could live with
 
@Esailija Gosling said he'd code functionally in Java, but people didn't like it :P
 
This is just taking your definition, and creating an instance matrix for you. You can use the native "instanceof" operator to check the types, and cast to any base type you'd like. jTypes navigates the instance matrix for you. It passes the private instances to your functions, and the public instances are available on the object instance.
 
But you can still use prototypes. You can still put methods on the prototype chain, ect. You will just be restricted to your public members, which again, is no different from regular prototype-based objects.
 
I feel I should question the definition of 'class' people are using here
 
12:05 PM
@AaditMShah You're saying you think a pattern is not _use_ful and then you're saying you use it all the time. See the problem?
 
@phenomnomnominal If you would like to write up some definitions you can live with, I am open to all suggestions. I have no problem implementing more.
 
I am thinking to learn a new programming language. Just on weekends. what should I learn? (thinking about ruby)
 
@phenomnomnominal I am trying to make this as simple as possible.
 
guys what counts as "implementing classical inheritance"?
 
@Mr_Green I'm looking to get into Ruby myself as well.
 
12:07 PM
@Esailija ECMA
 
hmm I think it is cool then :)
 
@Esailija I would say jTypes is emulating classical inhertiance
 
33 mins ago, by Benjamin Gruenbaum
function getBase(){
    return {x:5};
}
function getSub(){
    var b = getBase();
    b.y = 6;
    return b;
}
 
It currently seems to be about as complex as possible
 
why cannot you just use old school constructor xD
 
12:08 PM
How so?
I would definitely like some feedback here. I haven't gotten much yet.
 
@Esailija I'm badass, just like that.
 
You took something simple and beautiful (JavaScript) and polluted it with the very concepts it has always tried to avoid? It's just a bit yucky.
 
I am simply trying to make it as open as possible. The class definitions themselves are completely abstract (no pun intended).
 
@AaditMShah where did you go :/
 
I just want to have an organized structure for large libraries (and not just in the way minifier code comments can achieve), but also with polymorphism and encapsulation. How can you build a large library without those two things and just inheritance?
 
12:11 PM
I find it funny that @AaditMShah says that classical pattern has worse performance, then goes on and uses Object.create which cannot be inlined
 
@BenjaminGruenbaum How do you handle functions on Objects in that code?
 
@Esailija I use Object.create, big deal :P
 
@redline all you need is the module pattern :)
 
When working on a large team of people, and trying to code large JavaScript libraries, that proved to be way too difficult. This made it so quick and easy.
 
@JonKoops The same way I'd handle them anywhere {a:function(){}} tada, an object with a function.
 
12:12 PM
@BenjaminGruenbaum well yes but don't go saying it has good performance lol
 
@BenjaminGruenbaum Doesn't that create duplicate functions?
 
@phenomnomnominal There is no ability to declare a virtual method or to use any kind of polymorphism. Both of which are very important when building large libraries.
 
@Esailija @JonKoops If you want, you can store functions on the prototype, storing functions on objects creates duplicate closures, not functions.
@redline WAT?
 
@BenjaminGruenbaum What?
 
@redline Polymorphism? Is that a joke? The whole language is duck types, I can look at any object like any other object and just try to access it. It's practically free.
 
12:14 PM
@redline, yeah are you kidding?
 
yes closures sharing compiled code is being done but it is almost the whole extent of how closures are "optimizied"
 
Yes but what I mean is, take this example:
 
@redline If I stick a bark method to both a and b then for all purposes, they are dogs.
 
@BenjaminGruenbaum Yes, but since it is anonymous prototypes wont matter.
 
you lose out on most important optimizations like inlining though
 
12:15 PM
I have an object a, and then I make object b inherit from a with Object.creates()
if i set any properties on b, but then want to cast to a, I can't do that.
 
@redline, you're trying to force JavaScript to be something it just isn't
 
I mean it creates a new Object every time.
 
@Esailija Nobody cares :P I like having optimization discussions with you, but we're talking about completely different magnitudes of performance. I write code I find readable, then I start dealing with what V8 can inline and such.
 
@phenomnomnominal Tell that to TypeScript or CoffeeScript, I simply made something that made more sense and didn't require anything external.
 
CoffeeScript makes a point of only being JavaScript
 
12:16 PM
@redline If you're doing casting in a language like Java or C# from a subtype to a supertype on a regular basis, you're using THAT language wrong.
 
It is purely syntactical sugar, it doesn't change a thing about the language.
 
@phenomnomnominal Obviously way more experienced developers than ourselves think having classical inheritance in JavaScript is important, and I agree.
 
Not to mention JS, in JS that's not abuse, that's malice.
 
@BenjaminGruenbaum the readability argument for new Person() vs Object.create(proto) is even less productive
 
@phenomnomnominal AHEM*scoping*AHEM
 
12:17 PM
I mean for me, the left is more readable, but if for you the right one is, then fine
what can be argued about there
 
@BenjaminGruenbaum (GODDAMIT)
 
I don't mean casting in the literal sense. I could pass an object into a function in C# that has a base type, technically I didn't "cast" anything, but it still had to be casted.
 
@redline, no one is saying it isn't important, but jTypes isn't just about Classical Inheritance
 
@Esailija All I'm saying is that the type of performance you speak of is not the type of performacne people normally worry about. You know it, I know of it and it to some extent, but it's not really a big deal in most cases, even in node, unless you're building something huge.
 
It seems to be about replicating every single concept in OOP
 
12:18 PM
@redline I can do it in JS too!
 
I just don't understand what good classical inheritance is without method overriding?
 
And it's 'importance' is based on peoples familiarity with it
 
Also, the fact "classical" languages don't have run-time polymorphism sucks in classical languages, not in JS :P
 
Don't forget super calls!
 
@JonKoops Hey, my example has a super call
 
12:19 PM
@BenjaminGruenbaum object creation speed is important for example in the game niche
you have 16ms per frame and need to create 2000 particle objects e.g.
 
@BenjaminGruenbaum Exactly, which is why I feel jTypes is a way better alternative to TypeScript
 
@ben
 
@Esailija If you're creating 2000 particle objects maybe you should use a 2d array and not objects to begin with. Optimization comes in different levels.
 
@BenjaminGruenbaum Does it?
 
@JonKoops getBase()
 
12:20 PM
Thats not a super call
That's just a function
 
@JonKoops Sure it is, it's the constructor of the super type.
 
@phenomnomnominal But still, what good is classical inheritance without method overriding and the ability to down-cast with those overridden methods?
 
@redline, I'm really sorry buddy, I know you've put a lot of effort into it, and there are people who are certainly interested in it. I'm just never going to be one of them
 
@redline You're entitled to like your framework. Although, this room is full with people who develop JS for a living, and none of us is under the impression it's a good idea. That doesn't mean it's a bad idea, but that's our opinion.
 
I could define an animal, have it make a sound, but not yet know what it is, and then iterate an array of animals.
 
12:21 PM
@redline Seriously?
 
So um, use prototypical inheritance?
 
@BenjaminGruenbaum yeah like that's readable :D but that would not be a problem at all when using new is my point
 
Prototypal inheritance makes it appear that it is a method override, but it is not
prototypal inheritance would be like if C# only had interfaces
we are talking apples and oranges
 
No, we're talking semantics.
 
just cause I know a method is defined, doesn't mean anything
 
12:23 PM
interface or Interface? =D
 
@redline [{makeSound:function(){alert("MOO");},{makeSound:function(){alert("Meow");}] I have an array of different types and polymorphically I treat them all as animal. Mind=blown
 
Yes, duh, I understand that
 
Blind=mown.
 
But you were free to do whatever you want.
 
am I the only one for who the module pattern is more than good enough?
 
12:24 PM
@FlorianMargaine, nope, that's all you need
 
I could use anonymous classes in C# all day long and do the same thing
 
and thinks that more just complicates stuff?
 
Can we just make one thing clear: JAVASCRIPT IS NOT C#
 
Really?!?!?!?
Woah, that's quite a wake up call.
Now it all makes sense.
 
Genuinely can't tell if you're being sarcastic.
 
12:25 PM
I was totally sarcastic
 
ahaha
good one ;)
sarcastic about sarcasm...mind = blown
 
stop saying "mind = blown", you look like kids
 
@BenjaminGruenbaum, yeah Ben.
 
@FlorianMargaine mind=blown
^ <- I haven't pissed Zirak with that yet today
 
12:27 PM
This is usually how I do inheritance: jsfiddle.net/tfPRU, any comments?
 
^^ mind === blown
 
Inheritance is an overused pattern in Java and C# anyway
 
ReferenceError: "mind" is not defined.
 
I think I know what my next nick is going to be.
 
@FlorianMargaine Hahahah
@BenjaminGruenbaum Inheritance is essential for large-scale JavaScript driven applications.
 
12:32 PM
@JonKoops No. It's not.
 
@Yes, it is.
 
@JonKoops What do you do for a living, mr. large-scale JavaScript driven applications?
 
No it's not
 
How do you handle event dispaching then?
 
Alright, I have a better way to explain this than my original Animal example where I started talking about abstracts for the wrong reason. What if I wanted to define a method on a derived class like Zebra, but when treated as an Animal, I wanted it to use the Animal method instead?
 
12:33 PM
@JonKoops I'm not sure if you're trolling right now...
 
The only way I can accomplish this is by getting the prototype of "this" and calling the base method. But that pretty much means you have to "override" all the time if using this design pattern. So while you have made your instantiations way faster thanks to prototypes, you now have to get the prototype every time to call your function, and when you define more and more classes, all your chaining will eventually hurt more than it helps.
So it's really, where do you want the performance hit when trying to use all the features of classical inheritance, during instantation and having it all managed for you, or manage it yourself and have it have performance hits when triggering methods every time...
 
@BenjaminGruenbaum No. Could you explain why it is not necessary?
 
@redline Object.getPrototypeOf(this).parentMethod() , no need for it though.
@redline The whole point of polymorphism is that you look at your Zebra like an Animal but it is still zebra.
 
Animal.prototype.method.call(Zebra, ...)
 
@JonKoops how is event dispatching even closely related to inheritance?
 
12:34 PM
@phenomnomnominal This.
 
@redline In C#, if you have a Zebra in C#, and it implements Animal and overrides saySomething() you expect that even if you cast Zebra to Animal, calling saySomething would be Zebra's say something, not Animal's
 
@Raapwerk 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.
 
@JonKoops, I feel uneasy when you agree with me.
 
@phenomnomnominal You just did 4 propery accesses every method call just to get your base method.
 
@phenomnomnominal hahaha
 
12:35 PM
@FlorianMargaine Since you usually extend an EventDispatcher in order to you know, dispatch events.
 
@redline, so? You take 7ms to instantiate an object!
 
hm... no?
 
@JonKoops mixins, look into them.
 
@phenomnomnominal Now I feel bad abou myself :(
 
@BenjaminGruenbaum That's method overriding, not re-defining methods.
 
12:36 PM
@redline If you are overriding a method and still using the super class's method on the object not inside the override, you're doing it wrong anyway. That's bad OOP in C# too.
 
@phenomnomnominal That's a gross oversimplification. It used to take 7ms for a GIANT class with 100 members and 4 levels of inheritance. Not to mention, I got that time down to 2ms now, but for regular classes it's very quick.
@BenjaminGruenbaum I'm not overriding an method to call the base. I'm saying that's the only way to do it in JavaScript.
 
Either way, there is no case where you version is going to more performant
 
any concrete examples of mixins I can look at?
 
@redline I'm starting to feel is not that you don't understand prototypical OOP, but that you don't understand classical OOP. That makes me sad.
 
Articles that helped you etc.?
 
12:37 PM
@JonKoops google "Learning JavaScript Design Patterns" , it's an awesome free book by Addy Osmani, read it.
 
@phenomnomnominal Of course not, it's about design, not performance. But the performance is neglible for most applications.
 
@BenjaminGruenbaum I understand classical just fine. Talking to 3 people at once is very hard, and I don't ever chat here, so it's difficult to explain myself in text when talking to 3 people.
 
@redline, then don't bring it up :)
 
@redline Take your time :) no worries.
 
12:39 PM
Ok, let me try this again.
 
Go ahead, no worries.
 
If I want to define a method in a derived class, but not override it, that is not possible in JS without actually taking a performance hit of getPrototype or directly referencing the base method.
In languages such as C#, I don't even have to worry about that, I can define a method, and it replaces the base method.
 
@JonKoops is that good enough for an event dispatcher without inheritance? jsfiddle.net/xVQyd/1
 
However, if I choose to override it, I can. I have the CHOICE, without having to do any external referencing or type getPrototype all the time.
From strictly a design perspective, that's a lot of work, and takes a lot more time. When I need to get work done on time for my deadline, I need to make classes fast.
 
@redline What do you mean define a method in a derived class but not override it? Isn't that just defining a method?
 
12:41 PM
0.1 ms instantiation is nothing to me when I can define classes in the same manner as in C# without all the extra work.
 
If someone sat down with me at a code review and showed me jTypes code, I would probably vomit.
 
@redline you have lots of extra work. You write tens of lines of code compared to what I'd do in one line.
 
@FlorianMargaine Yes, but I meant an implementation in another object.
 
So you want to make another object that inherits the event dispatcher functionality?
 
12:43 PM
@BenjaminGruenbaum Exactly. But in JS if I did that, but then had the array of Animals, it would not call the Animal method anymore. The top-level method in the prototype always takes precedence.
 
No you can't do inheritance without inheritance.
 
@FlorianMargaine I'll show you, gimme a sec
 
I have no way to define a method in Zebra, throw it in an array of Animals, but then have the Animal method called instead of the Zebra method.
 
Yes you do
 
Unless I grabbed the prototype before throwing it in the array, but then it does not have any of my data.
 
12:44 PM
function Animal() {
    return { type: 'cat', run: function() {} };
}
how is that not faster than making a class with at least ~20 lines?
 
This is like the most blown out version of the XY problem ever.
 
@redline I'm arguing, you shouldn't do that in C# either, if you over-ride the Animal method in Zebra, and need to call Animal's method again outside of the Zebra class. Your classical OOP is wrong to begin with. Now that can be solved in JS, and easily, but that's not the point. The point is that your C# code is wrong.
You're asking how to solve a problem a good design would not have in the first place.
 
[Zebra, Giraffe, Goat, Cow].forEach(function (a) { Animal.prototype.run.call(a); });???
 
@BenjaminGruenbaum Then you are not understanding me for some reason.
I already said, I would never define an override to call the base in C#, that is retarded.
I'm saying every single method definition on a derived class in JS is an override, the only way to make it not is to do that, which is a retarded method.
 
@redline Then explain. Write C# good, trust me, we're all quite capable with C# here.
 
12:48 PM
> I'm saying every single method definition on a derived class in JS is an override.
wut?
 
Man guys, why is this so hard to understand.
I just want type B to derive from type A and define the same method as type A.
 
@redline Then you're overriding the method, are you not?
 
I'm just talking about which method is called depending on how I want to treat the object.
As A or B.
In C#, I have two options
 
Everyone understands, everything you've said. It's just wrong.
 
@redline Write C# code. That would be the easiest.
 
12:49 PM
I don't know how to write code in this stupid chat. The max is so short.
 
@phenomnomnominal I think he's talking about runtime polymorphism, which C# doesn't have.
 
I'm trying to explain it but before I can finish someone else already says it's wrong. I know it's not wrong. I'm not a damn fool. I know how to write C# and JS just fine.
 
@redline you seem to have a habit of attacking things you don't understand
 
@redline We're not attacking you, we just don't understand you. Use pastebin
 
@redline use gist.github.com if you want to write some long text
 
12:51 PM
class A
method Blah()
class B
method Blah()
 
I, for one, am happy to wait for you to construct your full argument, or perhaps write a blog post.
 
OR
class B
override method Blah()
 
do you have a concrete example of this usage?
 
So in C# if I did this, and did this new A[] { new A(), new B() }
with me so far?
 
So far yeah
 
12:53 PM
Whether I made Blah() an override or not has a direct effect on that array when I iterate and call Blah()
Now, forget C#
To do this in JS
class A
method Blah()
class B
method Blah()
which is all I can do
unless in B.Blah() I have getPrototype or A.prototype
in it
I have to manually call the base method to get the first option in C#
and actually keep track of that myself
I can't say getProto(array[1]) before putting it in the array
 
do you have a concrete example of this usage? Because I can't see it in any useful scenario right now.
 
@redline Calling Blah on that array would call A's blah on A and B's blah on B. Exactly like it would work in JS. I don't see your point.
class A
{
    public virtual void Blah()
    {
        Console.WriteLine("I'm A");
    }
}
class B : A
{
    public override void Blah()
    {
        Console.WriteLine("I'm B");
    }
}
Try it for yourself
 
yes, that is what JS does
but do it the other way
no virtual, no override
then put them back in the array and do it again
in C#, all is well
 
but when do you want this behaviour?
 
@ionutvmi 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.
 
12:56 PM
in JS, I can't RECREATE this functionality without manually keeping track of it myself and I coding it myself
 
you want the subclass to define a method with same signature but not override it?
 
Why wouldn't you want this behavior? It's standard class behavior. People don't ALWAYS override...
 
That's bad behavior indicating a design problem imo
 
that's ridiculous
 
No it's not
 
12:57 PM
@Esailija Yes, sadly C# makes this possible, it is widely considered a design mistake in the language.
class A
{
    public void Blah()
    {
        Console.WriteLine("I'm A");
    }
}
class B : A
{
    public new void Blah()
    {
        Console.WriteLine("I'm B");
    }
}
I think this is what @redline means, right?
 
That's saying classical inheritance is a design mistake then...
YES!!!
 
This should print 'A,A'
 
using the new keyword to hide the warning
 
@redline See how far a little code can go? You know that sort of behavior doesn't exist in other 'classical' languages right?
 
In C# this is easy squeezy
but not in JS
 
12:58 PM
so you look at what is clearly an ugly hack, and think ooh, JS needs that?
 
you can't do this in Java
can you?
 
C++ C#
 
And again, when do you want to do this??
 
@Esailija nope, in JS methods are virtual by default, you use the final indicator to prevent extending them.
 
all the time
this is the foundation of classical inheritance
polymorphism
 
12:59 PM
clearly it's not
 
is that a joke?
 
@redline No, it's not, the other version is. The other version is polymorphic, this one is not.
 

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