Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Object oriented programming

145 views
Skip to first unread message

Jonas Thörnvall

unread,
Jan 5, 2018, 1:25:50 PM1/5/18
to
If one where to buy a single book, that covers most aspects of object oriented programming from scratch "using Javascript".

Which book to buy.

I can see the use of object oriented programming.
For example i think i would like a midi track object, but how do you set boundaries for an object. For example that tracks can not use same channel and same out port? As i understand it an object have methods for its variables/"attributes?".

But rules for how they can be instantiated, can object oriended programming also handle such. Because that seem almost AI like, so i guess some external mechanism must check so the objects attributes do not collide?

Michael Haufe (TNO)

unread,
Jan 5, 2018, 2:51:55 PM1/5/18
to
I would say, drop the requirement of it being in JavaScript.

Perhaps the best beginners book on the feeling of OOP is: "A little Java, A Few Patterns" by Felleisen and Friedman.

<https://www.amazon.com/Little-Java-Few-Patterns-Press-ebook/dp/B004GCK2MO/ref=sr_1_1?ie=UTF8&qid=1515180547&sr=8-1&keywords=A+little+Java%2C+a+few+patterns>

It's also less than 200 pages in length.

Afterwards, follow the style of that book and try to write some basic data structures and algorithms in it.

An example of the feel:

<script>
abstract class List<T> {
abstract append(value: T): List<T>
abstract concat(list: List<T>): List<T>
abstract length(): number
abstract isEmpty(): boolean
abstract toString(): string
//etc
}
class Nil<T> extends List<T> {
append(value: T): List<T> { return new Cons(value, this); }
concat(list: List<T>): List<T> { return list.isEmpty() ? this : list }
length(): number { return 0 }
isEmpty(): boolean { return true }
toString(): string { return "[]" }
}
class Cons<T> {
constructor(readonly head: T, readonly tail: List<T>) { }
append(value: T): List<T> { return new Cons(this.head, this.tail.append(value)) }
concat(list: List<T>): List<T> {
return list.isEmpty() ? this : new Cons(this.head,this.tail.concat(list))
}
length(): number { return 1 + this.tail.length() }
isEmpty(): boolean { return false }
toString(): string { return `${this.head}::${this.tail}` }
}

var xs: List<number> = new Cons(1, new Cons(2, new Cons(3, new Nil())))
var ys: List<number> = new Nil().append(4).append(5).append(6)
var zs: List<number> = xs.concat(ys)

console.log(zs.toString()) // 1::2::3::4::5::6::[]
</script>

Julio Di Egidio

unread,
Jan 5, 2018, 3:09:39 PM1/5/18
to
On Friday, January 5, 2018 at 7:25:50 PM UTC+1, Jonas Thörnvall wrote:

> If one where to buy a single book, that covers most aspects of object
> oriented programming from scratch "using Javascript".

OO can be a language or it can be an architectural approach, just do not
confuse the two things: JS is a *functional* language (with prototypical
inheritance, which is all but OO), and while JS is so powerful a language
that it's not even difficult to implement the whole OO abstraction on top
of it, any such thing remains an aberration unless it's just for study.

That said, be aware that OO is very much overrated and actually inadequate
for most but some very specific situations. The great emphasis and hype
around OO is simply a product of some 25 years of vile speculations across
the whole software industry: outright bullshit on sale, from the fact that
OO is modular, which it least is (functional is modular), to the fact that
OO is nearest to the informal domain, which again is the exact opposite of
the truth: we mainly think functional. -- Just scratching the surface...

HTH,

Julio

Michael Haufe (TNO)

unread,
Jan 5, 2018, 4:02:09 PM1/5/18
to
Julio Di Egidio wrote:

> OO can be a language or it can be an architectural approach.

I don't think there is a difference semantically.

>, just do not
> confuse the two things: JS is a *functional* language (with prototypical
> inheritance, which is all but OO),

David Ungar would disagree, along with most of the Self community [1]

> and while JS is so powerful a language
> that it's not even difficult to implement the whole OO abstraction on top
> of it, any such thing remains an aberration unless it's just for study.

We've been through this before. JavaScript is clearly Object Oriented [2]. If you disagree, you need to define what you call "Object Oriented" then.

> That said, be aware that OO is very much overrated and actually inadequate
> for most but some very specific situations.

Overrated? Maybe. That seems to be more of a judgement of the industry than the paradigm though.

Inadequate? No more than functional programming would be. They are dual paradigms and suffer from dual limitations:

OOP: I have data but don't know the operation to apply. I have to use Subtype Polymorphism to figure it out.

FP: I have an operation, but I don't know what data to apply, so I have to use a switch or typecase construct to figure it out.

Example:

//OOP:
abstract class Shape {
abstract print(): string
}
class Circle extends Shape {
print(): string { return "Circle" }
}
class Triangle extends Shape {
print(): string { return "Triangle" }
}

myShape.print()

//FP
data Shape = Circle | Triangle

function print(s: Shape) {
switch(s) {
case s instanceof Circle: return "Circle"
case s instanceof Triangle: return "Triangle"
}
}

> The great emphasis and hype
> around OO is simply a product of some 25 years of vile speculations across
> the whole software industry: outright bullshit on sale, from the fact that
> OO is modular, which it least is (functional is modular), to the fact that
> OO is nearest to the informal domain, which again is the exact opposite of
> the truth:

Historically the industry was mostly procedural and imperative in it's programming. OOPs main sale was Encapsulation and Structured Programming. It was definitely over-hyped though and abused as a term. Alan Kay is credited for inventing the term. To quote him on the matter: "I made up the term object-oriented, and I can tell you I did not have C++ in mind."

> we mainly think functional. -- Just scratching the surface...

This is debatable. I don't know what we think closest to. I am aware of the arguments of prototypical vs classical OOP though [3] and both sides. DO you have any reference or justification for this?

[1] "SELF: THE POWER OF SIMPLICITY" <http://www.selflanguage.org/_static/published/self-power.pdf>
[2] <https://groups.google.com/d/msg/comp.lang.javascript/7yR6urAZypU/CF7Ucfj-BAAJ>
[3] "Psychological Criticism of the Prototype-Based Object-Oriented Languages" <https://web.archive.org/web/20100316225046/http://www.helsinki.fi:80/~jppesone/papers/kandi.html>

Julio Di Egidio

unread,
Jan 5, 2018, 5:38:27 PM1/5/18
to
On Friday, January 5, 2018 at 10:02:09 PM UTC+1, Michael Haufe (TNO) wrote:
> Julio Di Egidio wrote:
>
> > OO can be a language or it can be an architectural approach.
>
> I don't think there is a difference semantically.

You are simply wrong, that difference is in fact basic and quite important.
Of course, you could have asked "why is that difference important", but of
course you didn't, you rather "think".

> David Ungar would disagree, along with most of the Self community [1]

I have been debunking the whole bandwagon publicly and for years, and at
my own costs. You as most people just go with the authorities, which is
part of a now globalised problem, not any sensible objection to whatever
anybody is saying.

> Historically the industry was mostly procedural and imperative in it's
> programming. OOPs main sale was Encapsulation and Structured Programming.

Yes, a sale, as the whole thing remains unmitigated bullshit: indeed note
that OO programming is imperative itself, while structured programming
exists since the times GOSUB was invented: just to mention two immediate
things and what utter nonsense passes over that board just because some
nice guy is selling it and the rest cannot do better than parrot each other.
Overall, you literally do not know what you are talking about.

> Alan Kay is credited for inventing the term. To quote him on the matter:
> "I made up the term object-oriented, and I can tell you I did not have C++
> in mind."

