

Why is it ok that Javascript is the only client side option? - pedrocr
http://pedrocr.net/text/javascript-blues/

======
junklight
Oh dear.

First of all - shipping binary code to browsers. Please. No. Flash is bad
enough. Say good bye to all the grease monkey style hacks and remixes and lots
of other interesting things about the web.

Secondly - either you are a programmer or not. I can't actually tell from your
article if you want to be or not. However if you want to be a good programmer
then you need to learn other languages - you might not be an expert in those
other languages but being able to navigate your way round them - it is good
for your programmers brain. Eric Raymonds famous article actually recommends
you should try and learn a new language every year
<http://www.catb.org/esr/faqs/hacker-howto.html>

And thirdly - Javascript is actually a real cool language masquerading as a
very dull mainstream one. I resisted doing too much in it for years but as I
needed to do more and more I found out that its very powerful and flexible.
Also if you use something like jquery you get a lot of Ruby style bits and
pieces.

And lastly - it might be a cliche but that doesn't mean its not true (to use
another cliche in defence of the one I am about to use) - If all you have is a
hammer then every thing looks like a nail. Ruby might be a pretty good
language - but there is a reason there are so many other languages and its not
because all the other people are idiots who weren't smart enough to come up
with Ruby.

~~~
pedrocr
>First of all - shipping binary code to browsers. Please. No. Flash is bad
enough. Say good bye to all the grease monkey style hacks and remixes and lots
of other interesting things about the web.

Monkey patching bytecode may very well be harder but is that really used?
Greasemonkey is marginal at best. What other things do you have in mind?

>Secondly - either you are a programmer or not. I can't actually tell from
your article if you want to be or not. However if you want to be a good
programmer then you need to learn other languages - you might not be an expert
in those other languages but being able to navigate your way round them - it
is good for your programmers brain.

I've learned plenty of languages and do appreciate some of the points of
Javascript. I just don't see why everyone seems to defend it as the one-true-
language for the client side. For everything else people make plenty of
diverse choices yet somehow on the one platform that for historical reasons is
stuck with a single language saying you'd rather use another implies somehow
that you don't get it.

>And thirdly - Javascript is actually a real cool language masquerading as a
very dull mainstream one. I resisted doing too much in it for years but as I
needed to do more and more I found out that its very powerful and flexible.
Also if you use something like jquery you get a lot of Ruby style bits and
pieces.

I am using jQuery and it does have some goodies. The point isn't that with
effort I couldn't make myself more comfortable with it. The point is that I
don't see much that Javascript gives me that Ruby doesn't. So the fact I am
forced to use Javascript is a net-negative for me.

>If all you have is a hammer then every thing looks like a nail. Ruby might be
a pretty good language - but there is a reason there are so many other
languages and its not because all the other people are idiots who weren't
smart enough to come up with Ruby.

Certainly. And I do use other languages. The reason I'd like to be able to use
Ruby for both codebases is that that would allow me to do interesting stuff I
can't right now.

In fact the same criticism can be made of Javascript, that because it's the
only hammer available everything looks like a nail. I'm proposing more
languages, not less.

~~~
junklight
That most of the web (and obviously Flash is the exception to this) is text
based is not an accident. Browsers and people are not the only thing reading
the web - there are crawlers and other tools doing this, that and the other.
Search engine crawlers for example go into the javascript and extract links.

Also I really don't think you have thought it through as a developer - its bad
enough debugging stuff in browser without it being compiled and only having
basically machine code to look at.

I don't think its the one true language for anyone to be honest - but
expecting the browser to ship with several languages in it doesn't appeal to
anyone either (and I know you just want a few byte code runtimes in but I
cannot see how that would work while still maintaining all the richness and
complexity of the web as it stands)

anyway - I think if there was any appetite to do anything about this problem
it would have been done by now. There were people grumbling about it 10 years
ago and I've seen a number of projects to add languages come and go.

~~~
pedrocr
> That most of the web (and obviously Flash is the exception to this) is text
> based is not an accident. Browsers and people are not the only thing reading
> the web - there are crawlers and other tools doing this, that and the other.
> Search engine crawlers for example go into the javascript and extract links.

I can see how that is important for the strings in the code but I'm not aware
of many use cases for crawling the actual javascript code.

>Also I really don't think you have thought it through as a developer - its
bad enough debugging stuff in browser without it being compiled and only
having basically machine code to look at.

If I want to debug javascript I need Firebug or Chrome's tools and those can
very well have support for a standard debugger.

>but expecting the browser to ship with several languages in it doesn't appeal
to anyone either (and I know you just want a few byte code runtimes

I just want one standard bytecode runtime. I can ship and have the user cache
whatever runtime I need.

> but I cannot see how that would work while still maintaining all the
> richness and complexity of the web as it stands)

I still don't see what web richness is there to be had inside the <script>
tag. Seems to me all the uses of it that aren't simply execution are marginal
at best.

>anyway - I think if there was any appetite to do anything about this problem
it would have been done by now. There were people grumbling about it 10 years
ago and I've seen a number of projects to add languages come and go.

It seems to have been enough of a problem for google to have built GWT. I
wonder why they haven't shipped a Dalvik VM in Chrome and have their GWT apps
target the VM on Android and Chrome and Javascript for everyone else. Is V8
execution these days comparable to a good JVM/CLR?

~~~
junklight
I suspect this is becoming a bit fruitless because it seems like your tack is
- "I can't imagine anything other than the way I want to use the web"

But let me just mention one other view:

The browser, despite the inconsistencies between different brands, is very
accessible. Anyone with the ability to peck away at a keyboard and read some
basic instructions can make a web page - and with only a little more effort
add some quite rich functionality even if only by cutting and pasting some
javascript.

