uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Replace this with self #414

Closed flbulgarelli closed 8 years ago

flbulgarelli commented 8 years ago

C++ derived languages - JS, Java, C# - tend to use this keyword for object self-referencing, while Python and Smalltalk derived languages - swift, self, ruby - tend to use self.

Thus both self and this keywords are common terms among programmers.

However, using self has three good points over this:

flbulgarelli commented 8 years ago

@npasserini @javierfernandes @PalumboN @faloi any comments?

flbulgarelli commented 8 years ago

I'd like to know if I can proceed with merging the corresponding PR

javierfernandes commented 8 years ago

Sorry, I don't find any good reason to change it. I think that it is just a matter of taste.

3 out of 4 of the first 5th languages in TIOBE use "this".

On Wed, Dec 30, 2015 at 7:29 PM, Franco Leonardo Bulgarelli < notifications@github.com> wrote:

I'd like to know if I can proceed with merging the corresponding PR

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-168086494 .

flbulgarelli commented 8 years ago

Haha, yes, but they all languages from the same family :stuck_out_tongue: C++, Java and C#

But what about my reasons? When you teach to programming with objects in an initial course, do you say that "pepita le envía un mensaje a esto" or "pepita se envía un mensaje a sí mismo"?

matifreyre commented 8 years ago

My vote goes with Franco! I'd rather use self instead of this. El dic. 31, 2015 12:03 AM, "Franco Leonardo Bulgarelli" < notifications@github.com> escribió:

Haha, yes, but they all languages from the same family [image: :stuck_out_tongue:] C++, Java and C#

But what about my reasons? When you teach to programming with objects in an initial course, do you say that "pepita le envía un mensaje a esto" or "pepita se envía un mensaje a sí mismo"?

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-168113684 .

javierfernandes commented 8 years ago

I'm not sure about translating programming. In that case I would want a spanish programming syntax ;)

Yes most used languages are c/java like. El dic 31, 2015 12:03 AM, "Franco Leonardo Bulgarelli" < notifications@github.com> escribió:

Haha, yes, but they all languages from the same family [image: :stuck_out_tongue:] C++, Java and C#

But what about my reasons? When you teach to programming with objects in an initial course, do you say that "pepita le envía un mensaje a esto" or "pepita se envía un mensaje a sí mismo"?

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-168113684 .

flbulgarelli commented 8 years ago

Perhaps we can't translate everything, but sure there are terms that better map to our speech than others. I am sure about that.

Actually, the concept of self-referencing precedes object-oriented programming. this keyword comes from C++ derived languages, as already said, whose design decision can not be taken too seriously from an pedagogical point of view :wink:

javierfernandes commented 8 years ago

Then I think that me is what we want.

I don't think that in english one refers to oneself with the "self".

method fly100meters() {
     me.fly(100)
}
method getTrainedBy(trainer) {
    trainer.teach(me)
}
method travelBy(rocket) {
   rocket.fly(me).to(theMoon)
}
flbulgarelli commented 8 years ago

Weird, since it remembers me (? to the old VB days, but could work. I prefer it definitely to this

flbulgarelli commented 8 years ago

To be clear: I think that self is still better, because it maps to the _self_referencing concept, and is quite standard in the programming community.

Me is my second choice. I agree with @javierfernandes it fit a bit better with the object-point-of-view reasoning. But it is nearly an invention of us. It is also a very short word - two characters -, I wrote some examples for myself and it is easy to ignore it.

Perhaps there are other alternatives better than me and self.

this is my last choice. I really would like to avoid it as possible.

matifreyre commented 8 years ago

"it is nearly an invention of us" --> Not at all... OO-ABAP uses me and I'm sure it's more than 10 years old. And I consider it awful since I knew it :)... I'm sorry @javierfernandes, I just never liked it (maybe it's because I don't like so many syntax elements in OO-ABAP and I cannot separate both things).

My first choice is still self, as it is a noun instead of a pronoun like either this or me, and it feels to me that it's a slightly better choice for referencing an object.

On Fri, Jan 1, 2016 at 8:14 PM, Franco Leonardo Bulgarelli < notifications@github.com> wrote:

To be clear: I think that self is still better, because it maps to the _self_referencing concept, and is quite standard in the programming community.

Me is my second choice. I agree with @javierfernandes https://github.com/javierfernandes it fit a bit better with the object-point-of-view reasoning. But it is nearly an invention of us. It is also a very short word - two characters -, I wrote some examples for myself and it is easy to ignore it.

Perhaps there are other alternatives better than me and self.

This is my last option. I really would like to avoid it as possible.

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-168349734 .

Charlyzzz commented 8 years ago

As @flbulgarelli said, I think the key point lies under "[...] map to our speech [...]". Sorry for using spanish but I think some of my intentions may be lost in the translation.

Hay que pensar mucho en la diferencia entre lo que hacemos y decimos. Cuando enviamos un mensaje cuyo receptor somos nostros mismos, me parece interesante ver como es para alguien que recién se desayuna con este concepto. Por ejemplo un snippet random en un sintaxis smalltalkeana:

     hacerTorta: unosGramosChocolate en: unHorno
     unHorno prender.         
     *Inserte aquí la sintaxis de autoreferencia favorita* prepararMasaCon: unosGramosChocolate
     *Pasos siguientes*

¿Cómo es la forma más natural de enunciar esto en nuestras cabezas? Nos "paramos" adentro del objeto en cuya clase estamos editando y pensamos "Le digo al horno que se prenda", "Pongo agua al fuego" y "por último preparo la masa". Quien prepara la masa? Yo. Esto concordaría con un self o me.

Si nos paramos a analizar el this, estaría implicando verlo desde una tercera persona, cosa que suena un poco antinatural, ¿no les parece?