Exactly, back to languages vs paradigms, but you'll deny it if it comes from
me, while you will warship it and whatever if it comes from any of the star
system gurus.

> We've been through this before.

That's right, but this is a public group and my replies are for those who
can benefit.

*Plonk*

Julio

Thomas 'PointedEars' Lahn

unread,
Jan 5, 2018, 5:47:32 PM1/5/18
to
Michael Haufe (TNO) wrote:

> On Friday, January 5, 2018 at 12:25:50 PM UTC-6, Jonas Thörnvall wrote:
>> For example i think i would like a midi track object, but how do you set
>> boundaries for an object. For example that tracks can not use same
>> channel and same out port? As i understand it an object have methods for
>> its variables/"attributes?".

Yes.

>> But rules for how they can be instantiated, can object oriended
>> programming also handle such.

Yes.

>> Because that seem almost AI like,

There is not much to it: the constructor can do the check.

>> so i guess some external mechanism must check so the objects attributes
>> do not collide?
>
> I would say, drop the requirement of it being in JavaScript.

I would not, because today all widely distributed ECMAScript implementations
that have “JavaScript” in their name support implicit setters and getters.
That has been standardized for native objects in ECMAScript Edition 5
(2009).

In this example, the setter would read from and write to a common registry,
preventing the same property of two instances to have the same value.

> <https://www.amazon.com/Little-Java-Few-Patterns-Press-ebook
^^^^
> […]
> <script>

Now I am confused :)

> abstract class List<T> {
^^^
> abstract append(value: T): List<T>
> abstract concat(list: List<T>): List<T>
> abstract length(): number
> abstract isEmpty(): boolean
> abstract toString(): string
> //etc
> }
> […]
>
> var xs: List<number> = new Cons(1, new Cons(2, new Cons(3, new Nil())))
^^^
> var ys: List<number> = new Nil().append(4).append(5).append(6)
> var zs: List<number> = xs.concat(ys)
>
> console.log(zs.toString()) // 1::2::3::4::5::6::[]

Which programming language is this?


PointedEars
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Jonas Thörnvall

unread,
Jan 5, 2018, 6:09:28 PM1/5/18
to
I start to think i may need a course in OOP, because really alot of the code i find in javascript, i have very hard time to interpretate. The language so rich and require so much preknowledge, i was never close to machine or assembly, but when your first programming language except from basic was cobol and pascal the scope of the language almost out of reach. It is guess work all the way, like this midi API, i can guess there is a listener somewhere "or is the ports listeners themself". What i get really worried about is that you can write same thing so many ways, i have kind of teflon memory so that is quite annoying it is hard to read code and see the plan of OOP when you come out of JSP and structural programming. Also i noticed in the JS files there is no init so to speak, just some weird syntax beyond my comprehension.

The JS file "midiprogramming" i have used as example for my little midi project started like this.

var context = new AudioContext(),
oscillators = {};
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}

There is so much implecit like contructs i understand it is an audio object.
But a code like oscillators = {}, what is that even supposed to mean?

What is navigator and requestMidiAccess are they part of the AudioContext object,is midi access a method?

Well it is all very confusing to me, and i guess you can not figure out the above by reading an OOP book, or?


Michael Haufe (TNO)

unread,
Jan 5, 2018, 6:16:04 PM1/5/18
to
Thomas 'PointedEars' Lahn wrote:
> Michael Haufe (TNO) wrote:

> > I would say, drop the requirement of it being in JavaScript.
>
> I would not, because today all widely distributed ECMAScript implementations
> that have “JavaScript” in their name support implicit setters and getters.
> That has been standardized for native objects in ECMAScript Edition 5
> (2009).

The reason I said drop the requirement was to prevent the OP from unnecessarily restricting what books he could read on the subject.

> > <https://www.amazon.com/Little-Java-Few-Patterns-Press-ebook
> ^^^^
> Now I am confused :)

If you know a better book on the topic for JavaScript specifically, I'm all ears. But the "Elephant Books" are very hard to beat due to their brevity [1]

[...]

> Which programming language is this?

Apologies. It is TypeScript. I meant to specify, but forgot.


[1] <https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=Daniel+Friedman+and+Matthias+Felleisen&rh=i%3Aaps%2Ck%3ADaniel+Friedman+and+Matthias+Felleisen>

Jonas Thörnvall

unread,
Jan 5, 2018, 6:21:25 PM1/5/18
to
It is kind of scary when you can't "understand" and interpretate code to try to adjust/fiddle it.

Like this
for (input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;

}
It somehow reads in all input ports in a loop, and then suddenly ***bang*** it some sort of listener picking up midi messages? This code listens to all ports "omni", but i do not see what open all the ports? If i just wanted to listen to one?

And here is am totally lost input.value.onmidimessage = onMIDIMessage;

onMIDIMessage is a function? But why is there no parentheses and what is input.value.omnimidimessage? And why is there a equal sign between, to me it must be parameters? I just don't get the syntax so all become a hack.


Jonas Thörnvall

unread,
Jan 5, 2018, 6:27:51 PM1/5/18
to
I understand arrays and string handling using functions it is straightforward, sometimes i understand the implementation of the listeners within code, but most times the code looks really confusing i must say.

Michael Haufe (TNO)

unread,
Jan 5, 2018, 6:29:51 PM1/5/18
to
Julio Di Egidio wrote:
> Michael Haufe (TNO) wrote:
> > Julio Di Egidio wrote:
> >
> > > OO can be a language or it can be an architectural approach.
> >
> > I don't think there is a difference semantically.
>
> You are simply wrong, that difference is in fact basic and quite important.
> Of course, you could have asked "why is that difference important", but of
> course you didn't, you rather "think".

Somebody has to think. If you won't, than I will...

I've asked you to justify your claims more than once in the past, and I'm still waiting. I may be a masochist for this, but I do have limits.

> > David Ungar would disagree, along with most of the Self community [1]
>
> I have been debunking the whole bandwagon publicly and for years, and at
> my own costs.

Reference please.

> You as most people just go with the authorities, which is
> part of a now globalised problem, not any sensible objection to whatever
> anybody is saying.

Not simply "just", but generally yes. Some "authorities" are more equal than others. Ungar is not a lesser mortal in this field, so what *exactly* are you objecting to?

> > Historically the industry was mostly procedural and imperative in it's
> > programming. OOPs main sale was Encapsulation and Structured Programming.
>
> Yes, a sale, as the whole thing remains unmitigated bullshit: indeed note
> that OO programming is imperative itself,

Most, not all. My List implementation is not. Can you see the difference?

> > Alan Kay is credited for inventing the term. To quote him on the matter:
> > "I made up the term object-oriented, and I can tell you I did not have C++
> > in mind."
>
> Exactly, back to languages vs paradigms, but you'll deny it if it comes from
> me, while you will warship it and whatever if it comes from any of the star
> system gurus.

Why the assumption that languages and paradigms have to be separable and in conflict?

> > We've been through this before.
>
> That's right, but this is a public group and my replies are for those who
> can benefit.

Still not sure who benefits. It still looks vacuous to me.

Jonas Thörnvall

unread,
Jan 5, 2018, 6:49:28 PM1/5/18
to
Here is the midicode i hacked together so far but probably i do unecessary things, and maybe create objects that i am not even aware about.

Basicly i read midi in and out ports into select list adn create options. And have field to set/write program for each midichannel in an optionlist.

Probably i would want an object "track" that hold both channel and program and that also take care of the midi in port messages my keyboard send and forward to the midi out module.

In a sequenser one probably also want the object to also have a timecode with each message.

But it gets confusing is the track the object holding messages in a object? "if there is such"

