JavaScript Creator Talks About the Future
mikejuk writes "JavaScript is currently an important language — possibly the most important of all the languages at this point in time. So an impromptu talk at JSConf given by the creator of JavaScript, Brendan Eich, is not something to ignore. He seems to be a worried about the way committees define languages and wants ordinary JavaScript programmers to get involved."
You're arguing for value semantics (as in C++), as opposed to reference semantics (as in Java, Python, and JavaScript). In the latter languages, what many programmers think of as objects are really references to objects. In your code, myObj and newObj are two references that point to the same single object. Don't feel bad -- I talk to many Java programmers who still don't quite grasp this concept. Good old pointer diagrams make it clear; get a book that shows references as boxes with arrows that point to the objects they refer to.
What a fool believes, he sees, no wise man has the power to reason away.
It looks object oriented, but has no real notion of classes. No inheritance.
I agree with most of your points, but not this one. Class based and object oriented are orthogonal. Simula was class based, but not object oriented. JavaScript and Self are object oriented, but not class based. And JavaScript does have inheritance, a reduced form of the same differential inheritance that Self has (only one parent, can only be assigned at construction time). New objects inherit from the object in the prototype field of the constructor object.
I am TheRaven on Soylent News
Javascript doesn't have types to speak of
str = "10" + 2; - becomes "102"
num = 10 + 2; - becomes 12
num = 10 + 2 + "2"; - becomes 14
num = "10" - 3; - becomes 7
num = 10 / "2"; - becomes 5
num = "2" * 4; - becomes 8
num = 35.00;
str = "VALUE IS: " + num; - this becomes "VALUE IS 35".
--
Sure, it's a bit strange, but nothing extraordinary.
---
No scope to speak of
well, it's not true really. In the following example x will have global scope and y will be local to its function:
x=2;
function test() {
y = x + 3;
}
--
no real notion of classes
function Person(name, gender) {
this.gender = gender;
this.language;
this.name;
this.toString = function() {
return '' + this.gender + ' ' + language;
};
}
Person.prototype.getName = function() {
return this.name;
};
var person = new Person('Bob', 'male'); ...
person.language = 'English';
person.gender - this is 'male'
person.language - this is 'English'.
person.toString() - this is 'male English'.
person.getName() - this is 'Bob'.
--
Of-course you can also just evaluate a string into a class on the fly, few language allow that:
eval('
var person = {
name: "Bob",
gender: "male",
toString: function () {
return this.name + " " + this.gender;;
}
}
');
person.name - this is 'Bob'
person.gender - this is 'male'.
person.toString() - this is 'Bob male'.
No inheritance
- well, there is the keyword "inherits" and it does allow an object to be extended and you can use the 'prototype' to have multiple inheritance.
--
I am not saying this language is wonderful, whatever, but saying it is lacking various features, that it clearly has, even though they look different from other languages... it's disingenuous.
As to the question whether this language has anything that others do not, again, how about on the fly reflection via evaluation of strings into objects? When I first saw that over a decade ago, I thought it was a neat concept then, I still think it's a neat concept today.
You can't handle the truth.