The only people who think this is good for anything are those who never had to use it for anything beyond little "onclick" scripts on a webapp. Just because Google used it it doesn't make it automatically good.

The crappiness comes from the fact that it doesn't support inheritance. This might not seem a problem for a small app, but as it grows you would need to better organize your code. Some methods might be needed by several objects, thus requiring a component hierarchy.

Well, in JavaScript that's impossible.

Some JavaScript developer might say: "You can simulate it with design patterns." Google it and be afraid of the sheer amount of stupidity you need to suffer in order to get something that resembles sanity.

Why even bother with it? Shouldn't you just use a language that allows you to do what you need done?

JavaScript is just for tiny scripts and that's it. And even then there are better options out there.

JS is fine for little web scripts, which is all it was intended for. The problem is that now people want to do real software engineering client-side and JS just isn't up to the task. Various people want a JS.next, but putting in all the static typing and contract guarantees that would make JS suit people who want to program large systems will just piss off those who like JS the way it is while never satisfying the static/strict crowd.

The root of the problem is the lack of choice. The only real answer is to allow programmers to use whatever language they like client side, which can only really be achieved by having browsers running a byte code based VM which users compile or interpret to.

The only people who think this is good for anything are those who never had to use it for anything beyond little "onclick" scripts on a webapp. Just because Google used it it doesn't make it automatically good.

The crappiness comes from the fact that it doesn't support inheritance. This might not seem a problem for a small app, but as it grows you would need to better organize your code. Some methods might be needed by several objects, thus requiring a component hierarchy.

There are other ways of building inheritance, which also depends on how you build your classes. In some ways I'd say JS as a language is kinda lower level then Java, in that you can build most forms of abstraction in pure JS. Classes, modules, local functions (private to one section of code), static functions, classes, inheritance, multiple inheritance, aspect oriented programming, or something custom. You can build it all!

I've also written a whole programming language and several web applications in JS, and I much prefer it to Java. I also much prefer HTML/CSS to Swing. I get far more control, and it's easier to build a wide variety of components, whilst having far less cruft to deal with. I can just concentrate on getting the job done.

There is a bit of a learning curve, to learn all of these tricks you can perform. But once your over it, it's bliss.

The root of the problem is the lack of choice. The only real answer is to allow programmers to use whatever language they like client side, which can only really be achieved by having browsers running a byte code based VM which users compile or interpret to.

The root of the problem is the lack of choice. The only real answer is to allow programmers to use whatever language they like client side, which can only really be achieved by having browsers running a byte code based VM which users compile or interpret to.

Now, I wonder what kind of VM could handle that task???

The only improvement I know of over the last 5 years to Applets is the ability to use JNLP files. The JVM might be amazingly fast, but a lack of applet development, and terrible start up times makes it practically unusable for the web. It's also far more hassle to put an applet together then to build something JS powered.

But in terms of having a VM to target, rather then JS, I used to think this would be a good idea too. Now I'd rather see a high-level intermediate language, like C--, as it would be much easier to target. If they allow the same, then there is no benefit in having to output bytecodes over ASCII text (the latter is much easier to work out and debug).

Not as in applets, but as a general purpose execution engine with access to the DOM, just like JS has. Applets are a dead technology - Flash probably going the same way too along with all other plugins. HTML5 ftw.

Also, startup time need not be slow at all. Firstly, if Flash can start up instantly, then brilliant. Secondly, look at JamVM and Dalvik. Perfect. The ability to embed script as base64 encoded jars would be awesome.

It does compile to ECMAScript (to be compatible with other browsers), and does compile to a VM, which will be embedded in Chrome, and the promise goes, available to other browsers as well. At least in theory, it could work... but I share some of your concerns, too.

That 'general purpose execution engine with access to DOM' is already here, and it's JS. There's more and more languages and frameworks targeting JS as their eventual output format. Sure it's a big chunky ascii format rather than bytecode, but that's pretty much the only disadvantage IMHO.

That, and the fact it's never going to be as fast as straightforward Java bytecode can be due to the design of JS. And of course all of these JS-targeting things are riddled with incompatibilities and bugs. It makes no real sense.

LLVM bytecode would be another decent contender but much of the attraction of Java is the existence of a well-understood and decent platform of APIs. It is indeed the only reason I've bothered looking at Android.

In some ways I'd say JS as a language is kinda lower level then Java, in that you can build most forms of abstraction in pure JS. Classes, modules, local functions (private to one section of code), static functions, classes, inheritance, multiple inheritance, aspect oriented programming, or something custom. You can build it all!

No, you can't.

You can stuff functions inside of objects, and that's all. That's not metaprogramming.