I can probably make a sequenser oldschool by starting a timer and set timecodes on the messages, and store them as strings in an array and it will work. But it will be a hack?

var context = new AudioContext(),
oscillators = {};

outportindex=10;
programC=16;
channelC=1;
NOTE_ON=0x90;
NOTE_OFF=0x80;

function midiInit(){

if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess()
.then(success, failure);
}

}

function failure () {
console.error('No access to your midi devices.'+ + msg )
}

function onMIDISuccess( midiAccess ) {
console.log( "MIDI ready!" );
var input = midiAccess.inputs.entries.next();
if (input)
input.onmidimessage = echoMIDIMessage;
output = midiAccess.outputs.values().next().value;
if (!input || !output)
console.log("Uh oh! Couldn't get i/o ports.");
}

function success (midi) {
mid=midi;
inputs = midi.inputs.values();
outputs = midi.outputs.values();
// inputs outputs are Iterators
for (output = outputs.next(); output && !output.done; output = outputs.next()) {
var deviceOut = output.value.name;
console.log(deviceOut);
var optout = document.createElement("option");
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);

}
for (input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;

}
document.getElementById("out_portsel").selectedIndex=outportindex;
changeProgram();
}



function echoMIDIMessage( event ) {
if (output) {
output.send( event.data, event.timestamp );
}
}

function changeMidiChannel(){
console.log("Change MIDI channel");
channelC=document.getElementById("out_channel").selectedIndex+1;
console.log("channel ",channelC);
if (channelC==1) {NOTE_ON=0xC0}
else if (channelC==1) {NOTE_ON=0x90; NOTE_OFF=0x80;}
else if (channelC==2) {NOTE_ON=0x91; NOTE_OFF=0x81;}
else if (channelC==3) {NOTE_ON=0x92;NOTE_OFF=0x82;}
else if (channelC==4) {NOTE_ON=0x93;NOTE_OFF=0x83;}
else if (channelC==5) {NOTE_ON=0x94;NOTE_OFF=0x84;}
else if (channelC==6) {NOTE_ON=0x95;NOTE_OFF=0x85;}
else if (channelC==7) {NOTE_ON=0x96;NOTE_OFF=0x86;}
else if (channelC==8) {NOTE_ON=0x97;NOTE_OFF=0x87;}
else if (channelC==9) {NOTE_ON=0x98;NOTE_OFF=0x88;}
else if (channelC==10) {NOTE_ON=0x99;NOTE_OFF=0x89;}
else if (channelC==11) {NOTE_ON=0xA0;NOTE_OFF=0x8A;}
else if (channelC==12) {NOTE_ON=0xA1;NOTE_OFF=0x8B;}
else if (channelC==13) {NOTE_ON=0xA2;NOTE_OFF=0x8C;}
else if (channelC==14) {NOTE_ON=0xA3;NOTE_OFF=0x8D;}
else if (channelC==15) {NOTE_ON=0xA4;NOTE_OFF=0x8E;}
else if (channelC==16) {NOTE_ON=0xA5;NOTE_OFF=0x8F;}
output = mid.outputs.get(outportindex);
console.log("Channel ",NOTE_ON," program ",programC);
}

function midiToOutPort(message){
console.log(message.data[1]);
output = mid.outputs.get(outportindex);
console.log("Messag type",message.data[0]);
if(message.data[0]==144 && channelC!=1){message.data[0]=NOTE_ON;}
if(message.data[0]==128 && channelC!=1){message.data[0]=NOTE_OFF;}
console.log("Messag type",message.data[0]);
var noteOnMessage = [message.data[0], message.data[1], message.data[2]];
output.send( noteOnMessage );

}


function changeProgram(){
console.log("Change program");
sysexC=192+channelC-1;
programC=document.getElementById("prog_sel").value
output = mid.outputs.get(outportindex);
var programChange = [sysexC,programC];
output.send(programChange );
}


function changeOutPort(){
//outportindex = document.getElementById("out_portsel").value;
outportindex=document.getElementById("out_portsel").selectedIndex;
console.log("selected index "+outportindex);
}

function onMIDIMessage (message) {
midiToOutPort(message);
//synth(message);
}

Jonas Thörnvall

unread,
Jan 6, 2018, 5:23:16 AM1/6/18
to
I finally find a tutorial that explain somewhat what is going on.

https://code.tutsplus.com/tutorials/introduction-to-web-midi--cms-25220

But it is very vague, for example.

In order to get the input data from our device, we first create a variable and assign it midi.inputs.values() like so.


var inputs = midi.inputs.values();

Is midi.input.values(); a function or a method? How do i know the difference?
midi is an object?
input an attribute of that object?
values a property of input?

I even lost on the terminology here.

But if it is a function/method why the **fuc** are the brackets at the values?
I get that the **thing** is assigned to a variable inputs.

These so called built in methods/function is there no specification on what they return. I also wondered why some functions called properties, is it because they do not do anything with the ***thing***. Take length i mean it do something it count the objects of the array? If you knew to javascript how the fuck are you supposed to see it is a function that return number of elements of an array?

I do understand that alot is design decisions coming out of some model?
But it make it cumbersome to read due to semantics, or do the semantics carry meaning?

var arr3 = arr1.concat(arr2);

I mean what the fuck is this i don't see the point? why not
var arr3=concat(arr1,arr2);

I mean the above i get that arr2 is a parameter and concat is a method/function please explain the difference.

But what the fuck is arr1.concat supposed to mean?
To me it seem to say that arr1 "arrays" have a method i that correct?

Also they call it Array.prototype.concat()
What the fuck is prototype supposed to mean in this linguistic mishmash? I see it used but i never fully understood what a prototype is?

If this convoluted semantics really needed? why isn't it then explicit in the language so people by eyeballing the code can see what is an array a method when you stuck things together like

full.confusion.inmypants=getIt

input.value.onmidimessage = onMIDIMessage;

how the fuck am i supposed to interpretate that one by eyeball it, there is no clue to tell what is a variable or method or prototype or function? But it does not matter because getIt will call a function but you can't fucking see it? If you do not know the full language every built in method how can you know?

Just tell me how could you learn an AI to understand that language, without you let it know every

my.balls=jump

input.onmidimessage = echoMIDIMessage;

It can't be the meaning that you must know every command, method and built in objects "implicit" within the language to be able to understand code when you read it?

I am all far that a variable name that the programmer define can hold what the fuck ever, "because then somewhere in the code you can find it". But when there is built in objects and methods hidden in a noneexplicit semantics. It does not fucking tell what it is, how can i figure it out by just eyeball?

my.balls=jump

I can't track down the meaning within the code?


Julio Di Egidio

unread,
Jan 6, 2018, 6:25:13 AM1/6/18
to
On Saturday, January 6, 2018 at 11:23:16 AM UTC+1, Jonas Thörnvall wrote:
<snip>
> var inputs = midi.inputs.values();
>
> Is midi.input.values(); a function or a method?

There are no methods in JS, only functions, in fact closures.
Then there are objects with properties, not attributes.

Those properties, just like variables, can hold any value, including
references to functions (again, to closures), e.g.:

myobj.func = function () { return dosomething(); };

> How do i know the difference?

RTFM? JS is notoriously the world's most misunderstood programming language
ever, OTOH a language spec as well as some good enough tutorials are not
that difficult to find really:

<https://developer.mozilla.org/bm/docs/Web/JavaScript>

> my.balls=jump
>
> I can't track down the meaning within the code?

You cannot track the meaning of anything in that sense, i.e. by just
considering the rules of the language: readability (which includes
readable meaningfulness), just as correctness, is something we *strive*
for...

