
The surprising rise of JavaScript - Garbage
http://radar.oreilly.com/2012/05/051012-radar-script-javascript.html
======
6ren
There's a theory that languages hitch a ride on platforms that do something
useful, as a way of "scripting" (customizing or configuring) that platform.
The obvious one for Javascript is the browser, but we can see others: C for
unix; perl and PHP for the server-side; ruby for rails; objective-C for iOS;
C#/VB for Windows/Office and so on. Though not all languages seem to fit this,
e.g. Java.

I think it's actually an instance of the simple idea that products are only
adopted when they meet a need - an "application" of that product. Hence the
term "killer app" for a new technology. Platforms are often products that are
needed in themselves; therefore, anything that improves them a bit, expanding
their capabilities and usefulness, is also needed. It seems quite common that
a language, in itself, doesn't meet a particular need; similar to the idea
that code, in itself, doesn't solve problems; and pure mathematics, in itself,
isn't of practical use. All these need to be applied to a problem. (Of course,
_some_ people do adopt all these despite their "uselessness" - it's just that
this is a tiny minority).

In addition, people need to know about it (you can't adopt a compelling
solution to your urgent problem if you've never heard of it). A successful
platform helps here too - its scripting language is right there, installed,
ready to use even before you need it.

In the case of Java, it seems to be have been useful in itself, because it was
safer and easier to use than C and C++; it rode the rise of "OOP"; had a
reassuring industry backer (Sun) and complete toolchain, libraries, support;
and was heavily promoted by Sun. At that time, python, ruby and javascript
were slow (because of slow hardware and lack of optimization) and C# didn't
exist.

BTW: A blog/essay introduced the term "scripting language" to describe C
(which is striking because C is not one, by the usual definition), but I've
not been able to find it since.

So people bend over backwards to make javascript workable, improving it,
adding libraries, finding the good parts, writing front-ends for it, writing
back-ends for it, because it is the scripting language of the browser. If you
do all that, is it still javascript? Yes, in that it uses the adoption channel
of javascript, and maintains compatibility with javascript as an interface. So
Javascript is no longer a thing, but a conduit - a platform customized by
other scripting languages.

------
fruchtose
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. jQuery is so popular is because it allows you to turn away from
the _document.getElementById_ sort of operation (ugly code) and turn it into
_$("#id").filter().each().etc()_.

People don't like JavaScript because of what it is, but what it can be. There
are so many examples to choose from: jQuery (DOM API, data requests, standard
library "extensions"), jPlayer (multimedia), Node.js (server, native API),
Mustache (templating), Meteor (dynamic MVC). I am by no means an expert, but I
can appreciate that JavaScript has turned into a serious language. JavaScript
is not the holy grail of web programming languages, and I am sure that
something greater will succeed it, but for now there is a lot we can do with
it.

~~~
masklinn
> 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.

~~~
wwweston
> 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?

~~~
judofyr
In Ruby:

    
    
        foo = "Hello"
        def foo.to_s; "Hello world!" end
    

Because "def" introduces a new local variable scope, you'll have to use
#define_singleton_method if you want to close over variables:

    
    
        foo = "Hello"
        old = foo.method(:to_s)
        foo.define_singleton_method(:to_s) { old.call + " world!" }

------
VeejayRampay
How is the rise of the (unfortunately) sole technology that the ubiquitous
multimedia platform of the beginning of the 21st century understands
"surprising"?

The fact that we still haven't found a way to use anything else easily after
about 15 years and are still being somehow coerced into developing with it is
what's surprising really :/

~~~
josefonseca
> How is the rise of the (unfortunately) sole technology that the ubiquitous
> multimedia platform of the beginning of the 21st century understands
> "surprising"?

I recall that 14 years ago DHTML was the all the rage and javascript was the
key to DHTML. So I took up JS and bought books and went in head first.

Conclusion: it was impossible to take that language seriously. Javascript was
a hack.

So for me, the rise of javascript as anything more than a browser helper
language has been very surprising. I still have some prejudice towards it.
Maybe others feel the same way and knowing how O'Reilly comes from the UNIX
tradition, I'm sure that's what they meant with that title.

~~~
factorialboy
Similar story for me. Except that in 2010 I re-learnt JavaScript and
discovered how beautiful, flexible and powerful it can be as a client side /
server side language

~~~
jmspring
I've been node'n it up a bit myself lately. The language is easy to write,
pretty easy to get things done, and server-side node provides a lot of great
libraries.

That said, the development ecosystem around Javascript is very immature. To
really write decent amounts of server-side JS as a team, people often employ
linters and other things to sanity check their code. Debugging? Mostly
printf's (or equivalent). Scoping rules can also be pretty annoying.

It is useful for getting things done, but it generally isn't my first choice
(at least server side).

~~~
AdrianRossouw
Have you not seen [1] node-inspector? It allows you to debug your server side
code with the chrome/safari web inspector.

[1] <https://github.com/dannycoates/node-inspector>

~~~
jmspring
Adrian - I have and it is a very useful tool. I guess my main gripe is the
fact that the tool set is there in some form, but each has its area and none
of them are really connected/integrated.

I suspect the toolchain will eventually get there, but it is a big step back
if one is used to more integrated ecosystems.

------
PakG1
I remember back in high school, I think like 1998 or so, my friend told me,
"You should really learn Javascript really well. It's going to be really big
and around for a really long time." I laughed at him.

Funny thing is that ended up going into embedded hardware; he almost never
touches Javascript, except for some personal stuff. I still find it
mindboggling how right he was, but part of me still feels like he was just
shooting in the dark.

------
abbetts
If Javascript is so great then why do we need Coffeescript?

~~~
petercooper
Consider that in the browser, JavaScript is (with a few minor exceptions) the
closest to a universal scripting runtime/VM that we can get. Targeting the
browser, therefore, requires compiling down to JavaScript. So JavaScript (the
language) and CoffeeScript can both be awesome in the way that Scala and
Clojure have their different niches on the JVM.

------
islon
I wouldn't call it "surprising" to see the only client web language increasing
in popularity.

------
ambirex
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)

~~~
Michiel
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.

------
petercooper
As the title is ambiguous, my surprise is at _how long_ it took for JavaScript
to gain the stature and position it has now, not in it actually making that
rise.

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

~~~
factorialboy
Not even close. JavaScript is the closest thing we have today to a 'universal'
programming language.

~~~
VeejayRampay
It's universal because it's the only language that runs in the browser, not on
its merits though. That alone made it big and ubiquitous. If Python had been
picked as the scripting language for the web, or even Lua or Ruby, they would
be the "universal" languages.