You want to see real metaprogramming. Try Lisp. Your jaw will hit he floor and I promise you will never ever want to touch this filthy Javascript again. It is like the difference between a bicycle and the starship Enterprise.

I've also written a whole programming language and several web applications in JS, and I much prefer it to Java. I also much prefer HTML/CSS to Swing. I get far more control, and it's easier to build a wide variety of components, whilst having far less cruft to deal with. I can just concentrate on getting the job done.

The quality of your "programming language" must really low. Javascript doesn't allow simple things that would make good design.

There is a bit of a learning curve, to learn all of these tricks you can perform. But once your over it, it's bliss.

Have you ever built a proper application using JS?

No, it isn't. I tried and the more I learned the more outraged I got for being forced to work in such a primitive way. There are a dozen languages out there, especially on the JVM, that do a much better job.

JavaScript simply lacks many constructs that you get for free in more advanced languages.

Now I'd rather see a high-level intermediate language, like C--, as it would be much easier to target. If they allow the same, then there is no benefit in having to output bytecodes over ASCII text (the latter is much easier to work out and debug).

+1 to high level IR. And esp. a tree structured IR rather than "flat". Couldn't really care less about how it's transported (bytecode or source).

As much I as like LLVM, it's not the ideal (IHMO) transport method. But it would be much better than anything we have today.

From my perspective the ideal transport method is lzma pack200'ed jar files I suppose only time and motivation is stopping someone hacking on Chrome to implement JamVM like this. Would be exactly what the HotJava browser failed to be*

There are some advantages to a source-level specification and not a bytecode one -- different architectures can compile it in radically different ways, which is harder when you have assumptions about a machine model encoded into lower level code. That's the rationale the OpenGL ARB gives for not having a bytecode format for GLSL anyway, and it's a little bit weak but not totally without merit. Same argument could possibly apply to the scripting runtime for browsers too. I think we can all agree that Javascript is a pretty terrible compiler target though.

From my perspective the ideal transport method is lzma pack200'ed jar files I suppose only time and motivation is stopping someone hacking on Chrome to implement JamVM like this. Would be exactly what the HotJava browser failed to be*

Web servers and browsers already support compression whilst sending over data. It would be much better to have better compression there, so HTML, CSS and other items can benefit too. However I heavily disagree about wrapping it all up into one file. It prevents parallel downloads, using multiple CDNs, works against caches and increases startup time longer. Any large web game or application should also have it's content streamed as you are using/playing it, so it appearers like it downloads instantly. More should be done to make this more natural then it currently is. Wrapping all content into one file is like taking a step back from that.

I think we can all agree that Javascript is a pretty terrible compiler target though.

If you use === instead of == in your language, then most of the quirks (like 0 == '') go away. All of the closure and prototype stuff then allows you to build pretty much anything on top, as it's such a flexible language. So I'd disagree with you.

Funny, I use JavaScript daily and run a single-page-app framework with thousands of lines of code and I'm using classes. Seems to work just fine. And it's not a regular web page app, it's designed for television, meaning all input interaction must be coded and handled in code.

Just because you don't know better doesn't make JavaScript bad, there are tons of libraries out there, frameworks, etc. that can help tremendously.

You're barking up the wrong tree, this is a Java forum. Other than that, Javascript is an excellent language once you grasp the specification. It's a functional language that looks like an object orientated language, which causes a lot of confusion and results in incredibly crappy example code and tutorials all over the interwebs. Please don't let the incompetence of others influence your perspective on this language. The only thing Javascript desperately needs is a rocksolid IDE.

Hi, appreciate more people! Σ ♥ = ¾Learn how to award medals... and work your way up the social rankings!

Funny, I use JavaScript daily and run a single-page-app framework with thousands of lines of code and I'm using classes. Seems to work just fine. And it's not a regular web page app, it's designed for television, meaning all input interaction must be coded and handled in code.

Just because you don't know better doesn't make JavaScript bad, there are tons of libraries out there, frameworks, etc. that can help tremendously.

You can't be using classes, because Javascript doesn't have them. You are using a hack you think it is smart because nobody else noticed how much time you waste with this crap yet.

You're barking up the wrong tree, this is a Java forum. Other than that, Javascript is an excellent language once you grasp the specification. It's a functional language that looks like an object orientated language, which causes a lot of confusion and results in incredibly crappy example code and tutorials all over the interwebs. Please don't let the incompetence of others influence your perspective on this language. The only thing Javascript desperately needs is a rocksolid IDE.

I know exactly what JavaScript can and cannot do. And it is far from excellent. As a matter of fact it is the exact opposite of it.

Functional and object orientation aren't mutually exclusive, so I don't know what you mean there. JavaScript code looks like crap because the language itself is crap and the developer is fighting all the way through in order to get something sensible running.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org