Julio

Jonas Thörnvall

unread,
Jan 6, 2018, 6:39:55 AM1/6/18
to
But should one not be able to differentiate a function from a variable or from a listener. A value allocation from a function call?

Is this a value allocation or a function call.

my.balls=jump;

Jonas Thörnvall

unread,
Jan 6, 2018, 6:40:02 AM1/6/18
to
To get a little deeper in my understanding deficiency when it come to object oriented programming. Here is a function with a loop "well now two loops" i basicly just copied the in code two get the outports because original there was monophonic synth, and no output ports.

So script get out and in ports "i have zero idea how they stored" but they come from in inputs/outputs in a loop.
So it is just a loop through get the names of each? "Well that was what i was thinking". Until i saw this "from the original example code"

// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;

Here i got confused how can there be a midi message "listener?" within a loop.
But one just have to accept there is no way to understand this? But why in loop i am clueless, so i just string somecode together to list the ports list them in a select option list. And somehow "input.value.onmidimessage=onMidiMessage;
in ***A SAIN WORLD*** would be onMIDIMessage(input.valueonmidimessage);

Because otherwise i fucking can not understand where function onMIDIMessage (message) {} come from?

But in a sain world that function/method call would not be in a loop "that is not my code", i just do not get it? "If you don't understand don't change it"

And it is kind of strange it just loop thru the port ones, never more and then it just *listen*? for messages within loop?

Well whatever...
Well i figured out that send midi messages yourself was fairly easy like "program and channel change".
output.send( );

There is more insane thing in the code like this function it is never called "what i can see" but that is the active code that echo the midimessages. Where is the function call????

I can see the call to the success function but to onMIDISuccess there is never any call but yet the function executed how?

Can someone please explain how things string together...

Julio Di Egidio

unread,
Jan 6, 2018, 7:24:40 AM1/6/18
to
On Saturday, January 6, 2018 at 12:40:02 PM UTC+1, Jonas Thörnvall wrote:

> in ***A SAIN WORLD*** would be
> onMIDIMessage(input.valueonmidimessage);

That's just meaningless. Indeed, in a sane world you'd be learning how
to program, not just spamming the Usenet.

*Plonk*

Julio

Julio Di Egidio

unread,
Jan 6, 2018, 7:24:58 AM1/6/18
to
On Saturday, January 6, 2018 at 12:39:55 PM UTC+1, Jonas Thörnvall wrote:
> Den lördag 6 januari 2018 kl. 12:25:13 UTC+1 skrev Julio Di Egidio:
> > On Saturday, January 6, 2018 at 11:23:16 AM UTC+1, Jonas Thörnvall wrote:
> > <snip>
> > > var inputs = midi.inputs.values();
> > >
> > > Is midi.input.values(); a function or a method?
> >
> > There are no methods in JS, only functions, in fact closures.
> > Then there are objects with properties, not attributes.
> >
> > Those properties, just like variables, can hold any value, including
> > references to functions (again, to closures), e.g.:
> >
> > myobj.func = function () { return dosomething(); };
> >
> > > How do i know the difference?
> >
> > RTFM? JS is notoriously the world's most misunderstood programming language
> > ever, OTOH a language spec as well as some good enough tutorials are not
> > that difficult to find really:
> >
> > <https://developer.mozilla.org/bm/docs/Web/JavaScript>
> >
> > > my.balls=jump
> > >
> > > I can't track down the meaning within the code?
> >
> > You cannot track the meaning of anything in that sense, i.e. by just
> > considering the rules of the language: readability (which includes
> > readable meaningfulness), just as correctness, is something we *strive*
> > for...
>
> But should one not be able to differentiate a function from a variable or
> from a listener. A value allocation from a function call?

Not just by the name unless the programmer is using proper conventions, and
even then one should be careful when reviewing code, as generally very few
programmers can write decent code, but even the good programmers make
mistakes and are subject to fatigue.

> Is this a value allocation or a function call.
>
> my.balls=jump;

That is an *assignment*, dumbass. RTFM.

*Plonk*

Julio

Jonas Thörnvall

unread,
Jan 6, 2018, 8:26:27 AM1/6/18
to
Really?????? Are you sure then why the fuck are there functions that never been called using those names?

input.onmidimessage = echoMIDIMessage;
input.value.onmidimessage = onMIDIMessage;


If so why are there functions with those names?

function onMIDIMessage (message) {
midiToOutPort(message);
}

function echoMIDIMessage( event ) {
if (output) {
output.send( event.data, event.timestamp );
}
}


eatmy.balls=dumbass

Jonas Thörnvall

unread,
Jan 6, 2018, 8:28:50 AM1/6/18
to
Since you say they are assignments and not function calls, what are they doing?
input.onmidimessage = echoMIDIMessage;
input.value.onmidimessage = onMIDIMessage;
eatmy.balls=dumbass;

Jonas Thörnvall

unread,
Jan 6, 2018, 8:34:50 AM1/6/18
to
Are you telling me echoMIDIMessage and onMIDIMessage are variables? If so where the fuck did they come from? And why would you assign a null variable to an input port? Or are they functions assigned to a port.

You said they are assignments YES or NO?

Jonas Thörnvall

unread,
Jan 6, 2018, 9:08:28 AM1/6/18
to
Here is something relatable? OR?
But how the fuck am one supposed to guess that input is an object and onmidimessage an event attached to the object, and that onMIDIMessage is a function that will be called at the event onmidimessage by looking at it?
It is insane semantics, isn't it?

But it fucking get worse....
input.value.onmidimessage = onMIDIMessage;

Uuuuuuh what the fuck is value here?
I can't even guess that even though i have an example below, of an event upon an object trigger a function?

And why the fuck is the order object.event=function the linguistics of the shit you put together is so convoluted stupid in semantics one want to throw up on the shit, the only thing you managed to get right is string and array handling in javascript.

Of course it must be
ON punch OBJECT dumbass CALL out

Now you see i managed to get semantics that include it is
1. EVENT using ON and its name
2. OBJECT and its name
3. CALL a function or if you send parameters you can leave out CALL and use brackets.

Now we compare which is more readable

dumbass.punch=out

or

ON punch OBJECT dumbass CALL out


But the real dumbass prefer the punch to be an assigment.








As the other said you should assign a function.

Just wanted to point out that in this case you want to pass a value so you need to assign an anonymous function (or a named function defined inline) like

button.onclick = function() {otherfunction(parameter)};
If the function you want to assign does NOT require a parameter you can use it directly

button.onclick = otherfunction;
Note that there is no parenthesis in this case

button.onclick = otherfunction(); // this doesn't work
won't work as it will call otherfunction as soon as it is parsed

John G Harris

unread,
Jan 6, 2018, 9:11:06 AM1/6/18
to
On Fri, 5 Jan 2018 13:01:57 -0800 (PST), "Michael Haufe (TNO)"
<t...@thenewobjective.com> wrote:

Regarding this :

<snip>
>I am aware of the arguments of prototypical vs classical OOP though [3] and both sides.
<snip>

Note that in this paper :
>[3] "Psychological Criticism of the Prototype-Based Object-Oriented Languages" <https://web.archive.org/web/20100316225046/http://www.helsinki.fi:80/~jppesone/papers/kandi.html>

a prototypal language is defined as one where a new object can only be
created by cloning another object. This is most definitely not
ECMAScript.

John

John G Harris

unread,
Jan 6, 2018, 9:21:21 AM1/6/18
to
On Sat, 6 Jan 2018 03:25:03 -0800 (PST), Julio Di Egidio
<ju...@diegidio.name> wrote:

<snip>
>Those properties, just like variables, can hold any value, including
>references to functions
<snip>

No. The value of a Java variable can be a reference. The value of an
ECMAScript variable cannot. Nor can the value of an ECMAScript
property. As we used to tell newbies in the days of Netscape Navigator
Java != JavaScript

John

Jonas Thörnvall

unread,
Jan 6, 2018, 9:27:19 AM1/6/18
to
I mean it can't be you are such fucking intelligent that writing out the words is the more time consuming part of programming. Isn't it fucking better to go for readability of the code, then go all in ***HIDING THE PROPERTIES OF THE PROGRAMMING LANGUAGE*** using nonsense syntax that save letters?

Are you fucking going back to Perl, is that the mission making a new EMACS?
Or is it fucking about selling books? What is the fucking mission behind nonsense syntax, is it getting to easy to program for none anal personas with ideas? Are you going back to the fucking cult of memorise blip, blop semantics now when you no longer can justify programming in assembler and machinelanguages. You trying to develop a high order programming language that look like blip blop programming, so people can't fucking read what you write?

Jonas Thörnvall

unread,
Jan 6, 2018, 9:36:23 AM1/6/18
to
If it is about saving fucking place and a few Kbytes here and there have a fucking parser deal with it buy you fucking can't hide what is an object a event a variable and expect people will guess the shit its insane.

Fucking build a blip blop parser for those inclined to anal workflow using blip blops, and give the intelligent people a working tool where you do not have to read the full script to figure out what is taking place.

go.eat=shit

Yeah that make sense

Jonas Thörnvall

unread,
Jan 6, 2018, 10:34:49 AM1/6/18
to
Well i go back to program now but i can only conclude that the people behind ECMA script created a syntax and semantics of the coding language that is ambiguous that mean it is not possible to generalise into a parser without knowing ***every*** built in object and event names. The idiots built a syntax around names of objects bwhahahaha rather then conceptualisation around different programming structures.

When you see the command ***buttfucked*** in script then look up closest EMAC manual to find out if it was an event, a function call, a method or it could have been a variable assignment. Don't forget you will need the EMAC manual again if you want to buttfuck some other programmers trying to read your code.

To these people things like A.B=C have meaning they instinctly know that A is an object and B is the event and C is the function that will be called. Because when you eat ass all night, you stop to questioning things you just memorise what they feed you, that way there is no problem to accept idiocies.

Ben Bacarisse

unread,
Jan 6, 2018, 12:42:32 PM1/6/18
to
Julio Di Egidio <ju...@diegidio.name> writes:

> On Saturday, January 6, 2018 at 11:23:16 AM UTC+1, Jonas Thörnvall wrote:
> <snip>
>> var inputs = midi.inputs.values();
>>
>> Is midi.input.values(); a function or a method?
>
> There are no methods in JS, only functions, in fact closures.

From section 4.2 of the ECMA 262 language specification:

"A function that is associated with an object via a property is called
a method."

