views:

295

answers:

9

Inspired by this question.

I commonly see people referring to JavaScript as a low level language, especially among users of GWT and similar toolkits.

My question is: why? If you use one of those toolkits, you're cutting yourself from some of the features that make JavaScript so nice to program in: functions as objects, dynamic typing, etc. Especially when combined with one of the popular frameworks such as jQuery or Prototype.

It's like calling C++ low level because the standard library is smaller than the Java API. I'm not a C++ programmer, but I highly doubt every C++ programmer writes their own GUI and networking libraries.

+7  A: 

It is a high-level language, given its flexibility (functions as objects, etc.)

But anything that is commonly compiled-to can be considered a low-level language simply because it's a target for compilation, and there are many languages that can now be compiled to JS because of its unique role as the browser's DOM-controlling language.

Among the languages (or subsets of them) that can be compiled to JS:

  • Java
  • C#
  • Haxe
  • Objective-J
  • Ruby
  • Python
Nosredna
I would argue that the term 'low level' has a lot more to do with how close you are to the hardware layer. The fact that other languages can be compiled to js is meaningless.
Ed Swangren
Rather than 'compiled to' I see is as 'translate to' as C++ used to be translated into C
jottos
Distinguishing between compilers and translators is notoriously tricky.
Nosredna
While it is definitely true that the view held by people such as Ed Swangren above is true (from that perspective). However, the people that refer to it as lowlevel are speaking exactly from the perspective that Nosredna describes :-)
Joel Martinez
If you consider the DOM as the internal guts of the browser, nothing gets close to it compared to JavaScript. It's the bottom layer.
Nosredna
@Joel, yeah, if the GWT people aren't thinking of it as the low-level target language for their compiler, I don't know what they _are_ thinking. :-)
Nosredna
@Nosreda: But that browser sits upon countless layers of abstraction. I don't know, I can see what you guys are saying in a relative sort of way, but to me, calling js a low level language is pretty laughable. Of course, I work in a systems group :)
Ed Swangren
@Ed, most of the code I've written for money has been assembly language, so I'm not alien to your perspective. :-)
Nosredna
@Nosredna: Wow, you're more hardcore than I am! I mean, it is an interpreted language though, I just can't see how anyone could think...
Ed Swangren
@Ed, I've been programming for 30 years. What is "low level" is higher every year. I used to think C was hopelessly slow.
Nosredna
@Nosrenda: That is true, I am younger and some of the older guys laugh when I refer to C++ as a low level language :-)
Ed Swangren
Besides, V8 and TraceMonkey aren't the typical slow JS interpreters of a couple years ago. It's a crazy world. Even Java is fast now.
Nosredna
Speed does not make a language a low level language. C# is very fast (relatively), but I would not consider it 'low level'.
Ed Swangren
Funny thing about the DOM... near as i can tell, it was designed as an API to be used by Java - there are vast portions of it that make little or no sense from a Java*Script* perspective. Indeed, many of the most successful JS DOM libraries of the past few years have been those that go out of their way to *hide* the intricacies of the DOM from client scripts.
Shog9
@Ed: C# is high level. It compiles to IL or JavaScript--the low level languages. :-)
Nosredna
A: 

I don't view javascript as a low level language. A lot of functionality and user experience boosters are provided by it. Maybe others may view it as such simply because users can turn it off in their browser options, but it's a hugely robust language that virtually runs the web on virtually all types of browsers...

Jason
+1  A: 

It's not, it may be as low-level as you can get in normal browser programming, but its on par with functional languages like Scheme or Python.

I think the great lacks of Javascript are lack of name spaces or packaging and no threads

jottos
Lack of threads is not a language issue but an implementation issue. Thus, the web workers of Gears and HTML5.
Nosredna
it's hard to separate a language from it's runtime - there's not threading model in the javascript runtime or the language definition. the same holds for Scheme. Python on the other hand does threads all the way down
jottos
That's true But JavaScript doesn't just exist in browsers.
Nosredna
But you further my point - other Javascript definitions and implementations don't thread either - eg. ECMAscript or Javascript in Rhino
jottos
What do you think about web workers? They allow you to spin off background scripts that run in parallel.
Nosredna
Webworkers are running in a separate process, it's a neat trick the Gears guys pulled off but definitely not threads. You basically need to do IPC between them.
jottos
A: 