Now imagine if instead you needed a compiler and an SDK (see footnote), if you
couldn't just shove a bit of code in the page but instead it needed to be
compiled and included separately.

Would the web be what it is today?

Look at Java and Flash - why aren't they the dominant forces on the web
because they are taking very much the approach you advocate.

footnote: and who would make these? Would you have one for every browser, for
every language. Who would maintain them? In fact the more thought I give to it
the more impressed I am that there is anything like one single common language
available in all browsers

------
bdfh42
You are on a path to enlightenment.

JavaScript is an elegant and truly flexible language - very well suited to the
roll we have given it in remote (and until recently) pretty simplistic client
environments.

I suggest that your issues are not with JavaScript per se but with managing
the flow of data and functionality between the server and the client. I am not
suggesting that will become easy but, with experience, you will find
workmanlike solutions.

~~~
tzs
I think the problem he's highlighting is with the browser executing a specific
_language_. If it used a bytecode system, like JVM, CLR, or similar, you could
still use Javascript--just compiled down to the appropriate bytecode. But
others could use Ruby, or Python, or Java, or C#, or any other language that
can be compiled to the appropriate bytecode.

~~~
count
They're not mutually exclusive. Coffeescript[1], for example, compiles to
javascript, but isn't javascript itself.

I'd bet most browsers have a JVM installed as well, so there's that...

[1]<http://jashkenas.github.com/coffee-script/>

------
DjDarkman
Nobody is stopping the Ruby devs from writing a Ruby interpreter for the
browser. Here is the recipe:

1) invent a type that the browser current doesn't understand like:
application/ruby-script

2) write a parser for it in JavaScript

3) Profit??

It would look like this:

<script type="application/ruby-script">

//your browser will ignore this but your parser won't

//sorry I don't do ruby to come up with an example

</script>

<script src="yourawsomerubyparser.js">

------
BonoboBoner
I hated JS for years, but started to love it in the last couple of months. In
my experience, as long as you're not prejudiced and dont judge JS for its
flaws, it will treat you very well.

------
nervechannel
Actually, there used to be a choice.

When I got into web dev, I got several gigs doing IE-specific sites in
_VBScript_.

Think how much worse it could have been if JS _hadn't_ won.

------
RyanMcGreal
For enlightenment, read Crockford's _Javascript: The Good Parts_.

~~~
pedrocr
I have actually, that's the book I took with me. It made me understand the
language more and just highlighted how it has an interesting model behind it
(e.g., prototype and async) and a pretty bad syntax in front of it (e.g.,
constructor stuff).

------
toretore
TL;DR: I don't actually understand how JavaScript works, but I thought writing
a nonsense article demonstrating my willingness to bash it nonetheless with an
aggressive headline and post it on HN myself would bring me some desperately
needed attention.

~~~
pedrocr
If I do or do not know Javascript is actually tangential to my point. What I
find strange is that the browser environment forces a language on developers
and that is seen as OK. When apple was adding language/framework restrictions
to the AppStore people were screaming bloody murder but somehow the browser
status quo is fine.

That being said the title was probably too agressive. The original was not
very descriptive and it was what I came up with on the spot.

~~~
nervechannel
The AppStore restrictions are top-down decisions for commercial reasons.

Whereas the web ecosystem has _evolved_ this way.

You _can_ write code that compiles to bytecode to run on a browser -- applets,
Flash, Silverlight -- but for various evolutionary reasons, none of them have
become dominant over JS.

It's like being cross about how few air-breathing fish there are, and writing
to HN to complain.

~~~
pedrocr
>The AppStore restrictions are top-down decisions for commercial reasons.
>Whereas the web ecosystem has evolved this way. >It's like being cross about
how few air-breathing fish there are, and writing to HN to complain.

It was a rant about how things turned out. I'm not expecting anyone to go out
and build something I'd like better. But it does surprise that most people
think it's OK that an increasingly more important environment is limited to a
single language. I was attacking Javascript as a single choice more than
Javascript as a language, but I should have probably have made that more
explicit as there were plenty of comments about how this was just me not
knowing enough Javascript.

>You can write code that compiles to bytecode to run on a browser -- applets,
Flash, Silverlight -- but for various evolutionary reasons, none of them have
become dominant over JS.

All of those are ways to run code inside a box inside a webpage. None really
replace Javascript as a DOM manipulator with a bytecode. I don't think there
has ever been any portable option besides Javascript (or emitting Javascript
from something else) to do scripting on a page that isn't constrained inside
Flash/Applet.

~~~
nervechannel
I do see what you mean about the lack of choice, although I'd rather have all
browsers implement one language consistently and and well, rather than a
number of languages flakily and non-universally.

The compiling-to-JS idea has a lot of potential I reckon. I've done a couple
of GWT projects and the results work very well, much better than if I'd
written the JS myself, and not noticeably slow. And debugging the app in
Eclipse is so much nicer than using a JS debugger.

------
Roridge
Why not just use GWT?

~~~
pedrocr
Because I'd probably still prefer to write Javascript than Java. But a GWT
approach is one possible solution and there are some Ruby projects that do
similar things. None are production ready though. For reference:

<http://hotruby.yukoba.jp/> \- Implements the YARV (ruby 1.9) bytecode in
Javascript (most promising one in my view) <http://github.com/mneumann/rubyjs>
\- Compiles a subset of Ruby code to Javascript

~~~
Roridge
I happen to agree with you. My biggest issue with GWT is that it generates the
Javascript, and I am at it's mercy.

However sometimes it's important to get function over form?