(in all the editions I've so far checked from 5.1 to 8).

> ... OTOH a language spec as well as some good enough tutorials are not
> that difficult to find really:
>
> <https://developer.mozilla.org/bm/docs/Web/JavaScript>

This site, too, talks about methods.

--
Ben.

Michael Haufe (TNO)

unread,
Jan 6, 2018, 12:56:11 PM1/6/18
to
On Saturday, January 6, 2018 at 8:36:23 AM UTC-6, Jonas Thörnvall wrote:
> Den lördag 6 januari 2018 kl. 15:27:19 UTC+1 skrev Jonas Thörnvall:
> > Den lördag 6 januari 2018 kl. 15:08:28 UTC+1 skrev Jonas Thörnvall:
> > > Den lördag 6 januari 2018 kl. 14:34:50 UTC+1 skrev Jonas Thörnvall:
> > > > Den lördag 6 januari 2018 kl. 14:28:50 UTC+1 skrev Jonas Thörnvall:
> > > > > Den lördag 6 januari 2018 kl. 14:26:27 UTC+1 skrev Jonas Thörnvall:
> > > > > > Den lördag 6 januari 2018 kl. 13:24:58 UTC+1 skrev Julio Di Egidio:
> > > > > > > On Saturday, January 6, 2018 at 12:39:55 PM UTC+1, Jonas Thörnvall wrote:
> > > > > > > > Den lördag 6 januari 2018 kl. 12:25:13 UTC+1 skrev Julio Di Egidio:
> > > > > > > > > On Saturday, January 6, 2018 at 11:23:16 AM UTC+1, Jonas Thörnvall wrote:

[...]

Holy bloated headers batman

Julio Di Egidio

unread,
Jan 6, 2018, 2:47:52 PM1/6/18
to
On Saturday, January 6, 2018 at 6:42:32 PM UTC+1, Ben Bacarisse wrote:
> Julio Di Egidio <ju...@diegidio.name> writes:
> > On Saturday, January 6, 2018 at 11:23:16 AM UTC+1, Jonas Thörnvall wrote:
> > <snip>
> >> var inputs = midi.inputs.values();
> >>
> >> Is midi.input.values(); a function or a method?
> >
> > There are no methods in JS, only functions, in fact closures.
>
> From section 4.2 of the ECMA 262 language specification:
>
> "A function that is associated with an object via a property is called
> a method."
>
> (in all the editions I've so far checked from 5.1 to 8).

The magic of words and the total cluelessness...

It calls it a "method" just because its a *SLOPPY* fucking standard, mainly
thought for the clueless "web programmer", which was a very stupid move
indeed already at the time, but now the computer scientists are getting
programming jobs without knowing the first thing about programming, and
are completely fucking lost, on words.

Read this, I have not written it: <https://stackoverflow.com/a/18402468>

> > ... OTOH a language spec as well as some good enough tutorials are not
> > that difficult to find really:
> >
> > <https://developer.mozilla.org/bm/docs/Web/JavaScript>
>
> This site, too, talks about methods.

It also calls JS an OO language on the very front page, which is why I said
"good enough".

Now keep lying.

*Plonk*

Julio

Christoph M. Becker

unread,
Jan 6, 2018, 4:11:22 PM1/6/18
to
On 06.01.2018 at 20:47, Julio Di Egidio wrote:

> On Saturday, January 6, 2018 at 6:42:32 PM UTC+1, Ben Bacarisse wrote:
>
>> Julio Di Egidio <ju...@diegidio.name> writes:
>>
>>> There are no methods in JS, only functions, in fact closures.
>>
>> From section 4.2 of the ECMA 262 language specification:
>>
>> "A function that is associated with an object via a property is called
>> a method."
>>
>> (in all the editions I've so far checked from 5.1 to 8).
>
> The magic of words and the total cluelessness...
>
> Read this, I have not written it: <https://stackoverflow.com/a/18402468>

Interestingly, this SO answer points to its authors blog[1], where he
writes:

| Note: As of ES2015, JavaScript arguably got methods (and that is the
| term the spec uses) via a new notation on object initializers and via
| the class syntax. This article predates ES2015 and refers to
| non-method properties on prototypes, created with the function keyword
| (the new method syntax doesn't use the function keyword).

[1] <http://blog.niftysnippets.org/2008/03/mythical-methods.html>

--
Christoph M. Becker

Julio Di Egidio

unread,
Jan 6, 2018, 4:28:43 PM1/6/18
to
On Saturday, January 6, 2018 at 10:11:22 PM UTC+1, Christoph M. Becker wrote:
> On 06.01.2018 at 20:47, Julio Di Egidio wrote:
> > On Saturday, January 6, 2018 at 6:42:32 PM UTC+1, Ben Bacarisse wrote:
> >
> >> Julio Di Egidio <ju...@diegidio.name> writes:
> >>
> >>> There are no methods in JS, only functions, in fact closures.
> >>
> >> From section 4.2 of the ECMA 262 language specification:
> >>
> >> "A function that is associated with an object via a property is called
> >> a method."
> >>
> >> (in all the editions I've so far checked from 5.1 to 8).
> >
> > The magic of words and the total cluelessness...

[It calls it a "method" just because its a *SLOPPY* fucking standard...]

> > Read this, I have not written it: <https://stackoverflow.com/a/18402468>
>
> Interestingly, this SO answer points to its authors blog[1], where he
> writes:
>
> | Note: As of ES2015, JavaScript arguably got methods

Was that the point? Should I find another "third-party" blog entry about
how the new standard is even worse than what we had? Indeed, instead of
fixing it, they have been making it worse, and just in order to please "the
community" and the very bias towards object orientation. Marketers. JS the
most abused and misunderstood language ever. And it's a shame, as, besides
the ubiquity, it's fundamentally a wonderful language...

Julio

Michael Haufe (TNO)

unread,
Jan 7, 2018, 2:54:26 AM1/7/18
to
John G Harris wrote:
> "Michael Haufe (TNO)" wrote:
>
> Regarding this :
>
> <snip>
> >I am aware of the arguments of prototypical vs classical OOP though [3] and both sides.
> <snip>
>
> Note that in this paper :
> >[3] "Psychological Criticism of the Prototype-Based Object-Oriented Languages" <https://web.archive.org/web/20100316225046/http://www.helsinki.fi:80/~jppesone/papers/kandi.html>
>
> a prototypal language is defined as one where a new object can only be
> created by cloning another object. This is most definitely not
> ECMAScript.

A distinction that doesn't make a difference. ECMAScript has a superset of that behavior being multi-paradigm:

let newObject = Object.create(oldObject)

Christoph M. Becker

unread,
Jan 7, 2018, 6:40:36 AM1/7/18
to
I agree that functional programming in ECMAScript implementations is
still underrated, and I understand why some prefer and advocate
functional programming over object oriented programming. However, that
does not mean that these languages are not object-oriented, even though
it is possible to program non-trivial and even complex algorithms
without applying the object-oriented paradigm (most notably, mutation of
object state). One may even argue that ECMAScript has no first-class
functions, since functions are nothing more than callable objects.

With regard to function vs. method: as I see it, this distinction is
useful in these languages, but not so much as specified by Ecma ("A
function that is associated with an object via a property is called a
method."), but rather when referring to the possibility that the
function/method uses the implicit `this` reference. Along these lines,
`Array.prototype.map` would be a method, but `R.map`[1] would be a function.

BTW: I would suggest to avoid explicit language, at least in public
discussions. :)

[1] <http://ramdajs.com/docs/#map>

--
Christoph M. Becker

Evertjan.

unread,
Jan 7, 2018, 7:01:40 AM1/7/18
to
"Christoph M. Becker" <cmbec...@arcor.de> wrote on 07 Jan 2018 in
comp.lang.javascript:

> With regard to function vs. method: as I see it, this distinction is
> useful in these languages, but not so much as specified by Ecma ("A
> function that is associated with an object via a property is called a
> method."), but rather when referring to the possibility that the
> function/method uses the implicit `this` reference. Along these lines,
> `Array.prototype.map` would be a method, but `R.map`[1] would be a
> function.

Isn't any function [also] a method of an object?

... where 'this' just points to a default input-parameter?

window.a = 3;
function f() {return this.a};
console.log(window.f()); // 3

compared to:

window.a = 3;
function f(ob) {return ob.a};
console.log(f(window)); // 3

======

Originally, a function was a [sub]routine that returned a value,
so that it could be used inside a mathematical formula.

The functionality of the function seems to have been expanded beond measure.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

John G Harris

unread,
Jan 7, 2018, 9:05:32 AM1/7/18
to
On Sat, 6 Jan 2018 11:47:41 -0800 (PST), Julio Di Egidio
<ju...@diegidio.name> wrote:

>On Saturday, January 6, 2018 at 6:42:32 PM UTC+1, Ben Bacarisse wrote:

<snip>
>> "A function that is associated with an object via a property is called
>> a method."
>>
>> (in all the editions I've so far checked from 5.1 to 8).
>
>The magic of words and the total cluelessness...
>
>It calls it a "method" just because its a *SLOPPY* fucking standard, mainly
>thought for the clueless "web programmer", which was a very stupid move
>indeed already at the time, but now the computer scientists are getting
>programming jobs without knowing the first thing about programming, and
>are completely fucking lost, on words.
<snip>

Stop being a twerp. An International Standard can define "method" to
mean anything it wants it to mean, *within* the standard.

If you ever read a non-trivial maths textbook you'll notice that
professional mathematicians often define words with only local scope.
The idea of names having local scope is useful and is sometimes used
in Computer Science.

John

John G Harris

unread,
Jan 7, 2018, 9:13:34 AM1/7/18
to
Eh? oldObject is the prototype object of newObject.

newObject and oldObject have different prototype objects; newObject
can't be a clone of oldObject.

John

Christoph M. Becker

unread,
Jan 7, 2018, 9:26:25 AM1/7/18
to
You may prefer

let newObject = Object.assign({}, oldObject);

--
Christoph M. Becker

Julio Di Egidio

unread,
Jan 7, 2018, 11:30:33 AM1/7/18
to
On Sunday, January 7, 2018 at 12:40:36 PM UTC+1, Christoph M. Becker wrote:
> On 06.01.2018 at 22:28, Julio Di Egidio wrote:
> > On Saturday, January 6, 2018 at 10:11:22 PM UTC+1, Christoph M. Becker wrote:
> >
> >> | Note: As of ES2015, JavaScript arguably got methods
> >
> > Was that the point? Should I find another "third-party" blog entry about
> > how the new standard is even worse than what we had? Indeed, instead of
> > fixing it, they have been making it worse, and just in order to please "the
> > community" and the very bias towards object orientation. Marketers. JS the
> > most abused and misunderstood language ever. And it's a shame, as, besides
> > the ubiquity, it's fundamentally a wonderful language...
>
> I agree that functional programming in ECMAScript implementations is
> still underrated,

As a matter of fact, that's exactly upside down: JS is *born* functional.

> and I understand why some prefer and advocate
> functional programming over object oriented programming.

That is not my point, use the right tool for the right job: OO is just fine,
where it is appropriate.

> However, that
> does not mean that these languages are not object-oriented, even though
> it is possible to program non-trivial and even complex algorithms
> without applying the object-oriented paradigm (most notably, mutation of
> object state). One may even argue that ECMAScript has no first-class
> functions, since functions are nothing more than callable objects.
<snip>

Of course one can, it remains nonsense on the whole line.

> BTW: I would suggest to avoid explicit language, at least in public
> discussions. :)

Please stick political correctness where it doesn't shine. What is truly
horrifying is not so much the fucking criminal retarded cunts who run this
planet, but rather the intelligent people like you who will just never do
the right thing ever...

Julio

Julio Di Egidio

unread,
Jan 7, 2018, 11:33:39 AM1/7/18
to
On Sunday, January 7, 2018 at 3:05:32 PM UTC+1, John G Harris wrote:
> On Sat, 6 Jan 2018 11:47:41 -0800 (PST), Julio Di Egidio
> <ju...@diegidio.name> wrote:
> >On Saturday, January 6, 2018 at 6:42:32 PM UTC+1, Ben Bacarisse wrote:
> <snip>
> >> "A function that is associated with an object via a property is called
> >> a method."
> >>
> >> (in all the editions I've so far checked from 5.1 to 8).
> >
> >The magic of words and the total cluelessness...
> >
> >It calls it a "method" just because its a *SLOPPY* fucking standard, mainly
> >thought for the clueless "web programmer", which was a very stupid move
> >indeed already at the time, but now the computer scientists are getting
> >programming jobs without knowing the first thing about programming, and
> >are completely fucking lost, on words.
> <snip>
>
> Stop being a twerp.

Stop being a liar.

> An International Standard can define "method" to
> mean anything it wants it to mean, *within* the standard.

Yes and no: they could have said, even just in a side note, "we'll call
these methods henceforth, but please don't trip over it". That's not what
they have been doing, in fact the opposite of it.

Julio

Christoph M. Becker

unread,
Jan 7, 2018, 1:43:20 PM1/7/18
to
On 07.01.2018 at 13:01, Evertjan. wrote:

> Isn't any function [also] a method of an object?

If you mean that every function is assigned to a property of some (user
visible) object, that is not the case. Consider anonymous functions,
for instance.

--
Christoph M. Becker

Evertjan.

unread,
Jan 7, 2018, 2:34:07 PM1/7/18
to
"Christoph M. Becker" <cmbec...@arcor.de> wrote on 07 Jan 2018 in
comp.lang.javascript:

> On 07.01.2018 at 13:01, Evertjan. wrote:
>
>> Isn't any function [also] a method of an object?
>
> If you mean that every function is assigned to a property of some (user
> visible) object, that is not the case.

Not 'is' but 'can be',
and not 'to' a 'property'
but 'to' an object 'as' a 'method'.

Well, you could view a method to be an active property.

I hope ;-(

> Consider anonymous functions, for instance.

Right, I didn't.

I now will consider them to be a clever trick.

Thomas 'PointedEars' Lahn

unread,
Jan 7, 2018, 9:08:25 PM1/7/18
to
Michael Haufe (TNO) wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Which programming language is this?
>
> Apologies. It is TypeScript. I meant to specify, but forgot.

I figured it might be an ECMAScript Ed. 4 Proposal implementation because
of “class”, “var”, and “:”, but the generics looked like Java to me.
I understand now that TypeScript also supports that.

ACK to the rest.

Happy New Year!

--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

John G Harris

unread,
Jan 8, 2018, 4:39:37 AM1/8/18
to
Um. Object.assign doesn't copy non-enumerable properties, prototype,
or internal slots. It's a restricted clone operation. For instance, it
won't clone an Array object.

If you wanted to do some prototypal-style programming I think you'd be
better off using a constructor :
newObject = new Prototypal(oldObject);
where the constructor uses Object.assign to copy the enumerable
properties of oldObject.

This would be neat and make it obvious when you are being prototypal,
provided you don't want to play games with property attributes,
ECMAScript-prototype inheritance (obviously you wouldn't), or internal
slots.

John

John G Harris

unread,
Jan 8, 2018, 4:46:43 AM1/8/18
to
On Sun, 7 Jan 2018 08:33:31 -0800 (PST), Julio Di Egidio
<ju...@diegidio.name> wrote:

>On Sunday, January 7, 2018 at 3:05:32 PM UTC+1, John G Harris wrote:

<snip>
>> An International Standard can define "method" to
>> mean anything it wants it to mean, *within* the standard.
>
>Yes and no: they could have said, even just in a side note, "we'll call
>these methods henceforth, but please don't trip over it". That's not what
>they have been doing, in fact the opposite of it.

You will of course now add a note to the Wikipedia entry on Method
(computer programming) giving your definition of 'method'.

John

Julio Di Egidio

unread,
Jan 8, 2018, 6:45:22 AM1/8/18
to
LOL. That article is fine. You should just learn to read first.

*Plonk*

Julio

Christoph M. Becker

unread,
Jan 8, 2018, 6:12:23 PM1/8/18
to
On 08.01.2018 at 10:39, John G Harris wrote:

> On Sun, 7 Jan 2018 15:26:21 +0100, "Christoph M. Becker"
> <cmbec...@arcor.de> wrote:
>
>> On 07.01.2018 at 15:13, John G Harris wrote:
>>
>>> newObject and oldObject have different prototype objects; newObject
>>> can't be a clone of oldObject.
>>
>> You may prefer
>>
>> let newObject = Object.assign({}, oldObject);
>
> Um. Object.assign doesn't copy non-enumerable properties, prototype,
> or internal slots. It's a restricted clone operation. For instance, it
> won't clone an Array object.

ACK. However, it seems that we both missed the point, namely that the
article's[1] definition ("[…] instead a prototype can be cloned
resulting in another concrete and fully functional object.") might
simply be too strict or is using the word "clone" in a very broad sense.
Interestingly, Wikipedia defines Prototype-based programming as[2]:

| Prototype-based programming is a style of object-oriented programming
| in which behaviour reuse (known as inheritance) is performed via a
| process of reusing existing objects via delegation that serve as
| prototypes.

That fits well to Object.prototype.create() and also to the spirit of
the article (at least for me).

[1]
<https://web.archive.org/web/20100316225046/http://www.helsinki.fi:80/~jppesone/papers/kandi.html>
[2] <https://en.wikipedia.org/wiki/Prototype-based_programming>

--
Christoph M. Becker

Thomas 'PointedEars' Lahn

unread,
Jan 8, 2018, 8:45:51 PM1/8/18
to
Christoph M. Becker wrote:

> That fits well to Object.prototype.create() […]

For reasons that should be obvious, “create” is _not_ a property of the
object referred to by “Object.prototype”. So it is “Object.create()”
instead.

The more recent introduction of a lot of helper methods that are properties
of built-in functions that can be called as functions or constructors (which
can replace several custom workarounds devised earlier), which would be
called “static methods” in other OOP languages (and may also be in
ECMAScript implementations at some point, now that there can be proper
classes) is one reason why it becomes increasingly important to not speak
of, for example, “Object.prototype.toString()” as “Object.toString()”, which
(probably for technical reasons) even MDN has not fully managed to fix yet
(but I have said and done for years now).

,-<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString>
|
| Object.prototype.toString()
|
| […]

Jonas Thörnvall

unread,
Jan 9, 2018, 12:34:09 AM1/9/18
to
Sometimes one field that the functionality behind the language is both hidden and covered by wordsallad. Some programmers simply forget that the programmers also are users, and users demand a noneambigous language. Your pity semantic discussion lead nowhere to the development of a functional programming language just to confustion. When javascript developed their string handling functions, and pop and push there was a clear design idea behind it.

Now you idiots slowly transfer the language to the land of blip blops covered in wordsallad. Well you simply do not have the brain for it, you lift the innerworks to the surface and present them as blip blop semantics to the user.

You are indeed low IQ

Thomas 'PointedEars' Lahn

unread,
Jan 9, 2018, 6:52:57 AM1/9/18
to
Jonas Thörnvall wrote:

> Sometimes one field that the functionality behind the language is both
> hidden and covered by wordsallad. Some programmers simply forget that the
> programmers also are users, and users demand a noneambigous language. Your
> pity semantic discussion lead nowhere to the development of a functional
> programming language just to confustion. When javascript developed their
> string handling functions, and pop and push there was a clear design idea
> behind it.
>
> Now you idiots slowly transfer the language to the land of blip blops
> covered in wordsallad. Well you simply do not have the brain for it, you
> lift the innerworks to the surface and present them as blip blop semantics
> to the user.
>
> You are indeed low IQ

Before one writes a criticism, one should be able to express oneself
flawlessly in the language that one is using. Otherwise the effort
will backfire.

Christoph M. Becker

unread,
Jan 9, 2018, 7:19:47 AM1/9/18
to
On 09.01.2018 at 02:45, Thomas 'PointedEars' Lahn wrote:

> Christoph M. Becker wrote:
>
>> That fits well to Object.prototype.create() […]
>
> For reasons that should be obvious, “create” is _not_ a property of the
> object referred to by “Object.prototype”. So it is “Object.create()”
> instead.

Thanks for the correction.

> The more recent introduction of a lot of helper methods that are properties
> of built-in functions that can be called as functions or constructors (which
> can replace several custom workarounds devised earlier), which would be
> called “static methods” in other OOP languages (and may also be in
> ECMAScript implementations at some point, now that there can be proper
> classes) is one reason why it becomes increasingly important to not speak
> of, for example, “Object.prototype.toString()” as “Object.toString()”, […]

ACK.

--
Christoph M. Becker

Jonas Thörnvall

unread,
Jan 9, 2018, 7:41:49 AM1/9/18
to
I do not think so i am qualified for greatness with 187 in QI. One in a million approven.

Thomas 'PointedEars' Lahn

unread,
Jan 9, 2018, 9:50:31 AM1/9/18
to
Jonas Thörnvall fullquoted:

> Den tisdag 9 januari 2018 kl. 12:52:57 UTC+1 skrev Thomas 'PointedEars'
> Lahn:
>> Jonas Thörnvall wrote:
>> > [gibberish]
>> > You are indeed low IQ
>>
>> Before one writes a criticism, one should be able to express oneself
>> flawlessly in the language that one is using. Otherwise the effort
>> will backfire.
>
> I do not think so i am qualified for greatness with 187 in QI. One in a
^^ ^^
> million approven.
^^^^^^^^
<https://en.wikipedia.org/wiki/Intelligence_quotient>
<https://twitter.com/realDonaldTrump/status/949619270631256064>
<https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect>

F’up2 alt.1d

Jonas Thörnvall

unread,
Jan 9, 2018, 10:31:39 AM1/9/18
to

Jonas Thörnvall

unread,
Jan 9, 2018, 12:50:56 PM1/9/18
to
Could not quite quailfy?

Chris M. Thomasson

unread,
Jan 10, 2018, 6:04:00 PM1/10/18
to
$50 scoring fee?

Chris M. Thomasson

unread,
Jan 10, 2018, 6:04:57 PM1/10/18
to
per 4 of the tests? 200$ lol.

Jonas Thörnvall

unread,
Jan 11, 2018, 5:06:25 AM1/11/18
to
Well it was free in the 90's i ain't exactly hangaround...

bit-n...@hotmail.com

unread,
Jan 13, 2018, 1:57:36 AM1/13/18
to

> I finally find a tutorial that explain somewhat what is going on.
>
> https://code.tutsplus.com/tutorials/introduction-to-web-midi--cms-25220
>
> But it is very vague, for example.
>
> In order to get the input data from our device, we first create a variable and assign it midi.inputs.values() like so.
>
>
> var inputs = midi.inputs.values();
>
> Is midi.input.values(); a function or a method? How do i know the difference?
> midi is an object?
> input an attribute of that object?
> values a property of input?
>
> I even lost on the terminology here.

OK, TLDR the Whole Thing, but...
Yes, Jonas, I agree with you - I've been grappling with the same thing, and I STILL don't get it - I don't understand what "a.b.c()" is - it kind of makes my head spin!

Btw, this "Julio" person seems to have made a career out of plonking people on this forum (including me) - bro, if you don't wanna listen to what ANYBODY else here has to say..... - not much point *being* here, isn't it??

John G Harris

unread,
Jan 13, 2018, 8:27:33 AM1/13/18
to


On Fri, 12 Jan 2018 22:57:26 -0800 (PST), bit-n...@hotmail.com
wrote:

<snip>
>and I STILL don't get it - I don't understand what "a.b.c()" is - it kind of makes my head spin!
<snip>

You create a variable and name it a :
var a;
You can now access that variable by writing :
a
You assign a value to a, an object in this case :
a = new Object();
You can now access that object by writing :
a
You make that object have a property named b,
whose value is another object in this case :
a.b = new Object();
You can now access that second object by writing :
a.b
You make that second object have a property named c,
whose value is a function object in this case :
a.b.c = function () { alert("Hello World !"); };
You can now access that function by writing :
a.b.c
And you can call that function by writing :
a.b.c();
It now displays the world shattering message
Hello World !

John

Jonas Thörnvall

unread,
Jan 13, 2018, 11:24:41 AM1/13/18
to
When you know the object and the syntax isn't that strange
below i somewhat get that assign a variable to the button, but assign a function to an event to a event feel strange, even more strange the syntax look for an anonymous function.

<button>Change color</button>
The JavaScript looks like so:

var btn = document.querySelector('button');

function random(number) {
return Math.floor(Math.random()*(number+1));
}

btn.onclick = function() {
var rndCol = 'rgb(' + random(255) + ',' + random(255) + ',' + random(255) + ')';
document.body.style.backgroundColor = rndCol;
}

But to be honest your explanation do not help me understand something like

var inputs = midi.inputs.values();

Would you please do a similar explanation because i am truly lost, i have come to beleive that inputs in this case is some sort of array holding inports?

Also this next terminology used access the "inport objects?" is new to me, can can you make a brief explanation.

There is many things that make me question what i going on. I do understand navigator requestMidiAccess call function failure and access depending on its resolved state.

But then i go to the success function it is four lines of code but i just do not get it. I can losely tell what i think happens.

Request midi access have somehow created some "midi" object it has a property inputs holding values/messages "apparently of very different kinds"

"Why there is paragraphs on values seem weird to me but i guess it is a function of sort?

It seem to me inputs is some sort of array that hold inport values like name and index?

inputs = midi.inputs.values();

Down here i get a little bit more frustrated due to the next calls, i do not quite understand what next() mean but i guess it reads next port from the inputs array into an input object?

for (input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}

I guess input have a property name, but then i get confused why is it input.value.name? not input.name.value????

What seem really weird in this loop is that not only read it in port objects, to me it seem input only would hold the last inport objects but in the end that is not true.

Because the loop also hold some sort of listener "onmidimessage" that call a function onMIDIMessage? Every time there is an event on the port? I can't see why the read in of the ports is within the message event loop?

Is the success function in itself some sort of listener, as you seem my understanding of these four line of code is very confused.

I would truly be greatful to anyone that try to explain what is going on in this code. But also explain how i can access the midi messages on the ports from outside of success function right now i moved both the assigments of ports into option lists and the function calls that need to have access to midi messages inside success function, because evidently it is called everytime i generate a midimessage.

I realise it is totally crazy. On the other side i am totally clueless howto do it in another way.

Feel free to joke around about my coding, but even better explain why my code is hilarious ;), then both of us get something out of it.

function success (midi) {
mid=midi;
inputs = midi.inputs.values();
outputs = midi.outputs.values();
// inputs outputs are Iterators
for (output = outputs.next(); output && !output.done; output = outputs.next()) {
var deviceOut = output.value.name;
console.log(deviceOut);
var optout = document.createElement("option");
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);
}

for (input = inputs.next(); input && !input.done; input = inputs.next()) {
var deviceIn = input.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
// each time there is a midi message call the onMIDIMessage function
input.value.onmidimessage = onMIDIMessage;
}
document.getElementById("out_portsel").selectedIndex = outportindex;
Rstarttime=performance.now();
makeTrack();
setTrack();
listTrackData();
changeProgram();
computeform();
timebars();
}







0 new messages