It's low-level compared to the GWT and similar toolkits, but it's not a low-level language in the larger scheme of things. The features it offers are very high-level: closures, dynamic typing, and prototypical inheritance are just a few examples of its high-level features.

Imagist
Well, yeah, that's kinda the question here: when these high-level features don't exist in the language+toolkit being used to "compile" to it, how can you really consider that language/toolkit to be of a higher-level...
Shog9
A: 

It's as low level as you want it to be, I don't think that is a valid question, also it's a loosly typed language that runs on the client... maybe that's why.

Also you can create namespaces, and pseudo-classes... not the way the language is supposed to be used but it can be faked.

Joseph Silvashy
It is not as "low level as you want it to be", that is completely false. Try writing on OS in javascript.
Ed Swangren
"When I use a word," Humpty Dumpty said, in rather a scornful tone, "it means just what I choose it to mean - neither more nor less."
Shog9
that’s not false at all, you can write really really simple JavaScript, or you can be as complex as you want... I don't think it's low level at all.@Ed, js was created for the web, and hardware interrupts are the least of my concern. Sure, maybe it’s the least complex code in my apps, but it complements the Ruby as well. Is Ruby too "low-level" for you too Ed?
Joseph Silvashy
+1  A: 

"Low" here has the same meaning as in the sentences "The number of casualties suffered in the first world war was low," and "Reduced-fat ice cream is low in calories." It makes sense when there's an obvious point of comparison, but out of context, it is simply absurd.

David Berger
+2  A: 

A lot of people say this because the objects and structures provided in JavaScript are about as simple as you can get. To develop any sort of real functionality, you have to use an external library. Low level is a bad way to put this, because it already has a meaning in computer science. A better way to say it may be that it's without built-in libraries.

Compare this with Java, where the actual language really doesn't do a whole lot. Trying making an array without an ArrayList, or access the file system without the IO libraries. Most languages are more than just the basics, they come with this extra functionality.

With JavaScript, the only real power we get comes from the APIs that are introduced by the browsers and aren't part of the language. Things like DOM manipulation and Ajax are supplied by the browser.

It may be better to summarize all of this by saying that with a language like Java, you can get started doing some serious work without having to download third-party libraries, but with JavaScript, you either have to download a library or write a library of your own.

pottedmeat
A library is useful if you want to abstract DOM calls.But I find JavaScript more than capable for writing small to medium apps without any kind of library. Being able to return objects and arrays that you create on-the-fly drastically simplifies some types of problems.I ported a project from JavaScript to C and realized then just how powerful JavaScript is.
Nosredna
DOM itself is a third-party library. I tried to make the point in what I just wrote that JavaScript in the browser comes with a third-party library: the DOM, BOM, and Ajax APIs.
pottedmeat
Ah. Got it. Thanks for the clarification.
Nosredna
+2  A: 

Answering a question that says "why is something sometimes called X..." with "it's not X" is completely side stepping the question, isn't it?

To many people, "low-level" and "high-level" are flexible, abstract ideas that apply differently when working with different systems. To people that are not all hung up on the past (there is no such thing as a modern low-level language to some people) the high-ness or low-ness of a language will commonly refer to how close to the target machine it is. This includes virtual machines, of which a browser is now days. Sorry to all the guys who pine for asm on base hardware.

When you look at the browser as a virtual machine, javascript is as close to the (fake) hardware as you get. That is the viewpoint that many who call javascript "low-level" have. I think it's a pointless distinction to make and people shouldn't get hung up on what is low and what is high.

neorab
A: 

It's considered to be low level by a number of people who prefer writing java to generate javascript then writing javascript(ie they dislike it fairly or unfairly). A lot of people complain about java these days but despite the lack of static type checking most people would probably consider ruby and python easier to write in most cases (java being a fairly simple static language-which are much harder to design well without large built-in feature sets then a simple dynamic language).

Few people would call python or ruby low level compared to java and if people were forced to target a python or ruby vm its hard to imagine that a java to python/ruby compiler would become as popular as gwt.

In closing javascript has an image problem(people sometimes think of languages as getting more difficult as they become more low level and vice versa).

Roman A. Taycher