Live data from Hacker News

The surprising rise of JavaScript

radar.oreilly.com

21–30 of 39 posts

Re: The surprising rise of JavaScript

#21

JavaScript is a strange beast. The semantics of the language are, in my opinion, awesome and awful in different ways. Awesome: prototypes, first-class functions, dynamic function scope (not sure if there's a proper name for this), jQuery. Awful: the this keyword is confusing (but powerful once you learn it), type coercion, the API. The standard API is the reason that people care about "the good parts" of JavaScript.…

> the document.getElementById sort of operation which looks like it was designed in 10 days (all due respect to Brandon Eich)

document.getElementById() isn't part of JavaScript but part of the DOM Level 2 spec that came out years after JS.

JS was first seen in Netscape 2.0 in 1995 whereas DOM level 1 was specified in 1998 but didn't in fact yet contain document.getElementById. That one was added in DOM Level 2 in 2000, so five years after JS.

As such it was not designed by Brendan Eich, nor was it created in 10 days.

No. This is the work of a committee that was heavily influenced by the way Java does it which is understandable because when DOM1 came out it looked like Java is going to be the be all end all of Computer languages.

The "library" that comes with JS is really small (methods on String, RegEx, Date and Array). Everything else we owe to the W3C which has created an API that was all but made for the language it was going to be used from most of the time.

(edit: I got my dates and dom levels mixed up - fixed)

Re: The surprising rise of JavaScript

#22

JavaScript is a strange beast. The semantics of the language are, in my opinion, awesome and awful in different ways. Awesome: prototypes, first-class functions, dynamic function scope (not sure if there's a proper name for this), jQuery. Awful: the this keyword is confusing (but powerful once you learn it), type coercion, the API. The standard API is the reason that people care about "the good parts" of JavaScript.…

> Awesome: prototypes

Meh. I still have to write that rant, but javascript's "prototypes" are a boondoggle, they've got nothing to do with Self's prototypes[0] and don't provide anything more than classes do in nice dynamic languages (you can, in fact, do more fucking around with Python's types than with Javascript's prototypes). For all intents and purposes, Javascript's so-called prototypes are shitty single-inheritance classes without the sugar.

> dynamic function scope (not sure if there's a proper name for this)

Not sure what you mean by "dynamic function scope", since you don't seem to like `this` (which is indeed complete garbage, but is sorta dynamically scoped) I'm guessing you mean lexical closures? The part where a nested function has read/write access to bindings created in its outer functions/scopes?

> for now there is a lot we can do with it.

There's also a lot we could do with Fortran and Cobol. That's no bloody excuse.

[0] in Self, prototypes are just the thing you clone to get a basic object, they're just a template. They're not a unit of code reuse or inheritance: that's the job of mixins[1]

[1] which, again, are very different from what you get in JavaScript or Ruby (though Ruby is closer): in Self, a mixin is an object you link to your own via a "parent slot", a special type of slot used for message resolution. When a message is sent to an object, the runtime first checks all of the object's non-parent slots and if there's no match it follows the parent slots recursively to try and find a slot matching the message.

Re: The surprising rise of JavaScript

#24
post #6

It isn't really all the surprising if you have the background Douglas Crockford provided in his yahoo series - http://www.youtube.com/watch?v=v2ifWcnQs6M (part 1)

There was JavaScript (including the good parts) before Douglas Crockford started disseminating his ideas about the language and long before jQuery was released. So it was like a powerful and possibly quite elegant language all along, but it needed to be 'discovered' and 'evangelized'.

With respect to JavaScript, it's like front-end developers are all enlightened today, after living in the dark ages for about 10 years.

Re: The surprising rise of JavaScript

#25

hasn't objective-c and java pretty much replaced all the demand for javascript?

There's a trend of moving away from native apps to JavaScript driven ones. For example, the Financial Times' recent move: http://paidcontent.org/2012/05/01/web-journey-complete-ft-sw...

And how many new native apps were submitted that day? Calling it a "trend" is a bit over the top, imho. Also consider the nature of the app — basically to display some content.

Re: The surprising rise of JavaScript

#27

JavaScript is a strange beast. The semantics of the language are, in my opinion, awesome and awful in different ways. Awesome: prototypes, first-class functions, dynamic function scope (not sure if there's a proper name for this), jQuery. Awful: the this keyword is confusing (but powerful once you learn it), type coercion, the API. The standard API is the reason that people care about "the good parts" of JavaScript.…

> Awesome: prototypes Meh. I still have to write that rant, but javascript's "prototypes" are a boondoggle, they've got nothing to do with Self's prototypes[0] and don't provide anything more than classes do in nice dynamic languages (you can, in fact, do more fucking around with Python's types than with Javascript's prototypes). For all intents and purposes, Javascript's so-called prototypes are shitty single-inheri…

While you're generally right, you must not forget about Harmony Proxies and all that meta-programming fuzz.

While the final result of a prototypal class hierarchy is in fact very similar to pseudo-classic inheritance, remember that it's just the result of an internal, manual, modifiable process.

Re: The surprising rise of JavaScript

#28

JavaScript is a strange beast. The semantics of the language are, in my opinion, awesome and awful in different ways. Awesome: prototypes, first-class functions, dynamic function scope (not sure if there's a proper name for this), jQuery. Awful: the this keyword is confusing (but powerful once you learn it), type coercion, the API. The standard API is the reason that people care about "the good parts" of JavaScript.…

> Awesome: prototypes Meh. I still have to write that rant, but javascript's "prototypes" are a boondoggle, they've got nothing to do with Self's prototypes[0] and don't provide anything more than classes do in nice dynamic languages (you can, in fact, do more fucking around with Python's types than with Javascript's prototypes). For all intents and purposes, Javascript's so-called prototypes are shitty single-inheri…

> don't provide anything more than classes do in nice dynamic languages

How would you do in-place method mutation in something like Python or Ruby?

Re: The surprising rise of JavaScript

#29

Earlier quoted context omitted.

> Awesome: prototypes Meh. I still have to write that rant, but javascript's "prototypes" are a boondoggle, they've got nothing to do with Self's prototypes[0] and don't provide anything more than classes do in nice dynamic languages (you can, in fact, do more fucking around with Python's types than with Javascript's prototypes). For all intents and purposes, Javascript's so-called prototypes are shitty single-inheri…

> don't provide anything more than classes do in nice dynamic languages How would you do in-place method mutation in something like Python or Ruby?

Not quite sure what you mean, but I think it's something like this:

  a = "hello"
  puts a.size #=> 5
  class  1
Am I on the right track?

Re: The surprising rise of JavaScript

#30

JavaScript is a strange beast. The semantics of the language are, in my opinion, awesome and awful in different ways. Awesome: prototypes, first-class functions, dynamic function scope (not sure if there's a proper name for this), jQuery. Awful: the this keyword is confusing (but powerful once you learn it), type coercion, the API. The standard API is the reason that people care about "the good parts" of JavaScript.…

> Awesome: prototypes Meh. I still have to write that rant, but javascript's "prototypes" are a boondoggle, they've got nothing to do with Self's prototypes[0] and don't provide anything more than classes do in nice dynamic languages (you can, in fact, do more fucking around with Python's types than with Javascript's prototypes). For all intents and purposes, Javascript's so-called prototypes are shitty single-inheri…

> For all intents and purposes, Javascript's so-called prototypes are shitty single-inheritance classes without the sugar.

You're right. I would much rather have Java's or C++'s inheritance models in JavaScript. JS's object model is mutable, which is a plus for me, but it is far only language with mutable object methods or properties. I'll have to move prototypes from the "awesome" pile into the "meh" pile.

> lexical closures

Beyond closures, which I am glad to see in JS, I am referring to the call and apply functions which allow the user to set the scope of the functions during the function call. Again, I am hardly an expert, so the term for this escapes me. Your reply has been very helpful in that regard.

> There's also a lot we could do with Fortran and Cobol. That's no bloody excuse.

Very true, but I'd really like to know why you would put JS in the same class as Fortran and Cobol.

Post reply on HN