When did Javascript become a serious language?

Levi Pearson levipearson at gmail.com
Mon Dec 9 12:02:21 MST 2013


On Sat, Dec 7, 2013 at 5:37 PM, S. Dale Morrey <sdalemorrey at gmail.com> wrote:

> Now don't get me wrong.  I'm hardly a javascript noob.  I was writing
> Ajax-like website helpers scripts before we ever coined the terms Comet or
> Ajax.  Nevertheless I've always viewed it as a tool for making shiny bits
> and/or using it as a scripting language for controlling other programs.  In
> other words I've always seen it as being firmly as part of the view
> component.  I never really viewed it as something for serious computational
> workloads.  Until now.

A lot has happened in the world of compiler technology for
dynamically-typed languages in the last few years.  Or, I should say,
a lot of the research that was done ~20 years ago is finally making
its way into real implementations and getting refined.  Both the
Mozilla and Google javascript engines have had crazy man-hours dumped
into them to refine their compilers in the last 5-10 years.

> The Node.js version is (to the best of my knowledge) single threaded and
> the Java version is running on a thread per core model (even though the
> test box is 1.5 cores).  Looking back, going with thread per core may have
> gimped the Java version because of list contention, and/or context
> switching penalties so I do doubt the numbers here are anything resembling
> final.  In fact I ran it for 5 - 10 - 15 and 30 mins as well and once JIT
> kicked in and moved some stuff to metal, Java slightly matched (at 15 mins)
> and slightly exceeded (at 30 mins) Javascript.
>
> Javascript just trucked along at the same rate during similar intervals.
>
> The point is, When the heck did Javascript become suitable for something
> that's so computationally heavy?  A 50% performance improvement over Java
> in a short interval, especially when I have not done anything to
> intentionally gimp the Java version, tells me this is not the Javascript I
> used to know.

The javascript is JIT-compiled to machine code just like the Java is
(well, not *just* like... each runtime works a bit differently, but
they all generate machine code at least for hot path code).  But the
javascript has to have a lightweight, fast-startup JIT system for its
primary runtime environment, which is web page code.  You might be
able to tweak Java into a similar execution profile by tweaking its
runtime options, but I don't know it well enough to say for sure.

> It also showed me something about my own internal biases.
> I find it odd how my thinking has evolved over time.
>
> I used to be a computer programmer who had a good/decent familiarity with a
> broad range of languages and I would always try to select the best tool for
> the job taking into account the cost of developer time vs cpu time.
>
> Over the past 4 or 5 years I've been so heavy into Java (because that's
> what employers want), that I think I may have evolved into a Java
> programmer.

There's nothing wrong with spending the time to become expert at a
certain technology.  Being too much of a generalist can hurt your
productivity if you really do have to spend most of your time with a
specific technology.  But still, keeping up on what's going on is not
a bad thing to do, especially if it keeps you from getting too much
into a niche.

> So what do you think?  Have you looked at any languages for purposes you
> had previously disregarded?  What were your thoughts?

I'm currently working on writing somewhat practical code in Haskell,
which definitely forces a change in perspective.  It's hard to go from
being highly competent in one aspect of programming to feeling like a
complete noob again, but as the new techniques and ways of thinking
about things start to become natural, it's very exciting, almost like
learning to program all over again.

Whether you pick Haskell or not is purely up to you, I'm not trying to
push it, just making the point that going *way* out of your comfort
zone can be invigorating, at least if you've got the time to pursue it
long enough to reach at least a minimum level of competency. If not,
it can actually be a bit discouraging!

     --Levi


More information about the PLUG mailing list