Slashdot Mirror


Firefox Gets Massive JavaScript Performance Boost

monkeymonkey writes "Mozilla has integrated tracing optimization into SpiderMonkey, the JavaScript interpreter in Firefox. This improvement has boosted JavaScript performance by a factor of 20 to 40 in certain contexts. Ars Technica interviewed Mozilla CTO Brendan Eich (the original creator of JavaScript) and Mozilla's vice president of engineering, Mike Shaver. They say that tracing optimization will 'take JavaScript performance into the next tier' and 'get people thinking about JavaScript as a more general-purpose language.' The eventual goal is to make JavaScript run as fast as C code. Ars reports: 'Mozilla is leveraging an impressive new optimization technique to bring a big performance boost to the Firefox JavaScript engine. ...They aim to improve execution speed so that it is comparable to that of native code. This will redefine the boundaries of client-side performance and enable the development of a whole new generation of more computationally-intensive web applications.' Mozilla has also published a video that demonstrates the performance difference." An anonymous reader contributes links the blogs of Eich and Shaver, where they have some further benchmarks.

100 of 462 comments (clear)

  1. As fast as C code??? by ACDChook · · Score: 5, Interesting

    Correct me if I'm wrong, but generally speaking, I was always under the impression that, as an interpreted language, javascript will never be able to run 100% as fast as natively compiled C code.

    1. Re:As fast as C code??? by Anonymous Coward · · Score: 5, Informative

      Correct me if I'm wrong, but generally speaking, I was always under the impression that, as an interpreted language, javascript will never be able to run 100% as fast as natively compiled C code.

      Well, it has a JIT compiler, so that would transform it into bytecode essentially. It's the reason why C# is as fast as C code, because it too has a JIT. Google JIT :)

    2. Re:As fast as C code??? by Bjarke+Roune · · Score: 5, Informative

      The optimization in the story is to compile parts of code written in Javascript. So when using this optimization, the Javascript is only partly interpreted, and if the compiled part is the part that takes up most of the runtime, then the Javascript could conceivably be something like the speed of natively compiled C.

    3. Re:As fast as C code??? by fozzy1015 · · Score: 2, Informative

      Correct me if I'm wrong, but generally speaking, I was always under the impression that, as an interpreted language, javascript will never be able to run 100% as fast as natively compiled C code.

      A real world Javascript program will rarely, if ever, be as fast as C. The idea with this is: Normally, loops, no matter how tight, are executed in the interpreter environment with all the overhead that it entails. The idea is to profile loops that are 'hot' enough to be compiled to machine code so that the following iterations don't have the overhead of the interpreter. The more iterations for a loop the potentially faster speedup. Since compiling in itself takes time obviously part of the profiling will be to determine if a loop is worth compiling or not.

    4. Re:As fast as C code??? by Anonymous Coward · · Score: 5, Insightful

      Does that also mean it's NOT as fast as native C/C++ code because C# is blatantly not and thus is part of the marketing guff that you were gulliable to believe?
      Next you'll be telling me Java hasn't got obscene memory requirements in comparison to native C/C++...

    5. Re:As fast as C code??? by Rockoon · · Score: 5, Informative

      The amount of ignorance in this community is quite disturbing. I suspect that part of the cause is the unchecked pro-c religion, which always begins "C as faster than ...."

      Clue phone guys. Ring. Ring.

      C is a high level language and like all high level languages it can either be compiled, interpreted, or even translated. JavaScript is no different than C and can also also be compiled, interpreted, or even translated. There is nothing special about the C language that makes it inherently faster than other languages. C itself is a derivation of the language BCPL, whos shortcomming was a lack of datatypes. The design goal of these language syntaxes was parsing with minimal overhead because RAM was in short supply in those days. C was not designed to be "faster" than anything.

      C is commonly mistaken to be superior because the most popular C compilers are commonly more advanced than the compilers of other languages due to simple supply and demand metrics. C is more popular, so its compilers have traditionally gotten more development effort. C itself isnt special beyond its popularity.

      --
      "His name was James Damore."
    6. Re:As fast as C code??? by zuperduperman · · Score: 5, Insightful

      It's kind of a non-sensical concept because Javascript as a language is capable of things C can't do, like eval new code at run time, modify existing types etc.

      By the time you have a fair comparison (ie. written C code that can really do everything Javascript can), you have basically written Javascript itself in C. So all these comparisons are really just based on getting subsets of Javascript where it is really doing no more than plain C can do to run as fast as similar plain C, and guess what, that is done more or less by compiling said Javascript to native code.

      I find it amusing that all these higher level languages (everything from Java, to Javascript to Python or VB) continuously promote how they are "nearly as fast as plain C now" but then a release or two rolls by and voila they suddenly announce they have improved performance by 10x or some similar metric. But when you ask the question, "oh, so are you 10x as fast as C now?", the reply will be "oh, no, but we're nearly as fast as C!"

    7. Re:As fast as C code??? by cyberjessy · · Score: 4, Insightful

      Concurrency is another big win for interpreted (and to jit-ted code like Java) code. The compiler on the target machine gets to decide how to optimize the the code based on the number of processors.

      So, _eventually_ C may be slower than JS/Python/Java. :)

      And of course, as other pointed out the article says that JS is now getting compiled.

      --
      Life is just a conviction.
    8. Re:As fast as C code??? by cbrocious · · Score: 5, Informative

      Well, you're on the right trail, but not quite right. The key difference between Javascript and C, from an optimization standpoint, is the type system. The overhead of dynamic types is quite immense even at its most optimal. I suggest looking into the architecture of the DLR -- it really shows the key problems behind compiling dynamic languages and how they're being solved.

      --
      Disconnect and self-destruct, one bullet at a time.
    9. Re:As fast as C code??? by nmb3000 · · Score: 2, Interesting

      Does that also mean it's NOT as fast as native C/C++ code because C# is blatantly not and thus is part of the marketing guff that you were gulliable to believe?

      .NET languages have a JIT compiler that is automatically invoked when the application is run. This compiles the program down to native binary code for the current architecture and operating system. The resulting binary is cached on the system so future executions can skip the compiling process. Additionally the compiler can be executed manually when the program is installed to prevent the first-run delay.

      That said, in general programs written using the .NET framework end up with the same basic overhead as a program written in C/C++. The biggest difference are all the .NET libraries and other managed features of the language. In this way C# would be about the same as C++ using a bunch of dynamically-linked 3rd party libraries and a completely autonomous garbage collection library.

      Obviously this is more overhead than a small and simple C program but that wasn't the point. I think it would be interesting if you could provide pre-compiled Javascript files to browsers for execution -- give it the bytecode directly and allow it to skip the compile process. This would make Javascript much more like Java in that regard.

      --
      "What do you despise? By this are you truly known." --Princess Irulan, Manual of Muad'Dib
      /)
    10. Re:As fast as C code??? by BZ · · Score: 5, Interesting

      For what it's worth tracemonkey is about the same speed as unoptimized C on integer math at this point. The difference is register allocation (which tracemonkey doesn't do yet).

      Moving to more complicated examples, things get more interesting. Since the jit has full runtime information, it can do optimizations that a AOT compiler cannot do. At the same time, the lack of a type system does hurt, as you point out. At the moment, tracemonkey handles this by doing type inference and then if it turns out to be wrong (e.g. the type changes) bailing out and falling back on the interpreter. Turns out, types don't change much.

      The real issue for a real-world Javascript program is that most of them touch the DOM too, not just execute JS. And right now tracemonkey doesn't speed that up at all. In fact, it can't jit parts of the code that touch the DOM. Eventually the hope is to add that ability.

    11. Re:As fast as C code??? by Anonymous+Brave+Guy · · Score: 3, Interesting

      Concurrency is another big win for interpreted (and to jit-ted code like Java) code. The compiler on the target machine gets to decide how to optimize the the code based on the number of processors.

      Which would be great, if only someone had invented algorithms that could take advantage of that in cases other than trivial parallelisation where the more cores the better. Unfortunately, understanding of how to do that is still in its infancy even in academia, which means that the combination of old fashioned compilation plus moderate run-time adjustments are still likely to blow away anything interpreted for a while to come, and JIT compilation is no big advantage yet either.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    12. Re:As fast as C code??? by xquark · · Score: 4, Insightful

      You are ABSOLUTELY wrong! C# by its very nature can not be as fast as C. There is no example you can provide where the running time of an optimized C version will be as fast or slower than the most optimized C# version. Even with JIT and supposed optimal native code generation for tight-loops there is no way you can get the same performance.

      You are obviously just regurgitating MS marketing without thinking critically.

      --
      Arash Partow's Philosophy: Be a person who knows what they don't know, and not a person who doesn't know.
    13. Re:As fast as C code??? by cbrocious · · Score: 2, Interesting

      Aaaaaaactually, this is one place where such languages can shine. I don't know about the JS implementation in Firefox, but I know that MS.NET does memory allocation voodoo where an app domain will preallocate memory for objects. That way when you want to actually instantiate an object, you don't have the allocation step. In addition, when the GC runs and deletes objects, the memory gets put back into the pool. It leads to impressive performance for creation of a large number of objects.

      --
      Disconnect and self-destruct, one bullet at a time.
    14. Re:As fast as C code??? by cbrocious · · Score: 2, Interesting

      The use of more memory really has nothing to do with performance at all. It's that you've got a decent bit of overhead on every object and it adds up. In addition to the objects themselves being bigger (say, a string being represented as a refcount, a length, and then the data), you have the memory the GC uses. In the end, we pay for the convenience of these objects in memory, but it really has very little to do with performance. You could, of course, argue that you have multiple forms of the code in memory due to JITing, but that's negligible compared to the data handled by these applications.

      --
      Disconnect and self-destruct, one bullet at a time.
    15. Re:As fast as C code??? by shaitand · · Score: 3, Informative

      Java ByteCode is NOT equal to C in speed in the real world. C# applications are NOT equal to C in speed in the real world. For that matter, C++ isn't even equal to C speed in the real world (although the margin is very slim if both are optimized correctly and C++ will work most anywhere that asm shouldn't be used IMHO).

      That said, speed is not normally the most critical thing in an application. All of the above mentioned languages have strengths of their own and perform well when used properly.

    16. Re:As fast as C code??? by Anonymous Coward · · Score: 2, Insightful

      no kidding.
      take a simple statement such as this

      x = y + z;

      you could in theory have 3 different types going on here. C cheats and just munges it up to the highest type on the right and then truncates for whats on the left.

      But in a typeless lang such as Python, VB, Javascript, etc... that thing turns into several function calls and nested switch statements. It is quite amazing how much the 'higher' languages hide from you.

    17. Re:As fast as C code??? by billcopc · · Score: 2, Interesting

      It's true that dynamic typing is a clock-cycle hog, but almost all new languages use it... I'd be perfectly happy with a strongly-typed variant of Javascript if it will run faster.

      --
      -Billco, Fnarg.com
    18. Re:As fast as C code??? by Toonol · · Score: 4, Insightful

      Does that also mean it's NOT as fast as native C/C++ code because C# is blatantly not and thus is part of the marketing guff that you were gulliable to believe?

      Yes. Javascript will, just like C# or Java, be as fast as C/C++ in theory, and just like C# or Java, slower in practice.

      On the bright side... Javascript will be as fast as C# or Java, which is certainly good enough for a lot of things.

    19. Re:As fast as C code??? by arth1 · · Score: 2, Informative

      With JIT, what typically happens is that everything is interpretted at first, and the runtime compiler begins to analyze which code segments should be optimized. Because the compiler knows not just the source material, but how it's actually running it can do a better job optimizing the code than native C compilers could.

      It's not that simple. A native compiler can do profiling as part of the compilation, and spend quite a bit of time on branch prediction and other time consuming optimizations. Five seconds extra while compiling natively might not be a problem, but five seconds extra when JIT compiling might be unbearable.

      However, where languages like javascript, java and C# will always lose the most is in preemptive task switching, where the overhead is humongous compared to the native pre-compiled code, and you'll end up not just invalidating L1 cache but L2 (and great parts of L3 too where present).

      Another loss is the lack of link time optimizations. Two identical static functions can not be identified and merged. Nor can the functions be reordered to avoid page switching. Nor can virtual address mapping be done ahead of time (like SGI's requickstart and Linux' simpler prelink).

      JIT can du run-time profiling with valid data and genuine IO? So can native compiled code. It's just more work to set it up, but it's not rocket science either.

      Yes, you can get JIT code that approaches compiled code, but only for special cases, and the price is both a much higher memory use (which can negatively impact other tasks you may have running) and increased startup time. But I have yet to see bytecode or JIT that runs faster unless the tester does some blatant cheating to get the desired results (e.g. by using different algorithms, like comparing perl's using hash tables to a linear search in C, or by disabling all optimizations in the native compiler but keeping them in the JIT compiler).

    20. Re:As fast as C code??? by beelsebob · · Score: 4, Informative

      Except that C# code isn't as fast as C code. It's 2.7 times slower.

    21. Re:As fast as C code??? by shish · · Score: 3, Insightful

      C# by its very nature can not be as fast as C

      C#, once JIT'ed, is just a bunch of binary. C, when compiled, is also a bunch of binary. Given a theoretically perfect JIT compiler vs the theoretically perfect static compiler, they'll both output exactly the same code.

      You are obviously just regurgitating anti-MS propoganda without thinking critically :P

      (Note: I'm not saying that C# implementations are *currently* as fast as C ones, just that there's nothing to stop them becoming so in the future)

      --
      I mod down anyone who says "I will be modded down for this", regardless of the rest of their comment
    22. Re:As fast as C code??? by pbhj · · Score: 2, Insightful

      I'd have thought that it's possible in a limited scenario to produce the same machine code from various high-level languages. It surely depends on the compilation not the language?

      [You're right, I'm not a programmer]

    23. Re:As fast as C code??? by hattig · · Score: 4, Informative

      1) That's the Mono implementation of C#

      2) Intel's C++ compiler is known to be one of the best but cannot handle all situations. GCC's takes 1.3 times longer. Java 'only' takes 1.96 times longer.

      2a) Intel's C++ compiler got 3 errors in the benchmarks you linked to, thus it should have been disqualified. The Intel C got 1 error and a "no program", so again, disqualified. The first compiler to run all the tests was in fact the Gnu C++ compiler.

      Ruby at 63x longer (or 30x slower than Java) should shut up all the Java haters who witter on about Ruby (or PHP at 12 slower than Java) for web development.

    24. Re:As fast as C code??? by tkinnun0 · · Score: 3, Informative

      Another loss is the lack of link time optimizations. Two identical static functions can not be identified and merged.

      Sure they can. The JVM can calculate a hash of each method's code as it loads classes, then change constant pool entries to point to the canonical version of the merged method.

      Nor can the functions be reordered to avoid page switching.

      Sure they can. The code is just data and the JVM already does heap compacting.

      Nor can virtual address mapping be done ahead of time (like SGI's requickstart and Linux' simpler prelink).

      Why would you want to do that? As I understand, the more choices you can defer until you have "boots on the ground", the better.

    25. Re:As fast as C code??? by hattig · · Score: 2, Insightful

      Clearly no matter how fast the interpreted language goes it can never be faster than C, as long as the interpreter (or JIT, or whatever) is written in C.

      So if I wrote a C compiler in Ruby, the generated code could never run as fast as Ruby?

      Even though that is what a JIT is doing, taking a bytecode (or source code) and compiling it (at runtime, thus benefiting additionally from the runtime statistics) into native code. It's been proven that JIT compiling native code into native code on the same architecture can improve performance (HP Dynamo) - maybe the original compiler wasn't very good?

      Ruby, FYI, is about 50x slower than C for the same algorithms. Your comment is true if you had left out that "or JIT, or whatever" statement.

    26. Re:As fast as C code??? by gbjbaanb · · Score: 2, Insightful

      Ruby at 63x longer (or 30x slower than Java) should shut up all the Java haters who witter on about Ruby (or PHP at 12 slower than Java) for web development.

      nonsense :) if you want machine performance, go with C/C++. If you don't care about how fast your app runs becuase you're focussed on programmer productivity go with Ruby or Python. Java/C# therefore is a worse-in-every-case option :)

    27. Re:As fast as C code??? by gbjbaanb · · Score: 3, Interesting

      you want "memory allocation voodoo" in a lower level language? easy. overload the new operator in C++ and you're done. We did this for a very very fast, very very scalable system ages ago (back when 900mhz CPUs were teh win). You basically pre-allocate a pool of fixed-size blocks (eg 16 bytes, 32 bytes etc) then grab the first free one off the relevant pool when you need an object. And without the overhead of a garbage collector too!

    28. Re:As fast as C code??? by mpcooke3 · · Score: 2, Insightful

      A JIT can work out the OS and exact chipset on which it is running and therefore choose to generate different native code optimized specifically for you system.

      Even if a static C compiler happens to have been optimized for your exact CPU, cache size and memory a JIT could still collect or access runtime statistics about your application and do optimizations based on this information - this information is not available to a static C compiler.

      Perhaps the .NET JIT sucks or always produces code that is slower than compiled C code - I have no idea. But it doesn't take a genius to work out that there are going to be cases where a JIT could produce better optimized code than a static compiler.

    29. Re:As fast as C code??? by gbjbaanb · · Score: 2, Interesting

      Programming functional style (and limiting side effects) makes this task easier.

      Programming functional style (and NO side effects) makes this task easier. With multi-threaded apps, its an all-or-nothing approach. Some side-effects will ruin your week in a difficult to reproduce (let alone debug) way.

      Even then, I think you'll find its next to impossible to achieve without programmer hints to the compiler, but then you might as well make those hints into thread features of the language and let the programmer write threaded code.

    30. Re:As fast as C code??? by smallfries · · Score: 2, Interesting

      Damn. This is going to undo my mods in this discussion.

      Unfortunately your argument has a hole in it at this point. I was just about to mod your earlier posts insightful but I thought I'd correct you instead. If you write your JIT compiler in C then it takes the Javascript as input and outputs native code. This glosses over the interactive nature of the JIT compiler but is largely true. The compiler does not execute code in the language that it is written in. It executes code in the language that it is emitting. The language being emitted is the native assembly language. So you do not have a C program that does the same thing as the same speed. You have a C program that generates code, which when run does the same thing. For this reason the output of the JIT can be faster than C, even if the JIT is written in C.
       

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    31. Re:As fast as C code??? by amn108 · · Score: 2, Insightful

      Good point.

      One thing though - please do not call C a "high level language" - this has no meaning. And since you accuse others of mangling terms, it is important to get this straight. C is human readable textual language expression. That is what it is.

      Also, be careful generalizing. It is true that since C is a plaintext, it cannot be "fast" or "slow".But because of the way it expresses certain things, variables for instance, some optimizations will be out of reach for any C compiler.

      This is why Bjarne for example advances C++ into the C++0x. The STL has gotten to the point where it was near the very performance ceiling it could provide with the C++ syntax, but some clever tricks using C++0x expression MAY help future C++0x compilers to optimize the code by having more information (which the code contains).

      Stuff like "inline", "static" etc. This is an aid to compilers in optimizing code for speed. So even though strictly speaking C cannot be fast or slow, because it lacks such properties altogether, the real world compiler implementations do allow for certain languages to emit significantly faster process images than others. Consider an assembler program. Designed for one architecture, when ported to another, it becomes useless, because the abundance of many detailed instructions confuses the compiler, robbing it of the big picture. After all, a mov, cmp and jmp sequence does not tell much about what the program is all about, and there is little room for optimization.

    32. Re:As fast as C code??? by mdmkolbe · · Score: 2, Interesting

      The overhead of dynamic types is quite immense

      That is a common myth but unless you call a factor of 2.0 immense, it it wrong. The truth is that the cost is immense only in the most naive implementations (*cough* ruby *cough). For example, while the compiler has to insert type checks whenever you do something like "+", with a well designed implementation that uses pointer tagging that should cost at most one bitwise-and and one branch-if-zero (with modern CPU pipelines that should cost a fraction of a cycle since the branch should predict fail and in the fail case there is no data dependency). In addition a well designed system will be analyzing the code and eliminate/commonize those checks whenever possible. Finally for really high performance some implementations allow you to run in unsafe mode where those checks are turned off (not applicable to untrusted JavaScript code in a browser but in other applications may be useful).

      We could spend all day debating the details of this but in reality it all comes down to the numbers so lets talk numbers. Looking at the programming language shootout, I see Python Psyco, Scheme Ikarus, and Lisp SBCL as implementations of dynamically typed languages. Their performance relative to Intel C are 6.2, 5.9 and 2.0.

      Bottom line, will dynamically typed languages always be slower than statically typed languages? Yes, but in good implementations it should only be a small (2-6) factor.

      (Note, that Ikarus doesn't even do any heavy code analysis or optimization. It's just a good straight implementation of the language. I note this in case some cry foul that SBCL uses programmer supplied type hints and Psyco uses JIT specialization.)

  2. Wow by hairyfeet · · Score: 2, Insightful

    Script kiddies will be able to infect a Windows user in record time! Seriously,I install Noscript automatically with every new build and show the customer how to use it. It has just gotten too easy to infect Windows with JavaScript and it seems like everyday you're reading of a new JavaScript exploit. So it is safer just to kill it than to take the chance. So for me and my users at least it doesn't matter how fast FF renders JScript,because it has just gotten too dangerous to use. It is like saying "We've increased the speed of ActiveX by 300%!". But as always this is my 02c,YMMV

    --
    ACs don't waste your time replying, your posts are never seen by me.
    1. Re:Wow by erayd · · Score: 2, Insightful

      That attack was via flash, not javascript.

      --
      Forget world peace, bring on -1 pointless
    2. Re:Wow by hairyfeet · · Score: 2, Interesting

      Because then their damned Lexmark printers don't work and I go out of business? Until linux can run Windows games with a "clicky clicky,next next next" installer,and I can install those damned Lexmark all-in-ones that everyone seems to have there is just no way i can survive selling Linux boxes. i tried and ended up having to reformat them and put Windows because folks didn't want them. You can talk about how much safer Linux is to a customer all day long,but if it doesn't work with their hardware and they can't easily install and play their games,it is no sale.

      And as for flamebait? Has nobody seen the massive amounts of JavaScript exploits hitting the net lately? If this was an article touting an increased speed for ActiveX would we all be cheering? JavaScript is the script kiddies tool of choice ATM,and it is just getting worse. Don't believe me? Just go here or here and look for yourself. Or type "JavaScript Exploit Firefox" into Google and see how many hits you get. I counted over 702,000! We need to be increasing the security of JavaScript,not the speed. Who cares how fast it'll render if you are afraid to allow your users to have it on for fear of being hacked? But as always this is my 02c,YMMV

      --
      ACs don't waste your time replying, your posts are never seen by me.
  3. Precursor to more of Firefox being in JS by i.of.the.storm · · Score: 4, Insightful

    Interestingly, one of the linked blogs talks about how this could lead to more of Firefox being written in Javascript. I haven't done much non-web related Javascript programming, and I haven't really used those new frameworks, but it seems to me like application programming in Javascript is like trying to hammer a nail with the handle of a screwdriver. Sure, it might work, but there are much better tools for the job. What do you guys think?

    --
    All your base are belong to Wii.
    1. Re:Precursor to more of Firefox being in JS by Shados · · Score: 4, Insightful

      Javascript, especially when tied to a full featured framework such as ExtJS, is actually freagin cool. Add some IDE support, like in Visual Studio 2008, or in Aptana, and you've got one rock solid, multi purpose dynamic language that is already mainstream and well supported.

      Not as cool as Groovy, and I'm a static typing fan myself, but thats the next best thing.

    2. Re:Precursor to more of Firefox being in JS by bcrowell · · Score: 2, Insightful

      What do you consider to be the problem with JavaScript as a general-purpose programming language? I think it's a sweet language. Just because a lot of people learn it as a set of cookbook recipes for doing little things on web pages, that doesn't mean the language isn't a good language. The only really serious problem with JavaScript, IMO, is the lack of standardization of the DOM, and that's not even a real language issue, it's just a problem with the way the language gets interfaced to browsers.

    3. Re:Precursor to more of Firefox being in JS by i.of.the.storm · · Score: 2, Informative

      Well, XUL is just an XML language used for the UI. As far as I know the main codebase is C++/JS right now, but probably more C++ than JS.

      --
      All your base are belong to Wii.
    4. Re:Precursor to more of Firefox being in JS by T-Ranger · · Score: 2, Interesting

      Its a question of what is "core framework" type stuff, and what is "actual application". Things like UI layout, interaction, networking, security, caching, rendering - as well as executing run time JS - is "core" functionality. I'd wager that >90% of binary code of Fx and, say, Thunderbird is the same.

      And most of that core stuff is written in C++. Well, actually, its written in an obscure dialect of C++, developed when Netscape ran on a dozen various platforms, with mutually incomparable cpp compilers.

      But that 10% that makes an application engine a web browser, or a mail client.. Most of that is written in Javascript. And most of it is "leaf" code, with not much cross calling, or dependencies that don't go through the underlying engine. Stuff that the just about total lack of "programming in the large" that Javascript has doesn't much matter.

    5. Re:Precursor to more of Firefox being in JS by Randle_Revar · · Score: 2, Informative

      JS drives most of GUI interaction in FF. The bulk of the C++ is down in gecko, for rendering speed.

    6. Re:Precursor to more of Firefox being in JS by RedWizzard · · Score: 2, Insightful

      Interestingly, one of the linked blogs talks about how this could lead to more of Firefox being written in Javascript. I haven't done much non-web related Javascript programming, and I haven't really used those new frameworks, but it seems to me like application programming in Javascript is like trying to hammer a nail with the handle of a screwdriver. Sure, it might work, but there are much better tools for the job. What do you guys think?

      Why do you think Javascript is so unsuitable? I've done a fair bit of application programming in Javascript and it's fine so long as you keep your code structured (so no different to Perl or even C in that regard).

    7. Re:Precursor to more of Firefox being in JS by 93+Escort+Wagon · · Score: 4, Funny

      Gecko *is* a full-featured framework.
      ExtJS is for the more restricted web stuff without code signing.
      But then, the parent probably doesn't even know what a prototype is or a closure.

      Reading your first two sentences, I found your post informative and worthwhile. But, with the last sentence, the voice reading your comment in my head suddenly turned into that whiny, high-pitched geek voice they use on cartoons.

      --
      #DeleteChrome
    8. Re:Precursor to more of Firefox being in JS by Anonymous Coward · · Score: 2, Funny

      its not your fault. java made you retarded.

    9. Re:Precursor to more of Firefox being in JS by eclectechie · · Score: 2, Interesting

      Afterall, Firefox developers probably aren't the most 1337 C/C++ coders out there, but they are probably amongst the best JavaScript ones.

      Whoa! Not so fast!

      The Javascript interpreter in Firefox is written in C, and related stuff (XPConnect, etc.) is written in C++. You should go read it some time; this stuff was definitely NOT written by mere mortals.

      You can browse the source at the Mozilla Developer Center; no link, so only the truly interested will go there. Look in mozilla/js/src.

      --
      "The empty vessel makes the greatest sound." -- William Shakespeare; Henry V, 4. 4
    10. Re:Precursor to more of Firefox being in JS by shaitand · · Score: 2, Interesting

      'actually, its written in an obscure dialect of C++, developed when Netscape ran on a dozen various platforms'

      Really? I was under the impression that the core of Firefox 1.0 was a complete rewrite because the developers determined that the old Netscape stuff was a mess that wasn't worth moving forward with.

    11. Re:Precursor to more of Firefox being in JS by Plaid+Phantom · · Score: 2, Insightful

      Give JS some time. I had similar feelings when I first stepped into it, but now I've come to appreciate not having to worry about datatypes and the like.

      There are occasions where I would appreciate some basic support for classes. But I suppose they could be mimicked through function variables in some way.

      --
      All comments are properties and trademarks of the voices in my head. Not like I'm gonna claim them.
  4. Premature optimization.... by gandhi_2 · · Score: 3, Insightful
    is the root of all evil. --C. A. R. Hoare

    Now if we can just stop all the xss. Now it's just xss 20-40 times faster (in certain contexts).

    Actually, if JS gets fast enough, it could rival Flash. This is a good thing.

    1. Re:Premature optimization.... by Shados · · Score: 5, Funny

      Considering how long Javascript has been out, and that javascript intensive applications are clearly there in the present, I don't think this is premature =P Its late!

    2. Re:Premature optimization.... by Randle_Revar · · Score: 3, Informative

      Like stupid simple multimedia.

      like SVG, <canvas> <audio> and <video>

    3. Re:Premature optimization.... by Just+Some+Guy · · Score: 4, Informative

      intensive purposes

      "Intents and purposes." Somewhere, an English teacher cries.

      --
      Dewey, what part of this looks like authorities should be involved?
    4. Re:Premature optimization.... by poopdeville · · Score: 2, Funny

      Have you considered that his purposes might in fact be intensive?

      --
      After all, I am strangely colored.
    5. Re:Premature optimization.... by Ndiin · · Score: 2, Insightful

      You fail. It's a pun, dude.

    6. Re:Premature optimization.... by shreevatsa · · Score: 2, Informative

      is the root of all evil. --C. A. R. Hoare

      No, Donald Knuth, Structured Programming with go to Statements, ACM Computing Surveys, Vol 6, No. 4, Dec. 1974 (p.268). (Unless you can find a reference for Hoare having said it. See here.)

    7. Re:Premature optimization.... by ArsonSmith · · Score: 2, Funny

      Somewhere, a comedian cries. Not sure if it's from your missing it or the original joke.

      --
      Paying taxes to buy civilization is like paying a hooker to buy love.
  5. Yeah.. but... by EmagGeek · · Score: 2, Funny

    Will it make my Sony Bluray player take less than 10 minutes to boot and play a disc?

  6. Not bad by neokushan · · Score: 5, Insightful

    Firefox 3 already gave quite a nice performance boost to Javascript, enough to actually impress me (google maps is a great demonstration of this). It's good to see they haven't stopped there and are busy improving it further, a lot of software developers tend to spend too much time on making new features and not enough time fixing/optimising the existing one, but I think after the backlash from FF2's memory usage, Mozilla has rethought their priorities and I'm glad to say they're doing things right.

    --
    +1 IDisagreeSoHeMustBeATrollOrAnAstroturferOrAShill
    1. Re:Not bad by nyctopterus · · Score: 2, Insightful

      Yes. If you think about it, this is the best way to add "features"--faster javascript means more complex code can be written and run in browsers; including both web pages and extensions.

  7. Oh no! by Das+Modell · · Score: 3, Funny

    This improvement has boosted JavaScript performance by a factor of 20 to 40 in certain contexts.

    What does the scouter say about its power level?!

  8. Dr. Michael Franz by tknd · · Score: 4, Interesting

    The theories behind tracing optimization were pioneered by Dr. Michael Franz and Dr. Andreas Gal, research scientists at the University of California, Irvine.

    Hey that's my old compilers professor and my school!

    This PDF looks like the paper the article is referencing.

  9. Performance is great and all by MasterC · · Score: 5, Interesting

    I've written my share of JS-heavy apps and the boost will be nice for that. However, my complaints with JS don't lie with performance.

    • Tied too much to the browser. JS works great for some (some love it) but syntactically I hate every last part of it. However: web == JS so I have no other option.
    • Typing. Yeah, it has types but they're practically worthless. A Number represents a float/double and an integer? Say what?
    • Type checking.
    • No reflection.
    • No dictionary. Sure, you can use an Object as a dictionary but the second someone prototypes it to add root functionality then you've introduced other items in your "dictionary". (I'm looking at you prototype.js)
    • Nothing resembling libraries. No dependencies, etc.
    • It's bastardized to accommodate the short comings of HTML (drop downs, combo boxes, etc.)
    • Obey's Postel's law too much. Error handling and exceptions is a sad state.
    • No threading. No locking. Nothing resembling concurrent programming. The more complicated your app the more arbitrary events and multithreading are important.
    • No classes. Prototyping & cloning is a neat paradigm for where it fits but so do class-based objects. This isn't just JS I have this problem with. Being able to do both and using the right one where necessary would be great.
    • When is the document loaded? And if you have two libraries vying for that event? (See library complaint)
    • Since it has no real library support I have to blame the browser for not providing more general functionality. XML parsing, date stuff is abysmal, and other "routine" stuff you do when making web sites.
    • Scoping. Scoping is mind-numbingly bad.
    • Namespaces (again, see library complaint) are implemented via object nesting, which isn't really namespaces
    • Logging and debugging. I haven't delved into the likes of Firebug to see how it works but when the language (again no libraries so I blame the language) itself only provides alert() then it's clear the creators weren't thinking about debugging at all. At least IE natively will let you debug JS!
    • Standard dialogs are alert() and confirm(). Anything and everything else you have to roll your own. I really, really don't want to write something for a Yes/No dialog instead of OK/Cancel confirm().
    • Drag-and-drop. If you've done it then you know it's no walk in the park.
    • Browser identification and JS version identification. Why should I have to jump through hoops, poke & prod things, and guess at what my JS run-time is? Everyone has their own means to detect it and it's absolutely ludicrous. I'm fine if there's no real "standard" but at least give me the variables to know what I'm writing against so I can adequately work with it. (Again tied too close to the browser.) Every language I use frequently has means for me to identify such things.

    I think that's enough. I'm sure you could easily argue back but this is my rant about why this boost is not the saving grace to JavaScript.

    Basically my point is that performance does not bring JS up another tier. It just prolongs the pain of having a grossly inadequate language for rich application development. JS does have some nice things about it (first-class functions, closures, for(..in..), etc.) but in no way would I consider it "good" for application development.

    Step back and realize the movement is pushing applications into the browser. Yes, the same apps that currently use threading; the same apps that have more than 4 input widgets (input, select, radio, checkbox); the same apps that run slow even when written in native code; the same apps that depends on libraries of code; etc. JavaScript, as is, is not The Answer and this performance boost is just a Bluepill in disguise.

    --
    :wq
    1. Re:Performance is great and all by Anonymous Coward · · Score: 2, Informative

      I'm sure you could easily argue back

      I think I will

      Tied too much to the browser/Bad syntax

      Browser means it runs anywhere, syntax is C-like.

      No reflection.

      You can enumerate an object's methods, variables, etc as you can any other hash table.

      No dictionary/Adding stuff to Object (prototype.js)

      {} is a dictionary, no need to use Object. Even the author of prototype.js realized that adding methods to Object is a bad idea. I will complain that JS hash keys can only be strings.

      No threading. No locking. Nothing resembling concurrent programming. The more complicated your app the more arbitrary events and multithreading are important.

      setTimeout and setInterval are your friends. Cooperative multitasking makes some classes of problems more difficult, but greatly simplifies the language. There's quite a bit of infrastructure needed for correct behavior in the presence of preempting.

      Scoping. Scoping is mind-numbingly bad.

      Agreed. JS needs block level scoping like other sane languages.

      Namespaces (again, see library complaint) are implemented via object nesting, which isn't really namespaces

      It doesn't need to be called one to be one.

      Logging and debugging/Haven't used firebug/Creators weren't thinking about debugging

      If you haven't used Firebug, you are missing out! Debugging is no worse than other languages, and far better than IE's debugging support.

      Standard dialogs are alert() and confirm(). Anything and everything else you have to roll your own...

      Dialogs are modal... I think the absence of dialogs on the web encourages more usable alternatives.

      Browser identification and JS version identification. Why should I have to jump through hoops, poke & prod things, and guess at what my JS run-time is?

      Don't. Trigger off of capabilities rather than browsers. There may be a few instances where you have to specifically check for IE, but this is an exception rather than a rule.

      ... [JS is] a grossly inadequate language for rich application development...

      Besides the scoping gone horribly wrong, I can't agree with your conclusion.

    2. Re:Performance is great and all by MasterC · · Score: 2, Insightful

      or the inability to differentiate the DOM from JS the language

      Wow, you get a gold star for arguing word semantics unnecessarily! (Double bonus for intentionally being flamebait.)

      The context of the entire thread, the performance boost, and my comment is that of JavaScript in web apps. My comment was *clearly* about JavaScript in the context of web apps. Hell, my first bullet was that the language and browser are tied too closely together. I guess you read what you want to read.

      That said: practically there is no difference between DOM & JS. JavaScript has no libraries or modules which means all functionality IS the language (no more differentiable than alert()). Again: if there was any mention of writing stand-alone apps or tools in JavaScript then you'd have more of a point but what Firefox, IE, etc. provide as "JavaScript" is, de facto, JavaScript.

      I hate to see what you work on to call threading, logging, debugging, reflection, missing XML parsers, minimal date support, drag-and-drop, browser identification, etc. (and that's just where I stopped) just "missing bits"? If you want to write real apps then that stuff is not "bits" but necessities.

      --
      :wq
    3. Re:Performance is great and all by eclectechie · · Score: 2, Interesting

      I think that's enough. I'm sure you could easily argue back but this is my rant about why this boost is not the saving grace to JavaScript.

      Darn right. Virtually everyone one of your complaints is either based on personal taste (classes, strict typing, etc), missing bits of framework (threading, logging), or the inability to differentiate the DOM from JS the language (load order issues, dialog complaints, etc). About the only legitimate complaints I was able to identify are:

      * lack of modules
      * lack of namespaces

      And both of these are well-known issues that were *supposed* to be addressed in JS4 (and hopefully will be addressed in the future).

      Spoken like someone who has not programmed in enough languages to understand the GP's points.

      For myself, the "Postel's Law" item has been the cause of a lot of grief, tied in a dead heat with the lack of strict typing. Grrrr....

      --
      "The empty vessel makes the greatest sound." -- William Shakespeare; Henry V, 4. 4
    4. Re:Performance is great and all by tepples · · Score: 2, Insightful

      Step back and realize the movement is pushing applications into the browser. Yes, the same apps that currently use threading; the same apps that have more than 4 input widgets (input, select, radio, checkbox); the same apps that run slow even when written in native code; the same apps that depends on libraries of code; etc. JavaScript, as is, is not The Answer

      Then what technology is The Answer on a platform where native code must be digitally signed by someone other than the user but JavaScript code need not be? Examples of such platforms include PSP, PS3, Wii, iPhone, and some enterprise installations of Windows.

    5. Re:Performance is great and all by MrMunkey · · Score: 2, Informative

      At least IE natively will let you debug JS!

      That's the first I've heard of that. In order to debug JavaScript you either have to have Office installed, or download the MS Script Debugger. IE does report errors, but their description is horrible. I've found that just the error console in Firefox is much, much better than IE's error reporting. You really should look into Firebug. It's invaluable

  10. Fast as C but uses lots more memory by CustomDesigned · · Score: 5, Informative

    In general, JIT systems can really provide CPU performance near C speed, or even faster for some benchmarks, once the application gets going. The catch is that you pay two penalties: startup time and memory. Lots of memory: for keeping stats on what needs compiling, trampolines to call in and out of the interpreter vs. JIT native code, and the native code *plus* the byte code.

    Even dynamic languages like Python can have a JIT - it specializes a function for various combinations of argument types, and then provides a catchall generic version for general objects. The catchall version is not much faster than the interpreter, usually (in fact it could *be* the interpreter), but the specialized versions can be much, much faster. (Also blocks can be specialized within any of the function versions.) But all those specialized versions take up memory. So the JIT keeps stats and tries to make only the ones that really help.

    1. Re:Fast as C but uses lots more memory by CoughDropAddict · · Score: 5, Interesting

      The catch is that you pay two penalties: startup time and memory. Lots of memory: for keeping stats on what needs compiling, trampolines to call in and out of the interpreter vs. JIT native code, and the native code *plus* the byte code.

      That JITs automatically incur large memory footprint or startup time penalties is the logical conclusion you come to if you look at the JVM. But the truth is that JITs don't have to suck as much as the JVM does.

      For example, take LuaJIT, a JIT for the already-speedy dynamic language Lua. It speeds up Lua roughly 2-5x while starting up in less than 0.01 CPU-seconds and introducing less than 20% memory overhead. It also takes 2-8x less memory and starts up 10x faster than the JVM, despite the fact that Lua is compiling from source, whereas the JVM starts with bytecode.

      I've never looked at the source for the JVM, so I can't say just why it takes so many resources, but I can only conclude that it's because Sun just doesn't consider startup time or memory footprint a priority.

    2. Re:Fast as C but uses lots more memory by ensignyu · · Score: 4, Interesting

      So, really the memory access will be a bottle neck, you can never hope to have your program in cache and it will be much slower than C.

      That's not always a given. If we go by the old rule of thumb that 80% of the time is spent in 20% of the code, we could stick that 20% in one place to maximize cache usage. You can even optimize so that if branches that are taken are kept in the cache, and infrequently executed branches are moved out of the way, maybe in a separate page so they can be swapped to disk.

      You can do this to a certain degree at compile time, but often you don't know in advance what paths are going to be hot (it might be based on the data) and it may even change as the program runs.

      In practice, if someone tells you that Java is faster that C, they're speaking mostly in hypotheticals. Java and another high-level languages encourage so many layers of abstraction that the sheer amount of code that needs to run will probably make it slower than your typical C program. There's also a lot of things, particularly anything that needs to be dynamic, that you can't easily/efficiently compile.

      What's interesting is LLVM and .NET, where you can run C/C++ code in an interpreted/JIT-compiled environment. Potentially, with the optimizations mentioned above, you could have C code running in a virtual machine that's faster than statically-compiled C code.

    3. Re:Fast as C but uses lots more memory by Mithrandir · · Score: 5, Informative

      What's interesting is LLVM and .NET, where you can run C/C++ code in an interpreted/JIT-compiled environment. Potentially, with the optimizations mentioned above, you could have C code running in a virtual machine that's faster than statically-compiled C code.

      HP did a lot of research on this about 4-5 years ago where they proved this was exactly the case. Do some googling for HP's Dynamo project. Real runtime knowledge of exactly what is being used and when leads to better optimistaion than static optimisation.

      --
      Life is complete only for brief intervals in between toys or projects -- John Dalton
    4. Re:Fast as C but uses lots more memory by adonisv1 · · Score: 2, Informative

      You can look at Psyco which functions like a JIT for Python.

    5. Re:Fast as C but uses lots more memory by ensignyu · · Score: 3, Insightful

      http://psyco.sourceforge.net/

      The really neat thing about it is that you can just load the module and call some functions, and it'll start JIT compiling your Python code for some moderate speedups (particularly string and number crunching). It doesn't need a special version of CPython or anything.

      The original author is no longer developing it though -- he's working on PyPy, the Python interpreter/JIT written in Python. I think they're up to about half the speed of CPython, which is pretty impressive considering how slow Python is.

    6. Re:Fast as C but uses lots more memory by lubricated · · Score: 4, Informative

      So far JIT's just aren't as fast as C. They are very far along. People are using them for programs which may run for days at a time. This has more to do with having an easier time developing in a higher level language. In my experience java rivals and often surpasses C++ programs heavily reliant on the stl. Where I work, speed or features win marketshare and programs written in C are performance kings. Python and java are becoming more popular.

      --
      It has been statistically shown that helmets increase the risk of head injury.
    7. Re:Fast as C but uses lots more memory by Z00L00K · · Score: 2, Insightful

      Since web browsers usually can cache JavaScript it will be useful to cache the compiled JavaScript.

      Next step is that we shall be able to see a server-side compiled JavaScript, but we will have to wait for browsers to support that. In that case we will be able to have language-agnostic browsers since the compiled code won't necessarily have to reflect which language that was used to write the script.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    8. Re:Fast as C but uses lots more memory by H3g3m0n · · Score: 2, Interesting

      Makes sense, by compiling for a specific architecture you can get a %5-%10 performance increase. If the JIT compiler uses less than the %5-%10 and can optimise for the arch then its a saving. Of course it won't be a saving over compiling the code specifically for the architecture in the first place, but it is rare to see that (Gentoo'ers and other build from source distros). And multi-core processors are going to further reduce the speed since you can just offload the JIT to one of the other cores (of several if its threaded) and since few programs are very well threaded it shouldn't be a problem (and the kinds of things that are well threaded generally are longer number crunching tasks so the initial compile will be a small amount of the overall speed). In addition to that you might find other cool things like the ability to thread non-threaded code in some instances. For instance there is no reason for a basic function that's return value isn't used for a fairly long time not to be threaded, you can sort a list while you continue pass it on through the rest of the program as long as you don't actually need to read the content to decide where to send it or try and do something to it. As for memory, ram is cheap enough now that it shouldn't be a problem, 4GB will be fairly standard soon. Ubuntu already burns around 500Mb for me doing nothing.

      --
      cat /dev/urandom > .sig
    9. Re:Fast as C but uses lots more memory by Haeleth · · Score: 2, Insightful

      In general, JIT systems can really provide CPU performance near C speed

      You mean "in theory", not "in general". In general, real-world JIT systems are significantly slower than native code, though they certainly are noticably faster than regular bytecode, which in turn is faster than a pure interpreter.

    10. Re:Fast as C but uses lots more memory by Bj�rn · · Score: 4, Informative

      but never compared to C.

      Here is a somewhat old comparison of Java and C/C++ performance, done by the University of Southern California. Note that the article was written in 2003 and updated in 2004. Javas performance has improved significantly since then, most noticeably in JDK 1.6. This is the conclusion:

      Java is now nearly equal to (or faster than) C++ on low-level and numeric benchmarks.

      --
      Never express yourself more clearly than you are able to think. --Niels Bohr
    11. Re:Fast as C but uses lots more memory by Cyberax · · Score: 3, Informative

      "It wouldn't be JIT then, it'd have to be 'before the code is executed', because you wouldn't want the compiler to spring into action, run on core 2 whilst core 1 twiddles its thumbs waiting for the compilation to finish."

      For example, in Java HotSpot it _already_ works this way. A special thread compiles the code while other thread(s) work in interpreted mode. When compilation is finished, other thread(s) switch to this new fast compiled code.

      Also, there are optimizations in Java HotSpot which are _impossible_ to do using static analysis.

    12. Re:Fast as C but uses lots more memory by Cyberax · · Score: 4, Informative

      What a bunch of stupidity...

      First, "programs reliant on STL" can be as fast as anything on plain C. And very often they can be faster (for example, because dwarf-style exception handling is faster than return result checks).

      Second, JITs are NOT "very far along". HotSpot is _already_ faster than C/C++ on some benchmarks. And it's only going to get better, because HotSpot can use real runtime statistics to guide optimizations (C/C++ can also use Profile Guided Optimizations but it relies on static data).

    13. Re:Fast as C but uses lots more memory by Z00L00K · · Score: 2, Informative

      It compiled it into bytecode and references to variables, so it was reversible - just like Java.

      The references built was then used during execution as offsets into a jump table, which meant that it was fairly effective and the variables were referred by address to the definition area and not by name, which also did speed up things.

      See the link in my previous post for a few performance figures to compare with other systems of the time.

      The really boring thing with that computer was that the graphics wasn't really good, but you can't get everything. But compared to most computers of the time it was fairly competent and the successor the ABC800 which also used the same technique was in extensive use for business purposes in Sweden.

      It shall be noted that both computers were running a 3MHz Z80A (so it wasn't even using the full capacity of the Z80A for some reason!

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
  11. Re:The Greatest Idea by Spy+der+Mann · · Score: 4, Funny

    Expect this discussion to be full of astroturf, red herrings and trolls

    Ah, no problem. Just give the red herring to the troll and he'll let you pass the bridge :)

  12. That's pretty impressive... by Anik315 · · Score: 4, Interesting

    It would nice to see some demos of this with John Resig's Processing.js. It could definitely use the kind performance boost being discussed here.

    In addition to a performance considerations, it would also be nice to have addtional some additional bit depth in JavaScript.

    I anticipate JavaScript will continue to be very popular, but there are alot a lot of reasons other than performance that people won't want to use the language for writing desktop applications over C/C++/Java. That said, there have been alot of recent developments that have made me cautiously optimistic about the future of the language along these lines.

  13. Re:The Greatest Idea by Yvan256 · · Score: 4, Funny

    I am rubber, you are glue.

  14. Re:The Greatest Idea by Anonymous Coward · · Score: 3, Funny

    It won't be just from the Windows side - a good chunk of Linux-heads hate anything but static black text on plain white backgrounds. So this should get interesting...

    Goes to show what you know. Real Linux-heads hate anything but static white or green text on plain black backgrounds.

  15. Re:Javascript is good by fimbulvetr · · Score: 2, Informative

    My wording was wrong - I did understand your paragraph and was merely trying to point that JS could be very helpful when doing SS'ing since it has native Dom parsers and methods. Indeed, there are many things in JS that lend itself well to being able to "read itself" - see Douglas Crockford's comments on JSLint, for instance.

  16. Re:The Greatest Idea by Anonymous Coward · · Score: 2, Informative

    Ever since the matrix, it's been green text on black background. That movie was 10 years ago, get with the times man!

  17. Re:Javascript can never run as fast as C by martin-boundary · · Score: 2, Insightful
    Eh? My _point_ was, and still is, that Javascript has no hope of being comparable to C speedwise in ordinary use, no matter how much effort is put into clever profiling and jitting. It's a meta-issue, and claiming the speed of C as a goal is basically marketing speak.

    However, I never said that improving JS performance is undesirable. It's the old scripting vs low level programming debate: Low level is faster, but needs more expertise and programmer time. Pick the best tool, etc.

    The Mozilla architecture is a case in point. The UI is controlled by JS functions, which delegate all the hard work to XPCOM objects. That's more overhead than controlling the UI in C++ directly, but has the _huge_ advantage of being easier to modify and adapt the code for developers.

  18. Re:The Greatest Idea by totally+bogus+dude · · Score: 5, Interesting

    Sharepoint 2007 is a good example. Editing of the content is via a browser-based interface, which is quite script heavy. What's interesting is just how script heavy it is. While testing on an old laptop we have connected to an external link, I was a bit dismayed at how slow loading our site was. I got the impression that the browser was pausing before displaying the page for some reason.

    Opening up task manager, I saw that before IE displayed the page, it would spin on 50% CPU (on an old hyperthreaded P4) for over 5 seconds before finally rendering the page. After some experimenting which yielded consistent results, I tried Firefox and the difference was dramatic, to say the least.

    The upshot of all this is that we may need to recommend to our clients that they use Firefox to edit their Sharepoint 2007 sites, because it provides a significantly better experience than IE does if you have older hardware. On my own desktop at work (a reasonably modern Core 2 Duo) IE does spike the CPU usage, but generally it's for less than a second or two so it's not really distracting. Firefox is faster, but both are quick enough that it doesn't make a real difference to a human.

    Completely off-topic: I used refreshes of the task manager process listing to judge how long IE was spinning for. I always assumed the default setting was to refresh the list once per second, and some quick testing now confirms that that is what it does. If you go to View -> Update Speed, the default setting is "Normal". The status tip for this setting says "Updates the display every two seconds". Clearly a lie - or is it? If you select "Normal", then the display does in fact update every two seconds, and there doesn't seem to be any way to get it to go back to refreshing once per second.

  19. Java/C#/C++/C equally fast by pinkfloydhomer · · Score: 2, Interesting

    About the memory, you are correct (for now).

    About the speed:

    I made a benchmark written in a pure C subset of C/C++/C#/Java in all of these languages. A simple benchmark involving calculations with integers (primes) and floating point numbers (sums of products of square roots of primes). The result, when running a bazillion iterations:

    C# and Java took 50 seconds, C++ took 49 seconds and C took 51 seconds. Other benchmarks I made showed similar results.

    So for pure calculating, C#/Java + JIT is equally fast. For big real-life systems involving a lot of other stuff, the results might be different.

    But it is a long time ago that Java et. al. were 3 times slower than native code.

    1. Re:Java/C#/C++/C equally fast by Toonol · · Score: 4, Insightful

      I can't speak to the C# benchmark, but I can't imagine any case where C++ would outperform C in straightforward computation. The fact that you have C++ two seconds faster indicates to me an error margin of at least two seconds in your tests.

    2. Re:Java/C#/C++/C equally fast by makomk · · Score: 2, Informative

      IIRC, it's possible for the same program to be faster when compiled using the C++ mode of the compiler than the C mode, due to C++ being stricter and allowing some optimisations that aren't safe in C. Don't quote me on this, though.

  20. Re:Start selling printers by hairyfeet · · Score: 4, Insightful

    Does the DS have Age of Empires? FEAR? The simple fact is if I tried that the shop down the street would get the business and I am out on the street. You can't force your customers to take what they don't want. Rule One of Business: The customer is always right. I had four Linux boxes in the shop and had to reformat them because they were just gathering dust. The home user wants to be able to take the software he/she buys at Wal Mart and go "clicky clicky,next next next" and have it work,PERIOD. if it doesn't the machine is "broken" and it gets returned. And NOBODY wants to be handed a DS when they ask about games. Do you HONESTLY think if I did that to my customers they wouldn't just walk out?

    This kind of attitude is EXACTLY why Linux has been stuck in the hobbyist section for so long. Instead of an honest discussion about what customers wants and needs you get told "Buy a PS3" or "stick with Winblowz". Guys like me would love to be able to sell easy to maintain Linux units,but the simple fact is we don't want to starve. My customers DON'T WANT a PS3,they want to pick up a game at Wal Mart and have it work. They DON'T WANT a $200 HP added to the price of the unit,they want to take their Lexmark all-in-one that they are quite happy with and have it work. If I was to adopt that elitist attitude my shop would be out of business in less than three months,instead of being busier than ever. Because I ask what they are going to do with their new PC and design it around their needs. Here is what I have found would be needed for Linux to take off in the home/small business sectors based on my customers:

    1. VB6 support out of the box. Every single SMB I've ever done business with have one or more VB apps that are essential to the companies survival. No VB,no sale. 2. Windows software and games should be installable from the CD,especially games. If they pick up something at Wal Mart it had better work when they put in the disk. No easy way to install games? No sale. 3. An NDISWrapper for printers,especially those damned Lexmark all-in-ones. They are popular for a reason. They are cheap and give the folks what they want,an easy to use all-in-one printer/scanner/fax. No Lexmark support? No sale.

    Without these 3 things I just can't give a Linux machine away. Folks simply don't want them. I have been able to sell the EEE because folks look at them as a "toy" that they don't expect to do the things a "real" computer can. But with a desktop they have expectations: they expect the software they buy to run,they expect the programs that their business depends on to work,and they expect their hardware like printers to just connect and go. Without that,they just sit there gathering dust. But as always this is my 02c,YMMV

    --
    ACs don't waste your time replying, your posts are never seen by me.
  21. No by extrasolar · · Score: 4, Insightful

    And stay off the chans.

  22. Re:suggestions for improvement by Nicolas+MONNET · · Score: 2, Insightful

    So basically you suggest doing the exact opposite of what has been shown experimentally to work very in the article?

  23. Re:Server-Side is still the way to go if you can by ColaMan · · Score: 3, Insightful

    Doing anything that can be done server-side on the client side is generally a bad idea

    Oh, I don't know - what about the simple stuff like form validation? On a high traffic site, receiving a complex form from a client, only to have to send a page back saying "sorry, you forgot this field,do it again" seems to be a waste of both the servers resources and the user's time. Better to just have a JS popup telling them and changing focus to the problem field - no effort on your server's part is needed.

    Of course, double-check everything you get at the server, just give the client a chance to sort it out at their end first before troubling you with it.

    --

    You are in a twisty maze of processor lines, all alike.
    There is a lot of hype here.
  24. Re:The Greatest Idea by moonbender · · Score: 3, Interesting

    On the off-topic note: Don't even bother thinking about the task manager, just download the Process Explorer and set it to replace the task manager. It's light weight and vastly superior to the task manager in every way. One of the utils I miss in Linux.

    --
    Switch back to Slashdot's D1 system.
  25. Re:The Greatest Idea by gbjbaanb · · Score: 2, Informative

    tip: don't use Task Manager, for investigating performance issues, use PerfMon (under administrative tools on your start menu).

    Open a performance report, add the %CPU counter for just IE (it'll be under the Process counter set).

    You can get it to update faster than 1 second default, and get it to log to a file instead so you can view it later. Add a network counter and memory counter too for more insight.

  26. C is inefficient by speedtux · · Score: 4, Interesting

    You are ABSOLUTELY wrong! C# by its very nature can not be as fast as C.

    The C# JIT has all the information that a C compiler has (essentially, the entire source code). In addition, it has a lot of global program information and it has runtime statistics. And, the C# language has better defined semantics. All of this taken together means that C# can be optimized better than C.

    In terms of performance, C is a lousy language; Fortran is a "faster language" than C.

    The only reason C even runs as well as it does is because people have invested 20 years in making compilers squeeze out the last cycle, because C compilers play fast and loose with C semantics at high optimization, and because even CPUs have been tuned to accommodate its semantics.

    1. Re:C is inefficient by speedtux · · Score: 2, Insightful

      Huh? You say that C is a lousy language for performance and then commence to list the reasons why it is a good language for performance?

      No, I list the reasons why C programs benchmark well even though the language is hard to optimize.

      Anyway... it seems C can be optimized better than Fortran [...] but real-world examples and benchmarks do not agree with you.

      The fact that you think that those numbers are in any way relevant to what we are talking about just shows that you know absolutely nothing about benchmarking or high performance computing.