Más haya de si se usa en X o Y lenguaje, creo que estaría bueno desarrollar el lenguaje pensando en lo que queremos nosotros (como vienen haciendo), utilizando nuestra experiencia como guía y no givear un fuck por otras cosas que existen o que sean convención. Arrimar el bochín para el lado del alumno me parece que garpa más.

Si bien entre las opciones disponibles self se lleva el poroto, creo que también se podrían utilizar otras palabras como myself o algún derivado.

PS: Perhaps this is a good question to add in the questionnaires that were handed at the end of the course :P.

npasserini commented 8 years ago

Francamente no creo que this o self o me cambien gran cosa. Más interesante sería afinar el lápiz en cuanto a los criterios de decisión que utilizamos. Acá Erwin propone "no givear un fuck" por otras cosas que existen, en cambio al discutir sobre métodos de colecciones se habló muchísimo sobre cuáles eran las opciones más populares. Acá hablamos de didáctica, en el thread de los bloques se hizo un cambio con implicancias didácticas casi sin hablar de ellas.

Yendo a algo más puntual, aquí el ejemplo de Erwin no me parece del todo feliz. El uso de self aparece modelando a una persona, la persona habla de sí mismo. Creo que es el tipo de ejemplos que conviene editar, porque dan una imagen confusa de lo que significa modelar con objetos. En un sistema real, sería muy raro que alguien programe cómo una persona hace una torta. No quiero plantear esto como un argumento a favor del this, solamente quisiera que vayamos puliendo la forma en que tomamos decisiones.

2016-01-02 22:19 GMT-03:00 Erwin Debusschere notifications@github.com:

As @flbulgarelli https://github.com/flbulgarelli said, I think the key point lies under "[...] map to our speech [...]". Sorry for using spanish but I think some of my intentions may be lost in the translation.

Hay que pensar mucho en la diferencia entre lo que hacemos y decimos. Cuando enviamos un mensaje cuyo receptor somos nostros mismos, me parece interesante ver como es para alguien que recién se desayuna con este concepto. Por ejemplo un snippet random en un sintaxis smalltalkeana:

 hacerTorta: unosGramosChocolate en: unHorno
 unHorno prender.
 *Inserte aquí la sintaxis de autoreferencia favorita* prepararMasaCon: unosGramosChocolate
 *Pasos siguientes*

¿Cómo es la forma más natural de enunciar esto en nuestras cabezas? Nos "paramos" adentro del objeto en cuya clase estamos editando y pensamos "Le digo al horno que se prenda", "Pongo agua al fuego" y "por último preparo la masa". Quien prepara la masa? Yo. Esto concordaría con un self o me.

Si nos paramos a analizar el this, estaría implicando verlo desde una tercera persona, cosa que suena un poco antinatural, ¿no les parece?

Más haya de si se usa en X o Y lenguaje, creo que estaría bueno desarrollar el lenguaje pensando en lo que queremos nosotros (como vienen haciendo), utilizando nuestra experiencia como guía y no givear un fuck por otras cosas que existen o que sean convención. Arrimar el bochín para el lado del alumno me parece que garpa más.

Si bien entre las opciones disponibles self se lleva el poroto, creo que también se podrían utilizar otras palabras como myself o algún derivado.

PS: Perhaps this is a good question to add in the questionnaires that were handed at the end of the course :P.

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-168448586 .

flbulgarelli commented 8 years ago

I wrote a loooong mail explaining my criteria a week ago - spoiler alert: it is composed of 4 items, including both speech mapping AND popularity .

I will translate it and publish it into a general syntax and semantics discussion thread, alongside some paper investigation results.

matifreyre commented 8 years ago

Any news about this? I still vouch for "self" instead of "this" as being more natural. It's a necessarily self-referencing noun against a pronoun that could refer to anything.

javierfernandes commented 8 years ago

Yes. We will implement this change. Is just that the PR got old and we need to update it with new changes in the code (this replacements for self).

On Thu, Feb 4, 2016 at 10:33 AM, Matías Freyre notifications@github.com wrote:

Any news about this? I still vouch for "self" instead of "this" as being more natural. It's a necessarily self-referencing noun against a pronoun that could refer to anything.

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-179839499 .

npasserini commented 8 years ago

uuLeí ese mail y comparto en principio los 4 principios. Lo que no me parece es que estemos siendo consistentes en cuando a cómo los vamos priorizando. Acá parece priorizado

On Mon, Jan 4, 2016 at 1:22 AM, Franco Leonardo Bulgarelli < notifications@github.com> wrote:

I wrote a loooong mail explaining my criteria a week ago - spoiler alert: it is composed of 4 items, including both speech mapping AND popularity .

I will translate it and publish it into a general syntax and semantics discussion thread, alongside some paper investigation results.

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-168577348 .

npasserini commented 8 years ago

Either way, it would be nice to start a new discussion about "the 4 principles". I ve tried to found them unsuccessfully, can someone help me?

On Thu, Feb 4, 2016 at 11:17 AM, Nicolas Passerini npasserini@gmail.com wrote:

uuLeí ese mail y comparto en principio los 4 principios. Lo que no me parece es que estemos siendo consistentes en cuando a cómo los vamos priorizando. Acá parece priorizado

On Mon, Jan 4, 2016 at 1:22 AM, Franco Leonardo Bulgarelli < notifications@github.com> wrote:

I wrote a loooong mail explaining my criteria a week ago - spoiler alert: it is composed of 4 items, including both speech mapping AND popularity .

I will translate it and publish it into a general syntax and semantics discussion thread, alongside some paper investigation results.

— Reply to this email directly or view it on GitHub https://github.com/uqbar-project/wollok/issues/414#issuecomment-168577348 .