6

Well..I am learning java now and I am curious to know will this yield a noticeable performance increase ? And If many developers are following similar methodology for windows programming ( C++ back end and Java UI ) or other languages are used like python?

*this : C++ back end and other languages for UI instead of using the other language to write the whole program .

10
  • 24
    There's a tremendous difference between Java and Javascript - they are completely different languages.
    – Pointy
    Commented Sep 27, 2010 at 18:40
  • 3
    I'll assume that there's a bit of a language problem, but you are asking three separate questions, none of which is a complete thought. (When you say "will this yield a noticeable...", what is "this"?) Commented Sep 27, 2010 at 18:43
  • 7
    You thought wrong. They share nothing in common except a C-like syntax and the first four letters of their name. Commented Sep 27, 2010 at 18:45
  • 2
    Brand recognigion, marketing, plain and simple. It was originally called LiveScript, but changed the first part to Java since Java was the big thing in the mid to late 90s. There are other reasons for sure, but that one is the most commonly stated.
    – MooGoo
    Commented Sep 27, 2010 at 18:48
  • 3
    Also see What's the difference between JavaScript and Java? Commented Sep 27, 2010 at 18:57

2 Answers 2

24

Firstly, Java and JavaScript are completely different and unrelated languages. Firefox uses JavaScript; it does not use Java at all.

Secondly, this was not done for performance reasons, it was done to make it simpler to write add-ons and extensions that can be used with Firefox on any platform. C++ code needs to be compiled, and once compiled will only run on the platform that it was compiled for. JavaScript is an interpreted language which runs in an interpreter embedded in the browser, and so the same extensions can generally run on MacOS, Linux, or Windows (or anything else that Firefox runs on).

And yes, there are other programs that use scripting languages for this sort of purpose (to allow easy customization and extension). For example, Civilization IV's UI and game logic is written entirely with Python and XML for this reason, while the performance-intensive graphics code is still in C++.

9
  • 5
    Civ 4 was notorious for running really slowly and eating scads of memory, though.
    – Crashworks
    Commented Sep 27, 2010 at 18:43
  • 6
    Well doesn't that just back up the point that it's not done for performance reasons? ;) Commented Sep 27, 2010 at 18:44
  • 1
    If you don't plan on having anyone else customize or enhance your program, there's not usually much point in including an embedded scripting language, since you as the developer can always just change the original source code. Commented Sep 27, 2010 at 18:51
  • 1
    This is a somewhat backward way to look at why the Mozilla Platform is the way it is. Gecko, the engine behind Firefox which renders web pages and the UI, was designed from the beginning to be a cross-platform application framework. And that is what it is. While Firefox is by far the most prominent example of an application built on top of Gecko, other's do exist. See XULRunner. The platform never really took off, for a variety of reasons. One is the general perceived "bloat" of Gecko, but I've also found XUL documentation to be severely lacking.
    – MooGoo
    Commented Sep 27, 2010 at 18:59
  • 1
    It's not just about add-ons. It's much easier and faster to write (and avoid memory safety issues) the core application code in JS than in C++.
    – Nickolay
    Commented Sep 27, 2010 at 20:02
4

This question really doesn't make any sense unless you're really asking whether you should implement your applications as XUL applications. Javascript by itself doesn't give you anything with which to build a user interface. A tremendous amount of the code in Firefox is C++ code to provide the Javascript components with a UI framework.

5
  • +1 This is an important point that I missed. The JavaScript in Firefox (and Python in Civ IV, etc.) doesn't create the UI, it allows third-parties to customize and modify the UI. Commented Sep 27, 2010 at 18:56
  • 2
    I am a beginner . I am not supposed to know all this or I wouldn't have asked at the first place !
    – Ahmed
    Commented Sep 27, 2010 at 18:58
  • 1
    @Ahmed I'm not blaming you for not knowing - I'm simply telling you the truth. Javascript is simply not a way to build a UI for anything outside of a browser, or something else (like Firefox itself) that does provide a UI framework. Also, you should probably learn what downvotes are really for.
    – Pointy
    Commented Sep 27, 2010 at 19:03
  • Javascript defines the behavior of the UI in Firefox, exactly as it would in HTML, so I would say in that respect it does create it. The tremendous ability to change virtually anything in Firefox exists because the UI is built in the same way extensions are (XUL/CSS/JS). With a UI hard coded in C++ you end up with an extensions system like in Chrome which offers barely more power than a Greasemonkey script. Web browsers that use the Gecko engine for HTML rendering but native API's for the UI, such as K-meleon and Camino are similarly limited in the extension capability department.
    – MooGoo
    Commented Sep 27, 2010 at 19:14
  • Well yes the Javascript code tells the UI code what to do, but my point is that just by linking V8 into your C++ code, you really don't have much more of a UI framework than you did previously. Sure, it may be a good idea if you want a lot of future flexibility or a plugin/add-on architecture or whatever, but on the way there you're also going to need to identify an actual UI toolkit to draw lines and boxes and circles and hamsters and text.
    – Pointy
    Commented Sep 27, 2010 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.