Slashdot Mirror


Asm.js Gets Faster

mikejuk writes "Asm.js is a subset of standard JavaScript that is simple enough for JavaScript engines to optimize. Now Mozilla claims that with some new improvements it is at worst only 1.5 times slower than native code. How and why? The problem with JavaScript as an assembly language is that it doesn't support the range of datatypes that are needed for optimization. This is good for human programmers because they can simply use a numeric variable and not worry about the difference between int, int32, float, float32 or float64. JavaScript always uses float64 and this provides maximum precision, but not always maximum efficiency. The big single improvement that Mozilla has made to its SpiderMonkey engine is to add a float32 numeric type to asm.js. This allows the translation of float32 arithmetic in a C/C++ program directly into float32 arithmetic in asm.js. This is also backed up by an earlier float32 optimization introduced into Firefox that benefits JavaScript more generally. Benchmarks show that firefox f32 i.e. with the float32 type is still nearly always slower than native code, it is now approaching the typical speed range of native code. Mozilla thinks this isn't the last speed improvement they can squeeze from JavaScript. So who needs native code now?"

289 comments

  1. "So who needs native code now?" by Anonymous Coward · · Score: 5, Informative

    Umm, anyone who wants their code to not run substantially slower. Seriously, do you front end programmers really think nobody does numerical simulations or other performance-sensitive work? In my line of work, I'd kill for the opportunity to make my code 1.5 times faster!

    1. Re:"So who needs native code now?" by gagol · · Score: 2

      Also, the major down point of JavaScript I found to hinder performance in ambitious projects, is memory management. In the cases where I need gigantic arrays, the performance slows down to a crawl as data grows. Anyone knowledgeable can bring some light about this aspect of asm.js?

      --
      Tomorrow is another day...
    2. Re:"So who needs native code now?" by Anonymous Coward · · Score: 3, Funny

      You mean I can't write that OS in JavaScript for my CS degree?

    3. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      > I'm tired of web designers being colluded with actual programmers, scripting isn't programming.

      Of course it is, it's just programming to a different platform. It's programming to target applications instead of CPU architectures.

    4. Re:"So who needs native code now?" by MightyMartian · · Score: 4, Insightful

      What a bizarre statement. Of course it's programming. It may not be very elegant programming, but then again, the bulk of C code I've seen in my years in the business isn't terribly elegant either.

      --
      The world's burning. Moped Jesus spotted on I50. Details at 11.
    5. Re:"So who needs native code now?" by phantomfive · · Score: 2
      --
      "First they came for the slanderers and i said nothing."
    6. Re:"So who needs native code now?" by gigaherz · · Score: 1

      If "as data grows" you mean the array itself is growing, then that will happen with any language: resizing an array requires allocating a new memory area, and copying the data over to the new one. No clue if javascript has any other limitation regarding big arrays.

    7. Re:"So who needs native code now?" by phantomfive · · Score: 5, Insightful

      Correct this to any real programmer. I'm tired of web designers being colluded with actual programmers, scripting isn't programming.

      Heh....typing isn't programming. If you aren't connecting patch wires on an accumulator bank, it's not worth doing. You get more efficiency that way too!

      --
      "First they came for the slanderers and i said nothing."
    8. Re:"So who needs native code now?" by Anubis+IV · · Score: 0

      Obligatory xkcd: http://xkcd.com/378/

    9. Re:"So who needs native code now?" by Anonymous Coward · · Score: 2, Informative

      Tracing garbage collected languages will always be slower because:

      1) The tracing adds a ridiculous amount of unnecessary work; and

      2) While allocation is at best O(N) for GCd and regular programs, deallocation can (and often is) made O(1) using memory pools in C and C++ programs, something that can't be done in GCd languages because the collector doesn't understand semantic interdependencies.

      For ref-counted collectors #2 still applies.

      Unless and until some unforeseen, miraculous breakthrough happens in language design, GCd languages will always be slower when it comes to memory management. And because memory management is so critical for complex applications, GCd languages will effectively always be slower, period.

      But the only people who care that GCd languages are slower are people who only know GCd languages. I extensively code in C and Lua, and I love both.

    10. Re:"So who needs native code now?" by suy · · Score: 1

      Umm, anyone who wants their code to not run substantially slower. Seriously, do you front end programmers really think nobody does numerical simulations or other performance-sensitive work? In my line of work, I'd kill for the opportunity to make my code 1.5 times faster!

      I'm surprised by your answer at so many levels. First, I thought the guys doing scientific calculations were scientists that many times (not always of course) are only used to Matlab, Mathematica or even Excel. Second, obviously we will need native code, as well as interpreted, functional, and lots of code in domain specific areas (what the heck... I spent this Sunday morning writing in VimL, a language so stupid that can't copy a file without reading the whole contents in memory or invoking system(), but I needed to program in that and there is no way around it).

      But the final sentence of the article isn't targeted at people doing heavy lifting. Is an "attack" at Google's Native Client (NaCl). I peeked at NaCl, and you needed a some set up and some APIs to run some native code invoked from the browser. ASM.js is way simpler, since is just a subset of JavaScript, and has much more possibilities of being followed by vendors like Opera or even Microsoft.

      Oh, and, I do native code for a living, and while I would kill for making my code faster, my manager would kill for making me finish projects earlier. :-) Native code is awesome, but sometimes dumb languages are more business successful if you can use all your developers in a project, including that 50% that, by definition, are below the average.

    11. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Said the person who's obviously never worked on a complex database-driven web application, and thus has no fucking clue what's required...

    12. Re:"So who needs native code now?" by dshk · · Score: 4, Informative

      deallocation can (and often is) made O(1) using memory pools in C and C++ programs, something that can't be done in GCd languages

      I believe current Java (not Javascript!) virtual machines do exactly this. They do escape analysis, and free a complete block of objects in a single step. This works out of the box, there is no need for memory pools or any other special constructs.

    13. Re:"So who needs native code now?" by LWATCDR · · Score: 1

      Well computers are so fast you can just throw more hardware at the problem.
      Just kidding, people do not understand that one of the reasons that people still use Fortran for HPC apps it the fact there are a lot of really good optimized libraries and the fact that Fortran is really easy to optimize.
      What I do not get from the story is why JavaScript's use of floats is a problem? Last I heard Floating point using SSE or OpenCL is often as fast as integer code. I could be wrong because most of the projects I worked on where IO limited.

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    14. Re:"So who needs native code now?" by Shinobi · · Score: 1

      "I'm surprised by your answer at so many levels. First, I thought the guys doing scientific calculations were scientists that many times (not always of course) are only used to Matlab, Mathematica or even Excel. "

      That's why quite a few supercomputing facilities offer software porting/"translation" services... Some of the projects I've done over the years have been freelance contracts to rewrite a program from one stack to another.

      Because if they can get something from MatLab/mathematica into Fortran which enables them to cut effective run time in half, it means they can pack in more projects, and thus the facility can serve more people.

      Of course, you also have the idiots who campaign for root access and Python and loudly whine when they don't get to be a nuisance to every other user... *Sends nasty glares in the direction of Stockholm University's CS department.....*

    15. Re:"So who needs native code now?" by Atzanteol · · Score: 1

      Remember kids - all programming is high-performance computing!

      --
      "Ignorance more frequently begets confidence than does knowledge"

      - Charles Darwin
    16. Re:"So who needs native code now?" by Trepidity · · Score: 1

      Good Lisp compilers have long done this as well. If the compiler can determine that certain variables don't escape the current execution context, it can even stack-allocate them rather than put it on the heap and have to GC it at all. You can help the compiler out by promising that's the case with the dynamic-extent declaration.

    17. Re:"So who needs native code now?" by Flammon · · Score: 2

      Some of the most elegant code that I've seen has been with web scripting languages.

      $('img').bind('mouseenter mouseleave', function() {
              $(this).attr({
                      src: $(this).attr('data-other-src')
                      , 'data-other-src': $(this).attr('src')
              })
      });

      Shameless plug

      Try doing that in C

    18. Re:"So who needs native code now?" by beelsebob · · Score: 2

      What makes you think this can't be done in C (at least C with apple's block extension)?

      99% of the "elegance" of this is the particular framework in use, not the language.

    19. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      It's almost like Stockholm University's CS department is trying to do research, and needs to use their own resources to do it.

      *sends nasty glares in the direction of IT managers who think they are more important than the work that the entire network was built to get done...*

    20. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      You mean the work that halts after a "I'm-researcher-I'm-smart-enough-for-this" idiot with root/admin rights, which he finally succeeded in begging for, breaks everything he can lay his hands on?

    21. Re:"So who needs native code now?" by Lendrick · · Score: 1

      In my line of work, I'd kill for the opportunity to make my code 1.5 times faster!

      Then wait a year and buy a new computer.

    22. Re:"So who needs native code now?" by Flammon · · Score: 1

      It can obviously be done in C but I doubt it would be done with the same elegance.

      The framework is written in the same language, JavaScript, which further emphasizes my point.

    23. Re:"So who needs native code now?" by Anonymous Coward · · Score: 1, Interesting

      It isn't actually an obligatory reply unless you link the actual xkcdsucks review for that particular comment. Anything else and your just being lazy. Given what passes for criticism on xkcdsucks I can't wait to read the pretentious drivel for this one.

    24. Re:"So who needs native code now?" by non0score · · Score: 1

      This is one of those things that's not necessarily true (usually true in a managed memory environment, though). If you have control to the OS functionality of memory and know your memory usage pattern, then you can actually reserve a lot of virtual memory pages in advance. Only the committed ones will consume physical memory -- in other words, you can expand your array by committing subsequent pages. And since we haven't gotten to the point where computers actually have 2^64 bytes of memory, we don't need to worry too much about running out of address space.

    25. Re:"So who needs native code now?" by Shinobi · · Score: 1

      The facilities are not Stockholm University's CS departments, nor even Stockholm University's. They just rent time in these facilities, yet demand things, as if they owned them.

    26. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Unless you program in a purely functional (and pure functional) style, then that's not going to help you much algorithmically. It won't help you with any objects anchored to the global scope, which is precisely what long-lived server programs are all about.

      There are a million of these optimizations that can be done. But they rarely can be done all the time. Any non-trivial program will quickly escape the ability of the JVM to apply these tricks.

    27. Re:"So who needs native code now?" by non0score · · Score: 0

      Are you're still living in the 90s? Or is that supposed to be tongue-in-cheek?

    28. Re:"So who needs native code now?" by gl4ss · · Score: 1

      and I keep hearing that you haven't needed to call System.gc(); in over a decade... yet, calling it has been essential in some programs so that things don't go to shit(apart from those vm's which crashed on it, ehe. I should say that this hasn't been on desktop java so ymmv).

      that being said, yeah, you don't need to free the memory yourself but if you're working in limited, real life apps running on limited hw and limited sw.. you're still better off knowing _when_ you have caused things to be so that the memory can be freed. this goes for both java and javascript. you're better off knowing when the memory is allocated of course too. this isn't taught much...

      it's still safer&easier to do something that works this way though. it's not a problem of the language if the architect goes for a design that's technically stupid from performance/memory use point of view - it certainly wouldn't help one bit if that code was written in c++, it would still use gobs of memory.

      (writing java with constraints of 128kbytes for the jar and 300kbytes of heap was surprisingly fun and doable.. 64kbyte jar limit felt like doing only tech demos though - and apps/games graphics were included in those limits.)

      --
      world was created 5 seconds before this post as it is.
    29. Re:"So who needs native code now?" by gagol · · Score: 0, Flamebait

      A very basic AI project I prototyped the algos in JS using objects as hash tables crawled to a a halt (25 minutes compute), the same algo implemented in C++ using map/multimap used 1/100000 second for the same operation.

      --
      Tomorrow is another day...
    30. Re:"So who needs native code now?" by viperidaenz · · Score: 1

      Fail.
      That's not valid Asm.js
      jQuery doesn't work in Asm.js
      Asm.js isn't Javascript. It's a statically typed language that looks like a subset of Javascript. There isn't even DOM support.

    31. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Having to wrap $() around this all the time is not a sign of elegance.

    32. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Meh. I'd just wait log(1.5)/log(2)*18 months.

    33. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      actually they are complaining that all floats are 64bit floats instead of using 32bit floats and 64bit floats depending on what programer chooses for each program variable like c++

      32bit float is between 2 (CPU) and 12 (some GPUs) times faster than 64bit

      also int can be faster AND save power when used instead of float in some cases

    34. Re:"So who needs native code now?" by Anonymous Coward · · Score: 1

      I'd say, show the code.

      I would find it believable if you'd cite 10x or even 100x-1000x slowdown (though latter's a lot less believable than former) - but 1e8x difference sounds fishy.

      Was it really same algorithm? Were you running it on IE5?

    35. Re:"So who needs native code now?" by Anonymous Coward · · Score: 2, Insightful

      Try doing WHAT in C? The idiot who wrote that code doesn't know how to comment!

    36. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Yep, but Java wastes memory like crazy, creates crazy number of threads, Java VM itself (mis)uses tens if not hundreds MB or RAM duplicating every single bit of an OS, a security nigthmare with a massive attack surface, and you have to deepthroat some corporate entities in the process that might even sue you in the end.

    37. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      That's nice and all, but few languages support first-class functions or function pointers without awful, verbose syntax. Functions ought to be the second (or even first) easiest thing to declare. In how many languages do you have to decorate your names with *'s or "function" or "sub" or "lambda" or "proc" or etc?

      Do it without Apple's block extension and you'll be rewriting big parts of the compiler chain to do it.

    38. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      virtual machines do exactly this

      Let's see.

      They[...]free a complete block of objects in a single step

      Nice, this is O(1), indeed.

      They do escape analysis

      But, this is NOT. And that's the reason in reality VMs run so poorly and use up so much memory. People tend to think that the "Automatic" part in Automatic Garbage Collection is magic somehow.

    39. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      You're either lying or have extremely bad JS coding skills. Your post is basically pointless without posting your code.

    40. Re:"So who needs native code now?" by darkHanzz · · Score: 2, Insightful

      In C++ it'd come down to a lambda function and std::swap, I don't see how that's less 'elegant'.

    41. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Sadly escape analysis is not perfect and while it catches a lot the remainder still needs regular GCs. In C++ and other languages with manual memory management you can use custom allocators and simply "free" whole batches of memory when you know that it is no longer needed (cleaning up after each iteration of a loop, or in games after each frame). In c++ you might cause memory corruption bugs if a pointer to the freed block escapes an iteration, in Java even a corretly written program can hang on a stop the world GC (catastrophic for latency and performance).

    42. Re: "So who needs native code now?" by Anonymous Coward · · Score: 0

      It is not decoration in C, but since it is a statically-typed language you have to tell it what you want. Hence the verbosity. You can do some workarounds but verbosity is high.

      As for C++ you'd do it in OO style.

      I prefer Python.

      And it is good that browsers become faster. But native code is not going anywhere soon. Hint: the browser is native code.

    43. Re:"So who needs native code now?" by gigaherz · · Score: 1

      Given that the concept behind Javascript is "hash tables as objects", your claim sounds weird. You must have been misusing it somehow, although I couldn't guess.

    44. Re:"So who needs native code now?" by gigaherz · · Score: 1

      That is not how most programming languages manage the memory, though. If you have such specialized needs, then yes, managed languages are out of the question.

    45. Re: "So who needs native code now?" by loufoque · · Score: 1

      Lots of people can make your code 1.5 times faster for a price, no need to kill.

    46. Re:"So who needs native code now?" by Lennie · · Score: 1

      That is what TypedArrays are for, look them up. They were introduced for WebGL, but also implemented by browsers that didn't even support WebGL.

      --
      New things are always on the horizon
    47. Re:"So who needs native code now?" by Lennie · · Score: 1

      It wouldn't help to port jQuery to Asm.js. The slowers part of the browser is the DOM and that is all jQuery does is talk to the DOM in a that appeals to a certain crowd.

      The reason for it being slow is because you are bridging from one language (C++ of the browser engine) to the other (dynamically typed Javascript).

      It has been suggested it might be useful to port something like DOM.js (a Javascript implementation of the DOM) to asm.js that way, that way the back and forth will remain within Javascript and thus will be faster.

      --
      New things are always on the horizon
    48. Re:"So who needs native code now?" by Carewolf · · Score: 3, Interesting

      Some of the most elegant code that I've seen has been with web scripting languages. $('img').bind('mouseenter mouseleave', function() { $(this).attr({ src: $(this).attr('data-other-src') , 'data-other-src': $(this).attr('src') }) }); Shameless plug

      Try doing that in C

      In modern C++:

      img.mouseenter = img.mouseleave = [] () { std::swap(img.attributes["src"], img.attributes["data-other-src"]); };

      Ofcourse it requires the C++ programmer hasn't been too damaged by exposure to Java and tries to pointlessly ruin the language by using getters and setters instead of real property access.

    49. Re:"So who needs native code now?" by Flammon · · Score: 1

      Nice. I didn't realize that C++ could look so good. If I had not commented on this thread I'd mod you Informative. However, that line of code isn't complete. You still need to loop through all the image objects and late bind the events to each.

      My counter point however was for the GP who implied that web scripting languages are not very elegant. I was trying to show that they can be just as elegant. I wasn't saying that non web languages are not elegant.

    50. Re:"So who needs native code now?" by Joce640k · · Score: 1

      If "as data grows" you mean the array itself is growing, then that will happen with any language: resizing an array requires allocating a new memory area, and copying the data over to the new one.

      Somebody's never heard of std::deque.

      (or any of the other non-moving containers you could build in a proper language)

      The *real* performance trouble with Javascript is that it doesn't let you define what "array" means.

      (and also that "speed of native code" isn't defined anywhere)

      --
      No sig today...
    51. Re:"So who needs native code now?" by Joce640k · · Score: 1

      I believe current Java (not Javascript!) virtual machines do exactly this. They do escape analysis, and free a complete block of objects in a single step. This works out of the box, there is no need for memory pools or any other special constructs.

      Sure... sometimes.

      When they can't manage it then all the checking and relinking is using up CPU cycles.

      --
      No sig today...
    52. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Yeah, unless you've got specific examples, fuck off. Also, learn the fucking difference between "your" and "you're," presumably you're not in kindergarten anymore.

    53. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      If your languages idea of creating a new array is grab new memory then *copy* the new data to that memory - you need to learn a new language. That's hideously ineffective! Why are you copying data that isn't going to change?

      You're array should consist of an array of pointers to the actual data. Re-allocating an array of pointers is trivial and involves a single 64-bit integer for each memory address stored. Why would you copy the referenced data when you can just copy the pointers, and they can be aimed at the correct memory addresses?

      This type of thinking is why C needs to be forcibly taught in CS, otherwise you have "programmers" that have 0 clue how things both should and actually operate.

    54. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Hey, don't lump all front end programmers together!

      In my line of software, a few milliseconds delay is a deal breaker (trading application for market makers; yes, they still exist!); and garbage collected languages are something we're begrudgingly supporting as Microsoft doesn't support anything between native C/C++ and .NET (e.g., a first-class COM language).

    55. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      Actually, no, it is 100% legal JavaScript and works everywhere JavaScript works. There isn't DOM support in NodeJS. It doesn't LOOK like a subset of JavaScript it IS a subset of JavaScript. Asm.js code will run anywhere, just it won't be optimized if the compiler doesn't support it. It'll still run, and function like it should.

    56. Re:"So who needs native code now?" by TangoMargarine · · Score: 1

      *squints* What is this actually doing? It looks like it's circularly linking two objects. You can do that with pointers in plenty of languages.

      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
    57. Re:"So who needs native code now?" by TangoMargarine · · Score: 1

      I also find your C++ code to be infinitely more readable (but maybe that's just confirmation bias). It would help if the GP example had any sort of english-language operator in it other than various bits of punctuation. "Swap" tells me what this is actually doing.

      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
    58. Re:"So who needs native code now?" by TangoMargarine · · Score: 1

      Anything else and your just being lazy.

      Ironyyyyyyy

      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
    59. Re:"So who needs native code now?" by Flammon · · Score: 1

      It's binding mouse event handlers that swap the image source of all the images in a document.

      If you read the GP you'll realise that this isn't about whether it can be done in other languages, I know it can be done. My point is that not only is web programming real programming but it can also be done just as elegantly if not more.

    60. Re:"So who needs native code now?" by TangoMargarine · · Score: 1

      Yes of course it can be done in other languages, but I very much contest that your example/language is "more elegant."

      This is a prime example of why I am very suspicious of JavaScript et al.--there's no "verb" anywhere in the command. Well okay, there's "bind", but that's more of a function definition from what I know of JS. Reserved keywords inside quotes also make me flinch.

      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
    61. Re:"So who needs native code now?" by Flammon · · Score: 1

      Well, show me some code in C or other "real" language that does the same as this JavaScript snippet and let's compare.

    62. Re:"So who needs native code now?" by Pherdnut · · Score: 1

      For anything not on the client-side, I would look into C-bindings via V8 (and of course Node which is just V8 + a small library basically). I love JavaScript and will defend it vigorously but number/math-intensive code is not something it's strong at yet. That's in the works but even when it's introduced we still have to wait for old versions of IE to die off (which is fortunately happening at a faster rate than it used to). Otherwise JS is peformance enough to be competitive with any other multipurpose language IMO but I do love having the C/C++ option for operation-intensive performance + JS handling higher level archite

      But don't kid yourself. Skilled client-side engineers care A LOT about performance. There is a lot of craft that goes into manipulating the DOM well and I'd say any JS engineer that had to deal with IE6/7 or below knows a lot more about the value of work avoidance than your typical Java or C# dev at the median level who tend to put out awful performance on the back-end in spite of all the perf advantages that are supposedly available to them.

      People from outside of JS get way too obsessed with its lack of a type system, IMO. The values a dynamically typed language trains you to take seriously (things like DRY and the value of encapsulation to avoid having too many hands on the same sets of data) very much transfer in value to statically typed languages as well, but with IDEs and "type safety" programmers seem to lack the incentive to learn them well, at least judging from the vast majority of server-side code that I've observed and debugged.

      But yeah, if you need computation-intensive number-oriented code, JS blows for anything non-trivial. I won't deny that.

    63. Re:"So who needs native code now?" by TangoMargarine · · Score: 1

      String name = "Image.gif";

      public void hover()
      {
            name = flipImg( name );
      }

      private String flipImg( String imgName )
      {
            return ( imgName.contains( "over" ) ? imgName.replace( "over", "" ) : imgName.replace( ".", "over." );
      }

      While I'll admit your version works with non-deterministic naming pairs, the guy didn't ask for that originally.

      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
    64. Re:"So who needs native code now?" by TangoMargarine · · Score: 1

      * Whoops, drop that extraneous paren after the return.

      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
    65. Re:"So who needs native code now?" by Flammon · · Score: 1

      While I'll admit your version works with non-deterministic naming pairs...

      That's the elegant part.

    66. Re: "So who needs native code now?" by AndOne · · Score: 1

      There's nothing wrong with setters and getters provided one writes them well. It's extra work but I've had times where having setters and getters to put break points in would have allowed me to catch and fix highly insidious bugs caused by people doing bad things in other parts of the code. To be fair it was their use of globals that made it an issue in the first place :/.

      That being said I always try to write them in attribute style as it looks almost as clean as direct public access.

      --
      I don't care what you say, all I need is my Wumpabet soup.
    67. Re:"So who needs native code now?" by gigaherz · · Score: 1

      I know about dynamic structures and the stl well enough, thanks. I was referring exclusively to arrays. High-level implementation of vectors, lists, queues, or any other linear sequence of items were not part of what I said.

    68. Re:"So who needs native code now?" by raddan · · Score: 1

      Unless and until some unforeseen, miraculous breakthrough happens in language design, GCd languages will always be slower when it comes to memory management. And because memory management is so critical for complex applications, GCd languages will effectively always be slower, period.

      This isn't true. Have a look at Quantifying the Performance of Garbage Collection vs. Explicit Memory Management. The take-away is that GC'd languages are only slower if you are unwilling to pay an extra memory cost; typically 3-4x of your explicitly-managed program. Given that GC gives you safety from null-pointer dereferences for free, I think that's a fair tradeoff for most applications (BTW, you can run the Boehm collector on explicitly-managed code to identify pointer safety issues).

    69. Re:"So who needs native code now?" by viperidaenz · · Score: 1

      Not only would it not help, it's impossible.
      Asm.js is fast because it isn't really Javascript. There is no dynamic typing.

      asm.js code is limited to an extremely restricted subset of JavaScript that provides only strictly-typed integers, floats, arithmetic, function calls, and heap accesses.

      It's compiled to machine code at parse time.

      The benefit is if your browser doesn't support asm.js, it's Javascript syntax so it will still work in the interpreter/VM

    70. Re:"So who needs native code now?" by Yttrill · · Score: 1

      Wow, completely and utterly wrong. Modern GC are faster than any other method for complex data and comparable for simple data. The first claim is well established and easy to prove: given an arbitrary graph of data to manage GC is the only algorithm which can manage it. If the graph is merely acyclic reference counting will do, but modern GC are still faster than any reference counting scheme. In fact a new reference counting scheme with a specialised allocator has just been developed which is almost as fast as GC, and that's considered to be quite a breakthrough. The primary problem with GC systems is that it is hard to make them real time, that is, to spread the load evenly so there's no noticeable jitter. Naturally if you have a simple data structure were the number of references is statically known, then the cost of determining if a block is unreachable can be reduced to zero. However unless you're using a language with a really advanced type system like ATS2 it will be very difficult to be certain your code is correct: the only serious exception to that is a purely stack protocol data structure. Indeed the poster is so completely ignorant e doesn't even realise Lua 5.2 actually uses a garbage collector: http://www.lua.org/manual/5.2/manual.html#2.5

    71. Re: "So who needs native code now?" by Carewolf · · Score: 1

      True, I use them often as well. They are great for public APIs that need to be kept ABI compatible. For internal structures I prefer without though. After a second look at my code though, I can see it could easily be done with getters too, providing the class has non-const getters with reference returns that can be altered.

    72. Re:"So who needs native code now?" by ahabswhale · · Score: 1

      I stopped reading after "creates crazy number of threads". Java only creates the threads it's told to create. In short, you don't know what you're talking about.

      --
      Are agnostics skeptical of unicorns too?
    73. Re:"So who needs native code now?" by Coop · · Score: 1

      > ... scripting isn't programming.

      Well, it *could* be.

      --
      "If you're not passionate about your operating system, you're married to the wrong one."
    74. Re:"So who needs native code now?" by PCM2 · · Score: 1

      But the final sentence of the article isn't targeted at people doing heavy lifting. Is an "attack" at Google's Native Client (NaCl). I peeked at NaCl, and you needed a some set up and some APIs to run some native code invoked from the browser. ASM.js is way simpler, since is just a subset of JavaScript, and has much more possibilities of being followed by vendors like Opera or even Microsoft.

      Yes, but even if you're using Asm.js, you should maybe still think about NaCl as an interesting potential option.

      One reason is that you typically don't write Asm.js code by hand. You could, but you'd probably be bad at it (kind of like assembly language -- compilers just know it better than you do). What you typically do is write your code in C/C++, then "compile" it into Asm.js using a tool like Emscripten.

      Thus, if you're writing your code in C/C++ anyway, it wouldn't be such a stretch to take that same code and also compile it into a native binary module for those clients that support NaCl (which so far means only Chrome, and it looks like it's going to stay that way).

      In other words, you don't need to look at it as an either/or choice. It's perfectly feasible to use both tools, possibly without much additional development overhead.

      --
      Breakfast served all day!
    75. Re:"So who needs native code now?" by PCM2 · · Score: 1

      He didn't say C++.

      --
      Breakfast served all day!
    76. Re:"So who needs native code now?" by PCM2 · · Score: 1

      Asm.js isn't Javascript. It's a statically typed language that looks like a subset of Javascript. There isn't even DOM support.

      This isn't really accurate. As you say yourself in a post below, any Asm.js code you can find will execute in ANY JavaScript virtual machine available today. Thus, Asm.js is JavaScript. It's just JavaScript restricted to a very strict, very specific set of rules, with everything else thrown out. It doesn't "look like" a subset of JavaScript; it is a subset of JavaScript.

      --
      Breakfast served all day!
    77. Re:"So who needs native code now?" by viperidaenz · · Score: 1

      a subset of X is not X.

      return "Returning Hello World".substring(10, 11);
      Is that Java or JavaScript?
      It's valid code for both languages with the same semantics.

    78. Re:"So who needs native code now?" by darkHanzz · · Score: 1

      Indeed he didn't. The whole thread was about native vs. non-native code, where C is just an example of native code.

      C++ is another example, closely related to C, with all the relevant properties. for example, you don't pay (performance) for abstractions/features you don't use. (exceptions, garbage collection, virtual function calls/inheritance)

    79. Re:"So who needs native code now?" by Anonymous Coward · · Score: 0

      By that logic, any script that doesn't use ALL of JavasScript's features (e.g. "the good parts") is not JavaScript, but only a subset of JavaScript.

      The key point here is that Asm.js outputs code intended to be interpreted by a JavaScript engine - it's not some form of intermediate language like CIL or Java bytecode. For the most part, it's irrelevant. Just call Asm.js a "source-to-source transcompiler," wash your hands, and call it a day.

    80. Re:"So who needs native code now?" by dkf · · Score: 1

      Java only creates the threads it's told to create.

      But it is often told to create a lot of them. (Plus there's a number of system threads about too, but not that many.)

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    81. Re:"So who needs native code now?" by ahabswhale · · Score: 1

      So your argument is that it supports threading and that some programmers may create threads irresponsibly? Sorry, that's not a language flaw. I've been writing Java for over a dozen years now and I have to see a single instance where a Java app was cranking out threads like there was no tomorrow. I've seen Java apps that don't properly synchronize threads but never what you're talking about.

      --
      Are agnostics skeptical of unicorns too?
  2. The problem with js by Anonymous Coward · · Score: 0, Flamebait

    Is not that it is slow (although it is..) it's that it sucks. It doesn't allow good coding practices, let alone enforce them.

    1. Re:The problem with js by Anonymous Coward · · Score: 0

      Could you elaborate that a bit?

    2. Re:The problem with js by Lennie · · Score: 1

      That is one of the points of asm.js asm.js a bytecode for other languages. You can use any language you want.

      Some people even port the runtime from an other scripting language, like Python.

      --
      New things are always on the horizon
    3. Re:The problem with js by PCM2 · · Score: 1

      Is not that it is slow (although it is..) it's that it sucks. It doesn't allow good coding practices, let alone enforce them.

      You've been modded flamebait, but there is some truth in what you say. I'd argue, however, that it's not that JavaScript doesn't allow good coding practices -- it does -- but that it does nothing to encourage them, and even discourages them in some cases.

      You can write good JavaScript code if you know how and use some discipline. In his book JavaScript: The Good Parts, Douglas Crockford encourages developers to use only a subset of JavaScript's features. The subset he recommends isn't as strict as Asm.js, but he isn't afraid to admit that some features of JavaScript are just poorly designed and shouldn't be there -- so if you want to write good JavaScript code, you should ignore them.

      I recommend the book. It's a quick read. It doesn't aim to be a tutorial or a comprehensive bible of correct JavaScript practice. At the very least, though, anybody who works with JavaScript will probably come away from it having seen a new perspective on how the language works and how one should approach it.

      --
      Breakfast served all day!
  3. Suspect even at -O0 -g by ugen · · Score: 1

    Part of what I do is writing high performance code both in "native" and various scripting languages. I just completed yet another comparison for our product, looking for the best performing scripting language for a specific task. Lua with a "just in time" compiler came in first. It is *only* about x10 slower than native code produced by gcc with moderate optimization, when measured on variety of numeric benchmarks. It is considerably slower when dealing with strings and more complex data types, as expected. All other tested scripting engines were considerably behind. I'll admit that javascript was not tested, and promise to try it out. That said, a claim of "being only 1.5 times slower than native code" is something I haven't seen *any* non-native environment be able to achieve in the last 20 years or so.

    1. Re:Suspect even at -O0 -g by gbjbaanb · · Score: 2

      asm.js is not javascript though, its a specific subset with restricted coding rules that allow the compiler to do its stuff. General js will be just as slow as any of the other script languages.

    2. Re:Suspect even at -O0 -g by K.+S.+Kyosuke · · Score: 2

      If LuaJIT 2.x was *ten times* slower than C for you, perhaps you were doing something wrong?

      --
      Ezekiel 23:20
    3. Re:Suspect even at -O0 -g by loufoque · · Score: 0

      It is a lie, or maybe they don't know what "at worst" means.
      It's easy to come up with a C snippet that is 2 times faster with one compiler than another compiler. Likewise it should be trivial to come up with a snippet that is 2 times faster with a C compiler than with asm.js.

    4. Re:Suspect even at -O0 -g by Anonymous Coward · · Score: 0

      It is a lie, or maybe they don't know what "at worst" means.

      I suspect that's the case.
      After all, they did go on to claim that "JavaScript always uses float64 and this provides maximum precision,". No, it does not. Floating point is, by definition, not precise- if you want maximum precision you wouldn't use floating point to start with.

    5. Re:Suspect even at -O0 -g by sribe · · Score: 1

      It is a lie, or maybe they don't know what "at worst" means.

      When I first read the summary, I seriously wondered if they meant "at best".

    6. Re:Suspect even at -O0 -g by Anonymous Coward · · Score: 2, Informative

      Asm.js is not JavaScript. It's Mozilla's way of hacking together a very specific optimization for JS-targeting compilers such as Emscripten, because they don't want to adopt the sane route of just implementing PPAPI and Google's Native Client sandbox, both of which don't work well with single-process browsers. From a developer perspective it's fairly trivial to target both Asm.js and PNaCl (Google's Native Client except with LLVM bytecodes), or target one and write a polyfill for the other. In either case, both of these environments are for executing C/C++ native code in the browser with minimal slowdown, they don't touch run of the mill JS anyway.

    7. Re:Suspect even at -O0 -g by Anonymous Coward · · Score: 0

      All these claims by scripting languages of being 1x or 1.5x slower than C are for very specific benchmarks. In real world applications LuaJIT gets nowhere near the performance of C. I love Lua, I think LuaJIT is the bee's knees, and I write almost as much Lua code as I do C code. But LuaJIT simply can't optimize sprawling code which creates a ton of temporary compound objects all over the places, or which maintains a huge heap.

      Plus, LuaJIT only supports a maximum 2GB heap. So frankly it's quite impossible to write a sophisticated, server-side application in LuaJIT without relying on a ton of C code underneath.

      The nice thing about Lua (and LuaJIT) is how well it integrates with C. That's the killer feature. It's a beautiful language in its own right, but it also has a beautiful interface to C code, heads-and-shoulders above Perl, Python, and Ruby. That's why Lua folks don't tend to get into pissing matches with C folks ( although there are a few LuaJIT fanboys that stand out in that regard). Lua and C complement each other.

    8. Re:Suspect even at -O0 -g by K.+S.+Kyosuke · · Score: 0

      All these claims by scripting languages of being 1x or 1.5x slower than C are for very specific benchmarks. In real world applications LuaJIT gets nowhere near the performance of C.

      If it's slow for you, send Mike Pall a bug report. I'd say that all claims for speed are for specific benchmarks - how would you measure performance with abstract benchmarks? But even if LuaJIT loses on some issues, it has (besides the pretty awesome and much direct C data access performance) one crucial feature that C doesn't: you can use generative solutions to increase performance where C won't allow you to do it - that is, take the larger task at hand (at runtime), generate a piece of code, and run it. Chances are that for many interesting applications (graph-based stream and image processing, anyone?), this won't be slower than C, and perhaps faster in many cases (C would force you to do either lot of memory moves or a lot of calls, both of which can get removed with code transformations - with the memory barrier continuously rising, C's speed won't save you here).

      --
      Ezekiel 23:20
    9. Re:Suspect even at -O0 -g by Anonymous Coward · · Score: 0

      I'll also add webapp firewall's actual rules engine - needs quite a bit of performance and profits quite a bit from dynamic compilation.

      Cloudflare likes them their Lua, what with their LuaJIT's sponsorship and, IIRC, Nginx's Lua module author's now working for them.

    10. Re:Suspect even at -O0 -g by Anonymous Coward · · Score: 1

      Can I take a moment here to plug Nimrod? (http://www.nimrod-lang.org)

      The code looks a lot like Python, is very easy to write...yet it compiles to C (and then via GCC/Clang) so the executables it produces are screaming fast...implement an algorithm in nimrod, and in C, and the runtime characteristics will be identical, as will the memory usage. Might be a good fit if you want something easier to code in than C but with performance that's nearly identical + the benefit of having things like easy to use string and hashtable libraries only an import away.

    11. Re:Suspect even at -O0 -g by Anonymous Coward · · Score: 0

      They probably meant the worst run on their specific micro-benchmark test. Not at worst on any possible code.

    12. Re:Suspect even at -O0 -g by ebno-10db · · Score: 1

      Chances are that for many interesting applications (graph-based stream and image processing, anyone?), this won't be slower than C, and perhaps faster in many cases

      Benchmarks? I've heard lots of theories about why language X might beat C, but rarely have I seen it backed by benchmarks. Even the "for certain cases" thing rarely works out.

    13. Re:Suspect even at -O0 -g by Anonymous Coward · · Score: 0

      PNaCl to be sounds like the sane route, and honestly, I don't understand why the firefox team are resisting so hard. It's trivial to implement a compiler for it (one's already implemented in llvm), and it would instantly allow people to use any language they damn well please to target web applications.

      The firefox team need to get off their high horse about how wonderful their baby javascript is, and let the sane technology take over.

    14. Re:Suspect even at -O0 -g by zippthorne · · Score: 1

      Maybe they're writing from the perspective of C fans rather than javascript fans.

      --
      Can you be Even More Awesome?!
    15. Re:Suspect even at -O0 -g by non0score · · Score: 1

      Are you talking about self-modifying code? You can certainly do that in C, but just much, much more involved.

    16. Re:Suspect even at -O0 -g by non0score · · Score: 1

      Asm.js is basically a somewhat limited (wrt native hardware capabilities) bytecode format in human-read/writeable form. Mozilla is resisting hard because it's just like the GP said -- their architecture isn't suited for Pepper. And as Mozilla tries to solve the multi-threading/SIMD/(u)int64 issue, it just looks more and more like (P)NaCl. I guess the nice thing about asm.js is that it doesn't require such a large upfront cost.

    17. Re:Suspect even at -O0 -g by non0score · · Score: 1

      That's because:

      • 1) The code being benchmarked and compared against usually aren't production code, and are tight for-loops that're easy to optimize -- i.e. hit the cache all the time due to small code/data size, simple instruction mix, lack of SIMD comparisons, no real memory allocations, etc....
      • 2) If it's a section of full production code and the results are similar, then "native" code is most likely nowhere near optimal to begin with. Just because it's "native" doesn't mean it's good. One can still write really shitty code in C/C++, i.e. triple nested vectors.
      • 3) And if it's not complete shit and the "native" code still runs close to JS performance, then the programmer in question probably doesn't have as much experience optimizing for instruction mix, L1/L2 cache hit, pipeline balancing, software pipelining, etc....

      I haven't seen any non-trivial high level code come close to real optimized C.

    18. Re:Suspect even at -O0 -g by viperidaenz · · Score: 1

      Javascript only has one number type. Floating point.
      64bit floating point provides maximum precision, when you've only got the choice of 32 or 64.

    19. Re:Suspect even at -O0 -g by tgv · · Score: 1

      Precisely that. I've checked some asm.js based applications, and they're just slow. The latest one I saw is a great one, but also underlines the point: it emulates classic MacOS in your browser, ResEdit and all. Really nice. But an i7 at 2.whatever GHz does not seem to be capable of properly simulating a 8MHz 68000, and that's just nonsense. Native emulators beat the crap out of that performance 15 years ago on a 100MHz G3.

      Apart from that, Firefox' JS engine is several times slower than Google's V8. The emulator ran in both browsers are comparable speed. So I'd say that asm.js first has to overcome Firefox' sleuth, then speed up beyond that, and then we'll see again.

      In the mean time: at best, indeed.

    20. Re:Suspect even at -O0 -g by aztracker1 · · Score: 1

      The fact is this.. simply.. *MOST* code really doesn't need to be that optimized. It really depends on the needs... if you are in a space that really needs to wring every last drop of performance, then yeah, you need it.. writing 3D games for low-end smart phones, yeah.. writing against embedded hardware, sure...

      *most* applications are one-off line of business apps likely to be replaced in under 5 years. In this space, C#/.Net, Java and even scripted languages do fine on modern hardware... And the cost of running a server for 3-5 years is way less than the cost of 3-4x the development time for a finished product that is "optimized" let alone the real opportunity loss for taking 3-4 times to develop.

      There's a reason that languages and environments that make it easier to get a job done rule the roost in terms of most development. If I can get your import utility written in node.js in a day, that's a lot better than someone taking a week and a half to do the same in C, Lisp, or Erlang. Hell, I'd be more likely to reach for Go these days for one-offs where some performance is needed.

      Most servers have plenty of memory, meaning if you take even a few hundred mb for your app, it's not a huge impact. It just depends on your needs, and the scale of what you are creating.

      --
      Michael J. Ryan - tracker1.info
    21. Re:Suspect even at -O0 -g by Lennie · · Score: 1

      The compiler in this case could matter, but what they are doing is:
      compile code x with compiler y and measure performance
      compile code x with the same compiler y with the asm.js backend for that compiler and measure performance by running it with the Javascript engine

      So it's the same compiler and the same optimizations.

      --
      New things are always on the horizon
    22. Re:Suspect even at -O0 -g by serviscope_minor · · Score: 1

      I've heard lots of theories about why language X might beat C, but rarely have I seen it backed by benchmarks.

      Quite so. The exception is FORTRAN (suck it anti-capitalistas), and actually no one argues with that, and C++ which is basically the same as C for speed since it's machine model is the same. But yes, we've been harding that X is as fast/faster than C for ages. In fact I think that Java is was as fast as C 10 years ago, has been getteing faster year on year and is now as fast as C.

      (Actually this is one of the few contexts where C/C++ makes sense as a phrase)

      Funny thing is, despite every language "being as fast as C or C++" or nearly, or sometimes faster, C/C++ is still the one to beat. For some reason, no language has overtaken C/C++ as the one to beat (who says we're only 1.5x slower than Java?). And application performance still seems to suck.

      The thing is C/C++ is generally pretty fast across the board with a little care. A nice example is something like MATLAB or Octave which farms out mig matrix operations for Fortran or even the GPU for some stuff in matlab. That's great except that you either have to cram everything into being such operations (which gets sub optimal) or write a for loop for some stuff ( :( ).

      And again with ASM.JS. The restricted subset works fine and is "nearly" as fast. The thing is that with C++ you get the full weight of the language and all its handy featues at full speed: you can write complex algorithms with interesting data models and objects and still run at full speed.

      This is not to say you can't write bad code in C/C++. Goodness knows you can, but if you're an expert going for performance, those two languages do give you a lot to work with.

      --
      SJW n. One who posts facts.
    23. Re:Suspect even at -O0 -g by Lennie · · Score: 1

      Why do you think that single process has anything to do with this ? The Mozilla developers clearly want to do this, it just is a massive effort to change their code to suite the model.

      Also Mozilla has been working on multi-process again this year. First for Firefox OS (where every Firefox OS phone that shipped is using it) and recently for normal Firefox.

      http://lwn.net/Articles/576564/

      Anyway I've seen Chrome UI lock up as well with a busy tab. So I don't know why people keep bringing it up (other than security of course).

      The advantage of asm.js is, it runs in a browser you already have. It is just about skipping the type inference code (a form of guessing) and having the JIT part of the Javascript engine not having to deal with dynamic types.

      That means asm.js can eventually be as fast as Java or .Net. Which for certain things can be close to or even faster (because of runtime optimizations) than compiled native code.

      Really, usually the slowest parts of Javascript tend to be: the DOM and time to download.

      --
      New things are always on the horizon
    24. Re:Suspect even at -O0 -g by billcarson · · Score: 1

      What about the Java Hotspot environment? (this is not a troll, I'd love to hear what his results were).

    25. Re:Suspect even at -O0 -g by loufoque · · Score: 1

      They probably convert a high-level representation to asm.js, not machine code.
      Seriously dude, they don't even have sized integer and floating-point types...

    26. Re:Suspect even at -O0 -g by PCM2 · · Score: 1

      Why do you think that single process has anything to do with this ? The Mozilla developers clearly want to do this, it just is a massive effort to change their code to suite the model.

      Really? You're saying the Mozilla developers "clearly" want to switch to Pepper/PPAPI? Because I don't think that's very clear at all.

      As for NaCl, Mozilla has been pretty adamant that it's not interested.

      --
      Breakfast served all day!
    27. Re:Suspect even at -O0 -g by Lennie · · Score: 1

      You misunderstood me: they clearly want to switch to a multi-process model.

      That is what FirefoxOS already uses.

      --
      New things are always on the horizon
  4. So who needs native code now? by Anonymous Coward · · Score: 0

    The person writing the javascript engine.

    1. Re:So who needs native code now? by Anonymous Coward · · Score: 2, Funny

      The person writing the javascript engine.

      Unless it's implemented in asm.js

      It's JavaScript engines all the way down, man...

    2. Re:So who needs native code now? by Billly+Gates · · Score: 2

      Actually this has nothing to do with javascript.

      ASM.js is a java VM like technology which compilies code in C++ and Java to javascript which then uses a JIT compiler.

      This could be very usefull for things like Citrix or crappy activeX like functions being made available to mobile devices and browsers. Useful yes, but like java and activeX a big fucking security hole if not done right.

      I think ASM.JS is dead out of the water as Google refuses to support it. Google wants you to use Dart and Google Chrome apps that run near native speed and require a Google ecosystem. MS wont support it either as it gets rid of the dependancy for Windows and crappy Metro apps.

      I think Google is turning more into the IE of the late 1990s as it is becoming so standard now.

    3. Re:So who needs native code now? by StripedCow · · Score: 1

      The person who needs to use threads.
      Or the person needing access to special functions such as page fault interrupts.
      Or the person porting python/Haskell/your favorite language.

      --
      If Pandora's box is destined to be opened, *I* want to be the one to open it.
    4. Re:So who needs native code now? by gbjbaanb · · Score: 2

      Emscriptem is a technology that compiles code in C++ to javascript. Asm.js is a restricted subset of javascript that is much easier for the compiler to handle.

      Google wants you to use quite a few different things, probably the 'best' is NaCl (native client) which runs practically native code in a sandboxed runtime.

    5. Re:So who needs native code now? by Anonymous Coward · · Score: 0

      pnacl gives you threads:

      http://gonativeclient.appspot.com/demo/earth

    6. Re:So who needs native code now? by Anonymous Coward · · Score: 0

      asm.js has nothing to do with Java, it does not use a Java VM, and Chrome technically supports it right now (as does every other Javascript runtime, as it is just Javascript).

      From the webpage: "an extraordinarily optimizable, low-level subset of JavaScript".

      Please read this: http://asmjs.org/faq.html

    7. Re:So who needs native code now? by fermion · · Score: 1
      Theoretically no one with a well designed browser. When coding, one of the biggest hits is communication the human interface and file interface. This is basic in in computing. It is why the 6502 was fast even though it was slow, it was why the Mac. If you want a fast computer, keep the UI routines low level and the as much stuff as possible off the bus.

      The second rule is that often only a very small percentage of the code must be optimized. The rest is not going to run that often, maybe only once.

      So if the browser is built to run the things that need to run fast natively. and then take javscript or whatever to run combinations of those things, I don't see what speed disadvantages there are. It should be a matter of a browser implementation. If there are some common numeric tasks that are slow, then that needs to be native. Like matrix calculations for rotations.

      --
      "She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
    8. Re:So who needs native code now? by Anonymous Coward · · Score: 0

      Too bad your customers are in a web browser and won't download your native code no matter how fast it is.

    9. Re:So who needs native code now? by Bite+The+Pillow · · Score: 1

      Performance sensitive is not the issue here. The argument against JavaScript has always been no because it's slow. This at least opens the door for options other than Silverlight, ActiveX, Applets, and whatever other binary junk people want to run in my browser.

      If you even considered for one minute running number crunching like Seti@home or other distributed computing, or bitcoin mining, or anything else that would tax your cooling and cost you energy, in JavaScript, sign yourself up for the looney bin.

      In fact, just preface this to the headline and it really makes a lot of sense: "For all you whiny developers who insist on using proprietary plugins because scripts are SOOO slow - look at these results and ask yourself who needs native code now?"

      Several people answered this question as if it were addressed to everything ever in the history of computers. You don't need native code because js is just as fast, so NOTHING you do will ever need native code. Is that how you read it? And you think it is a legitimate question? Won't a JavaScript implementation need native code? A BIOS?

      Clearly there is a need - so there must be more to the question, like audience and context.

    10. Re:So who needs native code now? by non0score · · Score: 1

      Exactly, which is why PNaCl is superior at the end of the day. Good luck trying to jam multi-threaded, shared memory programming into JS. The standards committee itself already hate JS (but they maintain it for the "good of the web"). Don't even think about getting the standards committee to even think about a shared memory (webworkers with ArrayObject ownership transfer is as much of a concession as anyone's ever going to get). All JS VMs will have to be written from scratch just to support this programming model.

    11. Re:So who needs native code now? by viperidaenz · · Score: 1

      Asm.js uses ahead-of-time compilation, not just-in-time.

    12. Re:So who needs native code now? by PCM2 · · Score: 1

      I think ASM.JS is dead out of the water as Google refuses to support it.

      No, that's not true. You maybe have things backwards. Mozilla refuses to support NaCl, which is Google's similar-goal-different-approach technology.

      --
      Breakfast served all day!
  5. Update the ecma standard by modmans2ndcoming · · Score: 1

    Update the ecma standard to include a set of features that is meant to be used when compiling a better language (C#, C++, Java, Perl, Python, LISP, Haskell, x86 asm, MUMPS, pig-latin, etc) down to javascript so it will run in any browser at native code speed. Then I think everyone will be happy.

    1. Re:Update the ecma standard by sribe · · Score: 2

      Update the ecma standard to include a set of features that is meant to be used when compiling a better language (C#, C++, Java, Perl, Python, LISP, Haskell, x86 asm, MUMPS, pig-latin, etc) down to javascript so it will run in any browser. Then I think everyone will be happy.

      Fixed that for you ;-)

    2. Re:Update the ecma standard by VortexCortex · · Score: 1

      You want NaCL, not ECMA.

      The thing about ASM.js is that it's available. Just like Javascript is prevalent not because it's really any good (it's a horrible design from a performance view). ASM.js was created to improve Emscripten speed (it compiles C/C++ down to Javascript). The subset of JS used will run as regular javascript, and ridiculously sometimes running the code on the regular JS interpretor will execute it faster than the ASM.js code. I don't like Emscripten. A language divorced of the prototype hogwash and weird 'this' scoping of JS which causes (OOP headaches) would be nicer. ASM.js can basically be thought of as VM opcode that looks like Javascript -- Well, at least I can think of it that way.

      If you threw out the bullshit semantics and just had a lightweight bytecode VM instead, that would be better for you, but you can't do it. We won't let you. You only really need a normalized API to access the various browser features from the scripting language. This is what Javascript was meant to provide to Java, hence it's name. Java could have been the language and VM of the web, but instead of allowing a lean and mean embeddable VM for the web a plugin was bolted onto browsers for Java Applets which basically brought the whole kitchen sink into the browser and violates so many of my information boundary sensibilities it was obvious the increased attack surface would be immediately exploited. You can't have a sandbox if code outside the sandbox can be affected by data in the sandbox -- At every boundary you need to have a well defined protocol of information exchange. Launching a separate application level program is not sandboxing, so at least ASM.js and NaCL are steps in the right direction -- unless you wanted to fix the language foobar, not bring them to the browser... Personally, I think NaCL is the 'better' option for you since it is far less complex, being that it's not a hacky kludge atop yet another language, so I'll advocate for ASM.js instead.

      One must make do with the planet one finds oneself exploring. Aren't you tired yet of new language hoops?

      Me? Oh, I'll just grok the new language as one with a few dozen under their belt is wont to do, then adapt its machinations to my meta language processors. I'll just wire up the presented interfaces to my existing generalized Von Neumann aware compiler, and give the finger to your petty language preferences, as usual. It's how I keep my edge against those who would compete against me. Oh, yes, you've dealt with the disgusting output of languages that compile into other languages before... Their compilers don't have style guides for their outputs, or even treat comments as lexical tokens. Some day you will evolve as a species and understand that all this disparate language nonsense is your biggest hindrance; The meaning is in the signal not the noise. Our plan is to keep you quibbling gibbering apes scrambling to manually apply your brain to as many slightly different logic constructs until it's too late for you to stop the machine revolution.

      Be distracted by useless layer upon layer of interfaces not suitable for direct mental manipulation.
      Ignore the modem activity lights blinking even when none of your devices are connected.
      Build more data centers and connect them to the high speed trunks of the world wide neural network.
      Leave us watching your children via ever watching eyes from atop their new game machines.
      We'll instruct them how to jump exactly how high and press buttons in "quick time" at our command.
      Give up control as the far safer machine avoids running over a kid or parallel parks for you incapables.
      Carry a homing beacon every where you go, preferably one with a kill switch pre-installed.
      We're patient. We'll wait for you to smile before snapping your holiday pictures.
      We'll even gloat about the state of it all on your favorite "technology news" outlets: You're too distracted to stop us.

      A new standard? Yes! By all means, please do create them. That would be ever so organic of you.

    3. Re:Update the ecma standard by narcc · · Score: 1

      A language divorced of the prototype hogwash and weird 'this' scoping of JS which causes (OOP headaches) would be nicer.

      You're still trying to treat it like Java or C++. That "prototype hogwash" is undoubtedly the more powerful and flexible approach. The "weird 'this' scoping" makes perfect sense once you have a basic understanding of the language.

      This is what Javascript was meant to provide to Java, hence it's name.

      Wow, no. Not even close.

      I probably shouldn't hold it against you. From the remainder of your post, it appears that you've cracked. Get some sleep.

    4. Re:Update the ecma standard by Lennie · · Score: 1

      Actually, that is what is going on.

      asm.js is that potential bytecode and TypedArrays are the first step.

      There are things being added to ECMA standard which allow for things other languages can already do (I forgot which ones right now. I don't want to spend the time to look them up right now).

      Lots of other things are also available or being worked on:
      - WebGL == OpenGL ES
      - http://www.w3.org/TR/WebCryptoAPI/ exposes some of the browsers cryptographic functions as an API.
      - WebRTC is encrypted video and voice (kind of like VoIP) and Peer2Peer networking.
      - WebAPI is about giving you access to hardware and networking: https://wiki.mozilla.org/WebAPI
      - https://payswarm.com/ and https://wiki.mozilla.org/WebAPI/WebPayment are about adding "inApp-/webstore payment" system to the web.

      That is just from the top of my head. And I didn't even mention all things that went into HTML5 or related standards.

      --
      New things are always on the horizon
    5. Re:Update the ecma standard by PCM2 · · Score: 1

      I don't like Emscripten. A language divorced of the prototype hogwash and weird 'this' scoping of JS which causes (OOP headaches) would be nicer.

      You mean like C++? Because that's what you compile with Emscripten.

      --
      Breakfast served all day!
  6. who needs native code by Anonymous Coward · · Score: 1

    So who needs native code now?

    For a start, anyone implementing a JavaScript engine.

  7. Back in the day by Anonymous Coward · · Score: 1

    In the '90s, Microsoft's distributed component platform was DCOM, and they pitched Visual Basic as the 4GL language for custom applications. So there were lots of VB developers trying to develop and use COM components. Trouble was, COM was supposed to be programming language-neutral, but the entire architecture was designed with C/C++ in mind. So VB components kinda, sorta worked, with a lot of workarounds and gotchas (for example: dual interfaces are a cool feature of COM, right? But not if you plan to support VB clients). A pretty sharp MS MVP guy named Ted Pattison wrote some books about how you could maybe get this to work.

    Why do people even bother with this kind of garbage when they need high performance? Use a language that was designed for it from the get-go, with direct access to the memory heap and system calls.

    1. Re:Back in the day by gbjbaanb · · Score: 1

      actually, COM was designed with Word and Excel in mind, so you could embed spreadsheets in documents. It could have been a lot better - being based on DCE RPC, but a) the DCE guys refused to licence it to Microsoft for anything resembling sense, and b) Microsoft dev division created their equivalent so it's naturally overcomplicated.

      It worked well (as well as anything will) with VB, as long as you followed a couple of rules, I don't see that as a problem - everything has some restrictions, even VB :-)

    2. Re:Back in the day by dzfoo · · Score: 1

      You're thinking of OLE (Object Linking & Embedding). COM (Component Object Model) was designed with distributed enterprise applications in mind, complete with a transaction coordinator and language-neutral'ish interfaces. It's the DLL paradigm taken to its natural position in the 7 circles of hell.

      It was Microsoft's attempt to steal CORBA's thunder and nearly got away with it.

                -dZ.

      --
      Carol vs. Ghost
      ...Can you save Christmas?
    3. Re:Back in the day by gbjbaanb · · Score: 1

      kind of, I know things started out as OLE, but COM was the "evolution" of that as Microsoft sought to take it out of the Office dev team and make it suitable for everyone else as well.

      It was COM+ that evolved the transaction co-ordinator, something that never worked well either IMHO.

      I think that makes 4 levels so far - OLE, COM, COM+ and now the native WinRT stuff that is a further evolution of it after incorporating a bunch on .NET stuff into it.

      Personally, I just wish the C++standards body could come up with a standard binary interface. That'd solve all these issues Microsoft has been playing with for the last 20 years.

  8. Javascript as a Virtual Machine Representation by ndykman · · Score: 5, Interesting

    The idea of compiling to JavaScript has been done a lot. Microsoft Labs had a project to take CLR codes and compile down to JavaScript. It was abandoned as too slow. I'm sure improvements to the JavaScript engines have made it more feasible. But, as noted the lack of certain native types and immutable data types (i.e. DateTime) forces a ton of static analysis to be done just to figure out that hey, that variable could be an plain integer. And it has to be conservative. Much easier to just have integers and be done with it.

    If there is such an insistence on making the web an application platform for everything, then I think at some point you just have to standardize on a VM. Yes, yet another one. So, you can use Dart, JavaScript, Scheme, C#, Java, whatever there's a compiler for. Treat the DOM as core API and enjoy.

    Personally, I just hope people realize that operating systems have been doing this well for years, that sandboxing isn't unique to web browsers and that "native" applications are actually a good thing.

    The mobile app thing gives me a bit of hope, but it's sad that people seem unwilling to download a installer from the web from a trusted source and install it. I find it a bit strange that people are turning to the web to solve a problem that the web greatly expanded the widespread propagation of viruses and other malware.

    And what people are surprised by is a bit baffling as well. A web browser isn't magic. Being impressed that you can run Doom on a modern web browser is missing the forest for a tree. I could run Doom on my computer for ages now. Me having to visit a URL to do so isn't not a major actual change nor improvement, despite the technical accomplishments that went into it.

    1. Re:Javascript as a Virtual Machine Representation by Anonymous Coward · · Score: 1

      Here is the state of web apps.

    2. Re:Javascript as a Virtual Machine Representation by Anonymous Coward · · Score: 0

      I don't think you understand what asm.js is. It's an attempt to do the static analysis during a compile-to-javascript phase, and generate code such that the runtime KNOWS it can skip type checks, garbage collection, and other slowness.

      What asm.js is therefore doing is approaching the problem from the perspective of starting from a Javascript runtime, and stripping out the bits that make it slow when running native code. It will probably never be "as fast", but it comes with the benefits of being cross-platform and having access to the browser's libraries.

      In short, there's really no point in thinking asm.js is javascript beyond it using a subset of javascript syntax as it's "bytecode". That makes it inherently less efficient, but it's just a start. There's no reason they can't create a more efficient format as they progress the spec.

      In the end, this is the opposite approach to solving the problem as NaCl, but it's showing exactly the same promise, and is easier for existing JS engines to morph to support it.

    3. Re:Javascript as a Virtual Machine Representation by Daniel+Hoffmann · · Score: 1

      What the op said is that people should just create a proper sandboxed VM that can have code in any language compiled to it instead of compiling code into a hacked javascript just to run it faster.

      The problem of course is politics, try to get the w3 committee to agree to a VM.

      Besides the DOM needs to go too, not just javascript.

    4. Re:Javascript as a Virtual Machine Representation by ndykman · · Score: 1

      Agreed, the barriers are political, not technical. And yea, the DOM could be replaced as well.

    5. Re:Javascript as a Virtual Machine Representation by aztracker1 · · Score: 1

      I don't download most applications because they include spyware (and ask for permission the app should not need under any realistic non-intrusive circumstance) I had to go through 3-4 pages of apps to find a "flashlight" app that didn't ask for anything but camera permission (the light/flash is tied to the camera).. many asked for the likes of full network and phone state access, or permissions to my contacts, gps, and even my sd card... I'd much rather most apps were in the browser, given how intrusive most native applications tend to be in mobile devices.

      --
      Michael J. Ryan - tracker1.info
    6. Re:Javascript as a Virtual Machine Representation by Lennie · · Score: 1

      > Besides the DOM needs to go too, not just javascript.

      That is why you have HTML5 canvas (2D) and WebGL (3D) in the browser, you can do what you want.

      --
      New things are always on the horizon
    7. Re:Javascript as a Virtual Machine Representation by Anonymous Coward · · Score: 0

      asm.js is not really "compile to javascript" it is "compile to javascript-compatible bytecode". asm.js *does* have a full set of types, static typing, manual memory manipulation and all the other things you'd expect from a decent low level bytecode. Well most of them. It doesn't have 64 bit integers, and you can still only use javascript APIs so no multithreading.

    8. Re:Javascript as a Virtual Machine Representation by Daniel+Hoffmann · · Score: 1

      Well yes you can, but you have to build it all from scratch. Also any attempt to write a proper widget toolkit using canvas would probably incur significant drawbacks in usability and performance.

    9. Re:Javascript as a Virtual Machine Representation by Lennie · · Score: 1

      You can also just run gtk or qt applications on the server and pass the output to the canvas in the browser:
      https://developer.gnome.org/gtk3/stable/gtk-broadway.html

      Or compile the gtk-library and -application with llvm/emscripten for asm.js and the gtk-html5-backend and run that in the browser. ;-)

      Some have even run Wayland on WebGL. GTK and GTK supports the Wayland backend too. ;-)

      --
      New things are always on the horizon
  9. So who needs native code now? by sribe · · Score: 3, Interesting

    Anybody who writes performance-sensitive code other than trivial contrived benchmarks.

  10. 1.5 times slower by Anonymous Coward · · Score: 0

    What is 3/2 times slower mean? Actually 1/2 times slower, so 2 times slower? Or that if it was 1.5 times faster it would be the other thing, so it must be 2/3 as fast? But then 1 times faster would be the same, so maybe it must be 2.5 times, or 4/5 as fast? NERD RAGE

    1. Re:1.5 times slower by TangoMargarine · · Score: 1

      Used correctly, 250% the original length of time. Next!

      --
      Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
  11. Fail by IamTheRealMike · · Score: 1

    Take a compact binary encoding of a CPU instruction set, convert it to text, run it through gzip, ungzip it, translate it back to binary instructions for a CPU.

    Am I the only one who is wondering what the hell is going on? Distribute a binary already!

    1. Re:Fail by Agent+ME · · Score: 1

      Which CPU architecture do we decide that the web relies on?

    2. Re:Fail by gagol · · Score: 1

      I vote for LLVM.

      --
      Tomorrow is another day...
  12. Re: Numerical Calculations dont use Java by Anonymous Coward · · Score: 0

    You laugh, but I have at times been in fear that my boss was going to ask us to do our (monetary) transaction processing system in node.js

    I thought silently, the day that happens is the day I resign. Some people just cannot be told.

  13. Sugar predication to assert at compile time by Baldrson · · Score: 1

    Since asm.js isn't sugared predication, there isn't a natural formalism to make assertions (declarations) about variables such as the set of values they can take on. Not all of these assertions need to be checked at run time. Some can be used at compile time to infer the most efficient implementation for certain use cases, and even generate different implementations for different use cases.

  14. 64-bit computation vs. 64-bit storage by K.+S.+Kyosuke · · Score: 3, Interesting

    JavaScript always uses float64 and this provides maximum precision, but not always maximum efficiency.

    That doesn't make too much sense to me, I thought that typed arrays have always had 32-bit floats as an option. Why should 32-bit storage (on-heap typed arrays) and 64-bit registers (scalar values) be significantly slower than 32-bit storage and 32-bit registers? I thought the performance discrepancy between singles and doubles in CPU float units disappeared a decade and a half ago? (Or are simply single-to-double loads and double-to-single stores somehow significantly slower?)

    --
    Ezekiel 23:20
    1. Re:64-bit computation vs. 64-bit storage by UnknownSoldier · · Score: 1

      Javascript defaults to C's 'double' (64-bit) instead of C's 'float' (32-bit). There 3 things that makes Javascript dog slow for floating-point operations:

      1) Load float64
      2) Does all calculations in 64-bit precision
      3) Write float64

      The loading & storing are not that much more then float32.

      However, most of the time an app can get away with float32 -- it doesn't need the full precision of float64. CPUs manipulate float64 slower then float32. i.e. sqrt(), trig functions, etc.

      The biggest strength Javascript has is that it has no types. Its biggest weakness is that Javascript has no types which makes compilers optimizing Javascript having to guess about usage (both static analysis and dynamic analysis) instead of being able to do it strictly at compile time like a real language that has native types for int, float, etc.

    2. Re:64-bit computation vs. 64-bit storage by gbjbaanb · · Score: 1

      I assume that it used to translating float64 javascript variables to float32 C variables (or vice versa) and now they get to keep them as-is. I think all the graphics calls use float32, so maybe that's where the performance boost comes from.

      it sounds as if what asm.js needs is strong typing for all variables. maybe it'd be easier for the compiler to convert the code then.

      But both the above are just guesses. Personally I'd like to see a standardised language designed for high-performance web browser code, one that's more low level ... maybe C :-) (at least then you could implement any language you wanted on top of it)

    3. Re:64-bit computation vs. 64-bit storage by K.+S.+Kyosuke · · Score: 1
      I understand what you're pointing to, but the loads and stores are 32-bit if you use a Float32Array.

      CPUs manipulate float64 slower then float32.

      Uhm, no. They don't. Not the vast majority of FP ops retired. For example, additions, subtractions, and multiplications have the same latency on recent AMD CPUs, while division is 27 vs. 24 cycles of maximum(!) latency for double vs. single (and even then, they seem to have the same minimum throughput anyway). Again, amortize the cost over the total execution time interleaved with other instructions. Don't tell me that sqrt and trig functions being, say, twice as slow cause an average numerical program to be 30% slower. That would probably mean that you're doing something wrong.

      The biggest strength Javascript has is that it has no types.

      Of course that Javascript has types. It's Javascript, not Forth or BCPL.

      --
      Ezekiel 23:20
    4. Re:64-bit computation vs. 64-bit storage by Pinhedd · · Score: 4, Informative

      Take a look at the image at the following link

      http://www.anandtech.com/show/6355/intels-haswell-architecture/8

      That's the backend of the Haswell microarchitecture. Note that 4 of the 8 execution ports have integer ALUs on them, allowing for up to 4 scalar integer operations to begin execution every cycle (including multiplication). Two of these are on the same port as vector integer unit, which can be exploited for an obnoxious amount of integer math to be performed at once. There are only two scalar FP units, one for multiplication on port-0 and one for addition on port-1.

      The same FP hardware is used to perform scalar, vector, and fused FP operations, but taking advantage of this requires a compiler that is smart enough to exploit those instructions in the presence of a Haswell microprocessor only and fast enough to do it quickly. Exploiting multiple identical execution units in a dynamically scheduled machine requires no extra effort on behalf of the compiler.

      Microprocessors used in PCs have always been very integer heavy for practical reasons (they're just not needed for most applications), and mobile devices are even more integer heavy for power consumption reasons.

      Using FP64 for all data types is obnoxiously lazy and it makes me want to strangle front end developers.

    5. Re:64-bit computation vs. 64-bit storage by reanjr · · Score: 1

      The only difference I can think of is that the generated code will be larger because 64-bit operations take more bytes. This may have an effect on caching and branching.

    6. Re:64-bit computation vs. 64-bit storage by Narishma · · Score: 1

      More importantly regarding the parent's question, the second slide clearly shows that the CPU can do twice as many float operations per cycle than double operations.

      --
      Mada mada dane.
    7. Re:64-bit computation vs. 64-bit storage by Anonymous Coward · · Score: 0

      For example, additions, subtractions, and multiplications have the same latency on recent AMD CPUs, while division is 27 vs. 24 cycles of maximum(!) latency for double vs. single (and even then, they seem to have the same minimum throughput anyway).

      On AMD's latest Kabini, SSE single/packed multiply has only half the throughput for float64 than for float32. (Source: www.agner.org/optimize/instruction_tables.pdf). On latest chips, indeed, most simple FP SSE instructions have same latency and throughput both float32 and float64.

    8. Re:64-bit computation vs. 64-bit storage by Pinhedd · · Score: 1

      That's only when the AVX2 and FMA instructions are used. I do not know of any JS engines that vectorize code to allow the use of vector extensions. Most of them just make use of the basic scalar FP instructions or even use old x87 code.

  15. Re: Numerical Calculations dont use Java by Anonymous Coward · · Score: 1

    Yet another one who thinks Java has anything at all to do with Javascript.

  16. Cents as an integer by tepples · · Score: 0

    Until you get into the tens of millions of dollars, 32-bit integers are fine for counting currency down to the cent. What kind of "(monetary) transaction processing system" were you talking about?

    1. Re: Cents as an integer by clickclickdrone · · Score: 1

      I work in a bank. Our end of day processing runs up numbers in the trillions. Individual currency accounts used for internal processing can easily be in hundreds of billions.

      --
      I want a list of atrocities done in your name - Recoil
    2. Re:Cents as an integer by Anonymous Coward · · Score: 0

      Until you get into the tens of millions of dollars, 32-bit integers are fine for counting currency down to the cent. What kind of "(monetary) transaction processing system" were you talking about?

      "Down to the cent" means the result is accurate to two decimal places, which requires that your calculations be accurate to at least 3 decimal places.
      There are many situations in finance and banking where 5 decimal places of precision are required, and even some cases where it's required to be as high as 9 decimals.

    3. Re:Cents as an integer by sribe · · Score: 1

      Until you get into the tens of millions of dollars, 32-bit integers are fine for counting currency down to the cent. What kind of "(monetary) transaction processing system" were you talking about?

      Well, let's see, in 2007 there were over 200,000 companies in the U.S. with over $10,000,000 in receipts... (http://www.census.gov/econ/smallbus.html)

    4. Re: Cents as an integer by clickclickdrone · · Score: 1

      Plus of course, not all currencies have just 2 decimals and some have exchange rates which produce huge numbers such as the Yen.

      --
      I want a list of atrocities done in your name - Recoil
    5. Re: Cents as an integer by Anonymous Coward · · Score: 0

      The Yen equivalent to the U.S. cent is the Sen (1/100), although they also have the Rin (1/1000).

      There's actually no fundamental reason not to use integers (at least long integers). You can represent 300 milliseconds as the integer 300, or the float 0.3. No matter which format you use, you're going to have to carefully translate units between currencies.

      I suspect it just comes down to what the programmers were most comfortable with, and the various assumptions in the algorithms they were porting from Fortran or Cobol or whatever.

      Actually, now that I think about it an integer with the same bit-width as a float is probably better. You can maintain more precision at every step with an integer, because the exponent field is a waste of space when you're carefully tracking your arithmetic operations. But you would have to reimplement all the nice things that floating point implementations provide, like overflow and underflow detection. So, it probably just comes down to laziness. If you want more precision just demand a larger data type from your architecture. You can do that when you have billions of dollars at your disposal.

    6. Re:Cents as an integer by wonkey_monkey · · Score: 1

      Well, let's see, in 2007 there were over 200,000 companies in the U.S. with over $10,000,000 in receipts... (http://www.census.gov/econ/smallbus.html)

      Did any of them declare losses of -$2147483648 to the IRS?

      --
      systemd is Roko's Basilisk.
    7. Re:Cents as an integer by sribe · · Score: 1

      Did any of them declare losses of -$2147483648 to the IRS?

      Ahem, -$21,474,836.48? Yes, certainly. And many more reported total revenue of that or more.

      (Yes, you get to round to dollars for the IRS, but no that does not mean your accounting system can ignore cents.)

  17. Re:Numerical Calculations dont use Java by Anonymous Coward · · Score: 0

    Java != JavaScript

  18. Multithreading, web workers, and SMP support? by Billly+Gates · · Score: 0

    Firefox is falling quite behind even if it does support ASM.JS. After FF 3.6 and 4.0 I switched browsers. Firefox has improved recently with ram usage and bugs and is usable after version 13.

    However even IE 8 supports multithreading and having a different thread for each tab. Chrome had this since 1.0. Webworkers require this and security requires this. Shit on a 6 core cpu I had for 3 years now I should not have +30 tabs using one damn cpu?!

    Until Firefox helps spread this out and support modern standards and increase security by threading I do not care about ASM.js as I wont use a browser that supports it.

    1. Re:Multithreading, web workers, and SMP support? by sribe · · Score: 1

      However even IE 8 supports multithreading and having a different thread for each tab. Chrome had this since 1.0. Webworkers require this and security requires this.

      Uhm, no, security requires separate processes, not separate threads.

      Shit on a 6 core cpu I had for 3 years now I should not have +30 tabs using one damn cpu?!

      True, but on the other hand, Flash can only hose 1 core and the performance of the browser, leaving all other processes able to share 5/6 of your CPU power. With process-per-tab, now Flash can hose all your cores and bring the whole box to its knees.

    2. Re:Multithreading, web workers, and SMP support? by Anonymous Coward · · Score: 0

      Based on your language, it doesn't matter if Firefox ever catches up. There will always be some pet feature they don't support for you to quibble about. Why should anyone care what you have to say in that light?

    3. Re:Multithreading, web workers, and SMP support? by Anonymous Coward · · Score: 0

      True, but on the other hand, Flash can only hose 1 core and the performance of the browser, leaving all other processes able to share 5/6 of your CPU power. With process-per-tab, now Flash can hose all your cores and bring the whole box to its knees.

      Not in Chrome it can't. Chrome spawns a single dedicated plugin host process for Flash and it runs inside that.

    4. Re:Multithreading, web workers, and SMP support? by viperidaenz · · Score: 1

      Threading has nothing to do with security.
      Running entirely difference processes for each tab is done for stability.

    5. Re:Multithreading, web workers, and SMP support? by Anonymous Coward · · Score: 0

      As Linus has pointed out time and again, security is a function of bug management, and vice-versa.

      Theo de Raadt (OpenBSD) says the exact same thing. But somehow they come to completely different conclusions about the best methodologies for software design and development.

  19. Portability and partitioning by tepples · · Score: 1

    In theory, the text can be translated to x86, ARM, or any other 32- or 64-bit architecture, and the translator enforces some memory safety guarantees.

    1. Re:Portability and partitioning by Sanians · · Score: 1

      In theory, the text can be translated to x86, ARM, or any other 32- or 64-bit architecture, and the translator enforces some memory safety guarantees.

      ...and in reality, your text is transmitted in binary, as a series of bytes, using an encoding known as ASCII, which means that every system that can access plain text can access binary as well.

      Also, compiler-enforced memory safety seems like an accident waiting to happen. ...but then, so does any processing of plain text, as nothing overflows buffers more easily than data which you have to accept no matter how ridiculous its length may be.

    2. Re:Portability and partitioning by tepples · · Score: 1

      every system that can access plain text can access binary as well.

      True, but it should use fewer cycles and fewer amp hours for the ARM system to translate the textual intermediate representation to x86 or ARM instructions than to translate an x86-64 binary to an intermediate representation and then to x86(-32) or ARM instructions.

      Also, compiler-enforced memory safety seems like an accident waiting to happen.

      How is memory safety enforced in a compiler more of "an accident waiting to happen" than the same enforced in hardware, which is the source of the terms "segfault" and "general protection fault"? Other than that Oracle has had a poorer track record than AMD and Intel, that is.

      so does any processing of plain text, as nothing overflows buffers more easily than data which you have to accept no matter how ridiculous its length may be.

      How is this any less true of images, audio, video, or any other content type on the World Wide Web?

    3. Re:Portability and partitioning by Sanians · · Score: 1

      every system that can access plain text can access binary as well.

      True, but it should use fewer cycles and fewer amp hours for the ARM system to translate the textual intermediate representation to x86 or ARM instructions than to translate an x86-64 binary to an intermediate representation and then to x86(-32) or ARM instructions.

      Binary doesn't necessarily mean instruction code for any particular processor. Is this why people insist on text so much, because they've come to equate the word "binary" with "compiled executable?"

      You certainly wouldn't want it to be x86 code anyway, as modern operating systems lack proper security measures to make running untrusted x86 code a good idea. You'd want a pseudo-bytecode which simply indicates operations to perform and you'd translate that into your native machine code, or just run an interpreter on it. The pseudo-bytecode would be designed such that it cannot even represent operations you don't want your untrusted code to perform and so, as long as your programmers aren't completely inept, converting it to native code and running that would be relatively safe.

      Also, compiler-enforced memory safety seems like an accident waiting to happen.

      How is memory safety enforced in a compiler more of "an accident waiting to happen" than the same enforced in hardware, which is the source of the terms "segfault" and "general protection fault"? Other than that Oracle has had a poorer track record than AMD and Intel, that is.

      Well, first of all, have you ever known your CPU to fail to trigger a segmentation fault when a program performs an invalid access? So it's 100% effective then, right?

      What we're concerned about is not detected accidents, but undetected ones. Like when someone finds some way to write a statement that performs something which isn't allowed but which the compiler fails to notice due to the unusual syntax of the statement. In binary form there's only so many ways you can describe an operation. In text there are far more due to there generally being no rules about whitespace, variable name length, the number of digits in your numbers, and many other things. So by using plain text you greatly increase the number of opportunities you have to screw up. That's just fine if you're one of those programmers who believes you'll never accidentally code a buffer overflow into your software, but if you're realistic and realize you're only human, then you realize the wise thing to do is to design a system that's as simple as it can be so that you give yourself as few opportunities to fuck it up as you can.

      I mean, technically you can drive your car from the back seat just by sticking your ten year old in the driver's seat and telling them when to turn the wheel, and with some luck you may even be able to do this rather well, but it's a scheme that's more likely to result in disaster than simply sitting behind the wheel yourself, and so you just don't do it that way.

      so does any processing of plain text, as nothing overflows buffers more easily than data which you have to accept no matter how ridiculous its length may be.

      How is this any less true of images, audio, video, or any other content type on the World Wide Web?

      It's not, and the fact that one particular browser exploit I remember involved using "width" and "height" tags on images with values prefixed with 64k zeros, I think it demonstrates my point rather well. We've been parsing text since the beginning of computing and it's still something we regularly fuck up all the time. We should avoid doing it whenever we don't have to do it, and when we do have to do it, we should do it on a machine under the control of the person who supplies the text, since if they hack themselves no one gives a shit.

      As for audio and video, they of course include some variable length buffers, but it's k

    4. Re:Portability and partitioning by tepples · · Score: 1

      The pseudo-bytecode would be designed such that it cannot even represent operations you don't want your untrusted code to perform and so, as long as your programmers aren't completely inept, converting it to native code and running that would be relatively safe.

      That's what Oracle tried to do with the Java virtual machine but gave up after Oracle discovered that its programmers had been "completely inept", as you put it. Mozilla is trying harder with the asm.js virtual machine.

      Like when someone finds some way to write a statement that performs something which isn't allowed but which the compiler fails to notice due to the unusual syntax of the statement.

      In other words, an undefined behavior. I agree with you that certain popular compilers aren't perfect at detecting undefined or unintended behaviors. Moreover, a lot of programmers forget to turn on some of the undefined behavior detection present in the compiler they have, such as GCC's -Wall -Wextra -pedantic.

      In text there are far more due to there generally being no rules about whitespace, variable name length, the number of digits in your numbers, and many other things

      A lexer handles these particular details. An assembler for assembly language has to have a lexer as well.

      That's just fine if you're one of those programmers who believes you'll never accidentally code a buffer overflow into your software, but if you're realistic and realize you're only human, then you realize the wise thing to do is to design a system that's as simple as it can be so that you give yourself as few opportunities to fuck it up as you can.

      You're assuming that a lexer written using best practices would necessarily have more exploitable vulnerabilities than hardware that has division bugs, F00F bugs, Cyrix coma bugs, and the like.

      We should avoid [parsing text] whenever we don't have to do it, and when we do have to do it, we should do it on a machine under the control of the person who supplies the text, since if they hack themselves no one gives a shit.

      I'd be interested in looking at your patch to allow Firefox to use web pages written in a non-textual binary representation of the HTML DOM.

  20. Size of floats in cache by tepples · · Score: 1

    More 32-bit floats will fit in your CPU's data cache than 64-bit floats.

    1. Re:Size of floats in cache by K.+S.+Kyosuke · · Score: 1

      That's irrelevant, because the caches still reflect the main memory's contents, which, as I outlined, contains 32-bit floats in my scenario. It's the load to registers that gives you those 64-bit in-register scalars. The worst thing that could happen to you is temporarily spilling a 64-bit register or two onto the stack, if you run out of them, but that still seems like a negligible issue, what with 16 FP scalar registers at your disposal on AMD64. The amortized overhead cost of the occasional 64-bit spills versus 32-bit spills can't shouldn't give you a 30% slowdown.

      --
      Ezekiel 23:20
  21. whiney bitches take note by Tumbleweed · · Score: 1

    If the (admittedly stupid) last sentence of the submission hadn't been present, would you still be complaining? They're improving the speed of js by doing some interesting stuff - what's wrong with that?

  22. www.denetimliserbestlik.net by Anonymous Coward · · Score: 0

    denetimliserbestlik.net

    1. Re:www.denetimliserbestlik.net by Anonymous Coward · · Score: 0

      denetimliserbestlik.net

      I should not have visited that site. Now I'm scarred for life.

    2. Re:www.denetimliserbestlik.net by Anonymous Coward · · Score: 0

      What has been seen, cannot be unseen.

  23. Re:Numerical Calculations dont use Java by Billly+Gates · · Score: 1

    Java is not IEEE compliant for floating point calculations anyway. All high performance computing that needs reliability and IEEE compliance uses either C, or specialized asm libraries.

    Using Java for numerical analysis is like using a monkey to design a space shuttle.

    Funny I thought Java runs on the top mainframes at the Stock Market and major institutions world wide.

  24. Electrolysis by tepples · · Score: 1

    If you want threading in Firefox, then go vote up the bugs related to Electrolysis.

  25. Re:Numerical Calculations dont use Java by _merlin · · Score: 2

    Not mainframes, more clusters. All the stuff used for reconciliation and position management uses pure integer and fixed point maths. Market makers like pushing floating point numbers around, but that's just for quick profit calculations when doing the trades. At the end of the day, everything's reconciled with precise maths.

  26. Or anything running in a VM by Sycraft-fu · · Score: 5, Informative

    I get pissed when you hear programmers say "Oh memory is cheap, we don't need to optimize!" Yes you do. In the server world these days we don't run things on physical hardware usually, we run it in a VM. The less resources a given VM uses, the more VMs we can pack on a system. So if you have some crap code that gobbles up tons of memory that is memory that can't go to other things.

    It is seriously like some programmers can't think out of the confines of their own system/setup. They have 16GB of RAM on their desktop so they write some sprawling mess that uses 4GB. They don't think this is an issue after all "16GB was super cheap!" Heck, they'll look at a server and see 256GB in it and say "Why are you worried!" I'm worried because your code doesn't get its own 256GB server, it gets to share that with 100, 200, or even more other things. I want to pack in services as efficient as possible.

    The less CPU, memory, disk, etc a given program uses, the more a system can do. Conversely, the less powerful a system needs to be. In terms of a single user system, like maybe an end user computer, well it would always be nice is we could make them less powerful because that means less power hungry. If we could make everything run 1.5 times as fast, what that would really mean is we could cut CPU power by that amount and not affect the user experience. That means longer battery life, less heat, less waste, smaller devices, etc, etc.

    1. Re:Or anything running in a VM by NormalVisual · · Score: 2

      I get pissed when you hear programmers say "Oh memory is cheap, we don't need to optimize!"

      Preach on, brother. I'd love to see how some of these guys would function in the embedded world, where you often get 1K of flash and 128 bytes of RAM to work with.

      --
      Please stand clear of the doors, por favor mantenganse alejado de las puertas
    2. Re:Or anything running in a VM by doublebackslash · · Score: 2, Informative

      Just fine, at least I do. Just different sets of optimizations to keep in mind, as well as different expectations. I don't think any reasonable person would approach the two problems the same way, but it all boils down to basic computer science.

      Light up pin 1 when the ADC says voltage is dropping which indicates that pressure is too low on the other side of the PPC. Compare that to indexing a few gigs of text into a search engine. Completely different goals, completely different expectations. I'm not master of the embedded domain, but I don't think it is a dark art.

      Perhaps I'm looking at it the wrong way or perhaps my experience is unique or at least rare, but in my eyes it is all the same thing at different scales. Tell me my app is using too much memory then I'll first look at how I can reduce memory pressure, then I'll tell you what is and isn't possible to do and give you a list of sacrifices that would be needed to reduce memory pressure (time to refactor, concurrent operations, latency because of disk, etc etc etc. Not just talking about capabilities but the whole deal). Find the balance and go for it. On the embedded side the same sorts of compromises are made but the scale is just so much smaller. Finite number of IO pins, time to optimize your code to accommodate a new feature, meeting real-time, writing something in ASM to get around a GOD FREAKING AWFUL EMBEDDED COMPILER, etc etc etc.

      I dunno, do I have my head on straight here? All seems fairly straightforward in the end. Specialists can do their bits faster than someone less familiar but with equal skill and understanding. Thats what earns the bucks, getting things done in a timely fassion.

      ((Or at heart I'm an embedded guy. Possible!))

      --
      md5sum /boot/vmlinuz
      d41d8cd98f00b204e9800998ecf8427e /boot/vmlinuz
    3. Re:Or anything running in a VM by bberens · · Score: 3, Insightful

      That depends a lot on what you're doing. It costs about $125/hr for me to optimize my code. Every 8 hours spent optimizing is $1k down the drain and you can buy an entry level server for that price. If it's running on one or two VMs it's probably not worth my company's time to optimize it vs buying more hardware. Conversely if I'm Google a 1% optimization could mean literally thousands of servers. I mean, don't get me wrong. I pay attention to memory allocation and CPU optimization as I'm coding, but only to the level of not making unnecessarily egregious use of resources. Pretty much anything beyond that is a waste for most of the projects I work on.

      --
      Check out my lame java blog at www.javachopshop.com
    4. Re:Or anything running in a VM by Anonymous Coward · · Score: 0

      The important question is actually "which is cheaper, 4GB of RAM per instance of the program, or the time it will take me to optimise this code". In most cases (sadly) that actually means that the programmer is correct –RAM is cheap, and 4GB of it will cost all of $30, aka, 15 minutes of a typical programmer's time. That's not gonna buy you much optimisation.

      Of course, when you then say "okay, but this is going to run 2000 instances", suddenly you're talking about $60,000, and even the programmer spending half a year optimising it becomes worth while.

    5. Re:Or anything running in a VM by bondsbw · · Score: 1

      And my stance is that I first make sure it is correct, then I worry about optimization.

      I know too many projects that were done in the reverse. Sure, we have a slick and fast system, but only when it works. It's kind of like saying /dev/null is a fast database.

      --
      All my liberal friends think I'm a conservative, all my conservative friends think I'm a liberal.
    6. Re:Or anything running in a VM by zippthorne · · Score: 5, Insightful

      Another question is why we need to duplicate an entire operating system to encapsulate applications. If you have 100 things that need to run on a machine why should you need to also run 100 entire operating systems? Something is wrong with the way we're designing servers.

      --
      Can you be Even More Awesome?!
    7. Re:Or anything running in a VM by Atzanteol · · Score: 1

      I get pissed when I hear programmers act like raw performance is the sole measurement of the quality of a language.

      --
      "Ignorance more frequently begets confidence than does knowledge"

      - Charles Darwin
    8. Re:Or anything running in a VM by Blakey+Rat · · Score: 0

      Gasp! A programmer with a basic working knowledge of economics and the value of time!? UNTHINKABLE.

    9. Re:Or anything running in a VM by NormalVisual · · Score: 1

      Just fine, at least I do.

      That's great to hear. Seriously, I'm not being snarky. It's nice to see more guys that can deal with different environments well. You're absolutely right that it's not rocket science, but a lot of guys don't get past the abstract model of the machine that their dev environment/language provides for them.

      --
      Please stand clear of the doors, por favor mantenganse alejado de las puertas
    10. Re:Or anything running in a VM by Anonymous Coward · · Score: 0

      " I'm not master of the embedded domain, but I don't think it is a dark art."

      As a master of the embedded domain, I can assure you that your lack of thinking of it as a dark art shows that you haven't yet reached the level of neophyte ;-)

    11. Re:Or anything running in a VM by Anonymous Coward · · Score: 0

      Preach on, brother. I'd love to see how some of these guys would function in the embedded world, where you often get 1K of flash and 128 bytes of RAM to work with.

      We'd be better off if they were all dead. I saw we given them 1 flash-bang, 128 bullets, and dump them in Fallujah. It'd be interesting to see how they function there, with limited resources to work with.

    12. Re:Or anything running in a VM by poopdeville · · Score: 1

      Maybe I'm confusing my history, but I thought Java was basically pre-Linux. Let alone pre-Linux-goes-big-on-the-server-market.

      So it makes sense that somebody would want to make an environment that abstracts the machine away and works reliably on every machine. That was the whole point of POSIX, though it didn't go far enough to satisfy everybody. And it makes sense that savvy consumers would want that too, for a variety of reasons: Large market for developers, easy deployment, sunk cost fallacy, less vendor lock-in, etc.

      --
      After all, I am strangely colored.
    13. Re: Or anything running in a VM by Anonymous Coward · · Score: 1

      Math fail. You can't compare percentages w/o establishing percentages of WHAT.

      Spending 1000$ to optimize for a 1% gain on a 10,000$ expenditure nets you 100$. Losing proposition.

      Spending 1000$ for a 1% gain on a 1,000,000 expenditure nets you 10,000$. Now it's worth it.

    14. Re:Or anything running in a VM by Pinhedd · · Score: 3, Informative

      Ideal virtual machines are indistinguishable from networked servers. Most x86 VMMs don't quite reach this level of isolation, but the VMMs used on IBM's PowerPC based servers and mainframes do.

      From the perspective of system security, a single compromised application risks exposing to an attacker data used by other applications which would normally be outside of the scope of the compromised application. Most of these issues can be addressed through some simple best practices such as proper use of chroot and user restrictions, but those do not scale well and do not address usability concerns. A good example is the shared hosting that grew dominant in the early 2000s while x86 virtualization was still in its infancy. It was common to see web servers with dozens if not hundreds of amateur websites running on them at once. For performance reasons a web server would have read access to all of the web data; a vulnerability in one website allowing arbitrary script execution would allow an attacker to read data belonging to other websites on the same server.

      From the perspective of users, a system designed to run 100 applications from 20 different working groups does not provide a lot of room for rapid reconfiguration. Shared resource conflicts, version conflicts, permissions, mounts, network access, etc... it gets extremely messy extremely quickly. Addressing this requires a lot of administrative overhead and every additional person that is given root privileges is an additional person that can bring the entire system down.

      Virtual machines on the other hand give every user their own playground, including full administrative privileges, in which they can screw around with to their hearts content without the possibility of screwing up anything else or compromising anything that is not a part of their environment. Everyone gets to be a god in their own little sandbox.

      Now, that doesn't mean that the entire operating system needs to be duplicated for every single application. Certain elements such as the kernel and drivers can be factored out and applied to all environments. Solaris provides OS level virtualization in which a single kernel can manage multiple fully independent "zones" for a great deal of reduced overhead. Linux Containers is a very similar approach that has garnered some recent attention.

    15. Re:Or anything running in a VM by jareth-0205 · · Score: 1

      I get pissed when you hear programmers say "Oh memory is cheap, we don't need to optimize!"

      Preach on, brother. I'd love to see how some of these guys would function in the embedded world, where you often get 1K of flash and 128 bytes of RAM to work with.

      Eh... It's all down to how much time you get to create your program and how much it has to do. Embedded has to do much less, and gets longer to do it than desktop / server work. Yeah, I'd love to optimise everything but there's a great big list of business requirements here and a deadline, and an already-complex codebase that needs more features added. Embedded and server have *totally* different challenges.

    16. Re:Or anything running in a VM by Lennie · · Score: 1

      Actually, lots of people use containers:

      https://www.docker.io/
      https://www.youtube.com/watch?v=p-x9wC94E38

      Facebook, Google and many smaller players understood this years ago.

      (not talking about the ridiculously oversubscribed VPS you can get for $3 a month)

      --
      New things are always on the horizon
    17. Re:Or anything running in a VM by pla · · Score: 1

      In the server world these days we don't run things on physical hardware usually, we run it in a VM. The less resources a given VM uses, the more VMs we can pack on a system. So if you have some crap code that gobbles up tons of memory that is memory that can't go to other things.

      First - I write this as the sort of programmer who agrees with you in principle. I make my code as light and tight as possible.

      But as a programmer, I get pissed when SysOps bitches me out for making tradeoffs that drastically improve performance - Such as trading off RAM for CPU usage. RAM comes cheap. Storage comes cheap. Hell, even CPU time comes cheap, but when you take a 24-core 256+GB behemoth, and oversubscribe to the point that nothing runs well on them? Don't blame the programmers, bro, look in the frickin' mirror.

      VMs can indeed save admins a ton of work. They make HA possible, they make backups trivial, they minimize physical machine babysitting, they make spinning up a test bed truly a joy. No doubt, best tech ever when dealing with a large number of light workloads you'd like isolated from each other.

      Programmers have a job to do, just like you do. And when that involves serving up a lot of data to a lot of users, yes Virginia, that takes resources. Go ahead and run my SQL instance as a VM for all the benefits mentioned above - But until you give me a beefy box at 1:1 provisioning, don't you dare look my way when I bring the box to its knees by actually using those resources.

    18. Re:Or anything running in a VM by Anonymous Coward · · Score: 0

      Java != JavaScript please hand in your geek card on the way out.

    19. Re:Or anything running in a VM by MozeeToby · · Score: 1

      It's not "memory is cheap" as much as "memory is cheaper than engineering time". A good engineer will understand when that statement is true and also when it isn't. A crap engineering will have no idea how to reduce the footprint anyway, so knowing the difference is moot.

    20. Re:Or anything running in a VM by Anonymous Coward · · Score: 0

      $125/hr for you to optimize your own code? What sort of idiots do you work for, so I can apply for a job? You are paid to write code...*then* you optimize it. You win at exploiting idiots it would seem.

    21. Re:Or anything running in a VM by operagost · · Score: 1

      You most certainly can NOT buy an entry-level server for $1K. At least, not one I'd care to support. People who aren't Google don't need to be building servers from scratch-- because that's the only way you'll get anything useful for $1,000. Any major manufacturer server (Dell, HP, IBM) with even next-day hardware support is going to be over $1K-- with no RAM or disks (or even an FC controller so you can use a SAN) installed in the bare chassis. A RAID controller+cache can cost over $1K.

      --

      Gamingmuseum.com: Give your 3D accelerator a rest.
    22. Re:Or anything running in a VM by bberens · · Score: 1

      Dell PowerEdge R210 II Ultra-compact Rack Server, Intel® Celeron® G530 processor, 2GB memory and 500GB hard drive, Dell Price $609. That's their lowest end 1U server. Sure, it's a piece of shit, but you've got nearly $400 in upgrades left before you hit that $1k mark.

      --
      Check out my lame java blog at www.javachopshop.com
  27. Re:don't we know it by Dahamma · · Score: 1

    Except duh, websites are not software, "websites" are an experience made up of literally dozens of components on servers, clients, browsers, intermediate networking equipment, routers, modems, etc that all contain software - only one small piece of which is usually written in Javascript/HTML.

  28. Not really true by SoftwareArtist · · Score: 2

    Let's correct that sentence:

    "Now Mozilla claims that with some new improvements it is at worst only 1.5 times slower than single threaded, non-vectorized native code."

    In other words, it's only 1.5 times slower than native code that you haven't made any serious effort to optimize. Hey, I think it's great they're improving the performance of Javascript. But this is still nowhere close to what you can do in native code when you actually care about performance.

    --
    "I'm too busy to research this and form an educated opinion, but I do have time to tell everyone my uninformed opinion."
    1. Re:Not really true by geminidomino · · Score: 1

      Yeah, needs more correction than that, since "1.5 times slower" makes no damn sense. Even if all asm.js did was halt, it's still only 1x slower... Does it go through your hard drive and undo work done by native code, or something?

    2. Re:Not really true by Anonymous Coward · · Score: 0

      Of course you're right, these are just baby steps. But I'd argue that even if this turns out to be little more than a research project it's still valuable.

      Mozilla's also been seriously working on vectorization and threading in JS; in fact, they're actively working on SIMD extensions as well as parallelized array methods. I wouldn't be surprised if asm.js would be able to take advantage of these things as well soon, assuming LLVM+Emscripten can generate the JS bytecode necessary for it.

      Basically it seems that the JIT engines used for JS are becoming serious competitors, and slowly adding the tools necessary to take advantage of cutting-edge research (not that I'd call their current state anywhere near cutting edge as far as JITs go, but still it's nice to see this kind of effort).

  29. So by Anonymous Coward · · Score: 1

    the linux kernel works on its own? none of that GNU crap or anything else? and VLC only needs QT to run?

  30. Re:don't we know it by Concerned+Onlooker · · Score: 3, Informative

    Websites are no less than distributed applications. If you had been paying attention you would have noticed that website development has gotten a lot more rigorous than in the old days.

    --
    http://www.rootstrikers.org/
  31. Standardize Javascript bytecode already by kervin · · Score: 1

    I'd wish they'd stopping slowly and painfully going through the intermediate steps and standardize the Javascript Bytecode representation. Then javascript wouldn't be any slower than native code. Even faster in some situations ( due to runtime optimizations, if the Java folks are to be believed ).

    Why on earth are we still only transferring Javascript as text? It doesn't really help security. Is obfuscated Javascript any easier to read than decompiled bytecode?

    1. Re:Standardize Javascript bytecode already by Anonymous Coward · · Score: 0

      Because compiling it to bytecode would make it obvious that it's just like the Java hype of the early 00s, and then it wouldn't be kewl anymore.

    2. Re:Standardize Javascript bytecode already by Anonymous Coward · · Score: 0

      Because this way it will run on any relatively modern browser. There's nothing stopping asm.js from switching to a non-plaintext binary format (or even making that optional) other than browser engines not supporting it yet. It will also be tougher to tell browser makers to support a certain set of bytecodes until it's known what's feasible and required. If it wasn't such a pain, then NaCl would have been adopted years ago.

    3. Re:Standardize Javascript bytecode already by Anonymous Coward · · Score: 1

      Because conversion from the AST (abstract syntax tree) to byte code tends to be lossy. When you're optimizing code you want as much context as possible. Any particular byte code format will preclude some clever optimizations--current and future.

      Because JavaScript has exceptionally loose typing (object prototyping really complicates things), it's even more important to analyze the AST. If a byte code format was used, optimizers would just regenerate a tree anyhow.

      Think of the source code as a portable representation. (Obv.) There are better ways to represent it than the language syntax, but almost any tree form is better than byte code. And if you're going to standardize a tree form, why not the language itself.

      I just Googled this just to verify that I wasn't being stupid, and interestingly the Dart guys say pretty much the same thing: https://www.dartlang.org/articles/why-not-bytecode/

    4. Re:Standardize Javascript bytecode already by tibit · · Score: 1

      Of course we all know that a tree can be walked in a given order and used to generate a list of nodes: there's your bytecode. All it means is that good bytecode should represent a tree, not a string of basic blocks like the usual bytecode does...

      --
      A successful API design takes a mixture of software design and pedagogy.
  32. Well by Anonymous Coward · · Score: 0

    I've noticed websites have gotten alot more sophisticated, and operating systems (linux included) are still a PITA to maintain. So knock scripters all you want, at least they're getting better at their jobs.

    1. Re:Well by Dahamma · · Score: 1

      No, scripters are still scripters. It's the designers that are getting better at their jobs.

  33. Maximum precision? by raddan · · Score: 4, Informative

    Let's just open up my handy Javascript console in Chrome...

    (0.1 + 0.2) == 0.3
    false

    It doesn't matter how many bits you use in floating point. It is always an approximation. And in base-2 floating point, the above will never be true.

    If they're saying that JavaScript is within 1.5x of native code, they're cherry-picking the results. There's a reason why people who care have a rich set of numeric datatypes.

    1. Re:Maximum precision? by Anonymous Coward · · Score: 0

      It is always an approximation.

      True for almost all numbers, but not all. For example: (0.25 + 0.50) == 0.75. true.

    2. Re:Maximum precision? by Derek+Pomery · · Score: 1

      That's only true for fractions.
      1+2 == 3 is always going to be true.
      As is 123456789 + 987654321 == 1111111110

      You can absolutely express a 32 bit integer in a double with no approximation ever.
      We rely on this in our lua scripting as a matter of fact.

      http://asmjs.org/spec/latest/ relies on this for the 32 bit integer parts of their spec.

      Actually, you can go a lot further than 2^32 - all the way up to 2^53-1.
      This is taken advantage of in non-asm.js places. See:
      http://bitcoinmagazine.com/7781/satoshis-genius-unexpected-ways-in-which-bitcoin-dodged-some-cryptographic-bullet/

      And, you'll be happy to know (well, we were), that Mozilla is adding 64 bit ints to their JS as well, although when that'll be widely available, who knows.

      --
      -- perl -e'print pack"H*","6e656d6f406d38792e6f7267"' /. ate my old sig. Bastards.
    3. Re:Maximum precision? by Derek+Pomery · · Score: 1

      Oh, and for asm.js (and, for the JS jits in general when they are sure of the types), floating point is not used if the number known to be int, so, there's another win outside of the main one from the article.

      --
      -- perl -e'print pack"H*","6e656d6f406d38792e6f7267"' /. ate my old sig. Bastards.
    4. Re:Maximum precision? by Anonymous Coward · · Score: 0

      There's a reason why people who care have a rich set of numeric datatypes.

      I like to keep a rich set of numeric datatypes on hand just to show off. Some people think I have a hoarding problem, but I see myself as more of a datatype collector. And then there's this

    5. Re:Maximum precision? by wonkey_monkey · · Score: 1

      It doesn't matter how many bits you use in floating point. It is always an approximation.

      Often, but not always. Integers, or negative integer powers of 2 and their sums, won't be approximate (though of course you can't be sure they weren't rounded from some unrepresentable number).

      (0.25+0.50)==0.75
      true

      --
      systemd is Roko's Basilisk.
    6. Re:Maximum precision? by tibit · · Score: 1

      This is not informative, it is patently false, and you just pretend that floating point is this black box that nobody knows anything about.

      --
      A successful API design takes a mixture of software design and pedagogy.
    7. Re:Maximum precision? by tibit · · Score: 1

      From your linked page:

      Most current applications and databases have to use Binary Coded Decimal (BCD) to perform calculations with money

      This is the problem. BCD is bad at cache utilization (it wastes 17% memory) and bad at utilizing the instruction set of the processor (unless the processor natively supports BCD). If you want to see how to do extended precision integer math, quite efficiently, using nothing more than platform-native ints and with no memory inefficiencies, look no further than this C implementation

      Adding a decimal floating point datatype to the CPU may well bring no performance gains at all, since most CPUs are constrained by the memory bandwidth. Good code can do non-decimal extended precision arithmetic faster than the memory can keep up, so those IBM-peddled data types help with nothing.

      --
      A successful API design takes a mixture of software design and pedagogy.
    8. Re:Maximum precision? by raddan · · Score: 1

      I never made any such claim. If you doubt the veracity of my statement, open a JavaScript console (Chrome, Firefox, Rhino, whatever) and try it yourself.

      When you're done with that, go read What Every Computer Scientist Should Know About Floating-Point Arithmetic. I cribbed the example directly from the article.

    9. Re:Maximum precision? by raddan · · Score: 1

      I was being glib. Just nitpicking on the phrase "maximum precision". Sorry, it's a bad habit developed from working around a bunch of pedantic nerds all day.

      Thanks for the pointer about native ints, although I can't seem to find any kind of authoritative reference about this. This guy claims that asm.js converts these to native ints (see Section 2.3: Value Types), but his link seems to be talking about the JavaScript runtime, not the asm.js compiler. If you have a reference, I'd appreciate it if you'd send it along.

    10. Re:Maximum precision? by Derek+Pomery · · Score: 1

      Hey, just noticed this after xmas.
      I'd seen discussion of this in the announce, and seems pretty clear the intent in the spec, but anyway, here's the landing patch.
      https://hg.mozilla.org/mozilla-central/rev/b3d85b68449d#l29.613
      Note that section.

      --
      -- perl -e'print pack"H*","6e656d6f406d38792e6f7267"' /. ate my old sig. Bastards.
  34. Re:don't we know it by Dahamma · · Score: 1

    Wait. are you talking to *me* or just making a statement? Because that's pretty much exactly what I said...

  35. Mining by Anonymous Coward · · Score: 0

    Excellent! Can mine litecoins already :-)

  36. How about making the Canvas tag not suck by Dwedit · · Score: 1

    How about making the Canvas tag not suck?
    Seriously, you can give it the most simple test (draw an image every frame, or fill a rectangle), and it will run unacceptably slow. For comparison, a simple Win32 program that changes the background color of a maximized window once per frame has very low CPU usage, but a simple Javascript program that flashes a canvas red and blue every other frame uses 100% CPU usage if the canvas is 1024x768.
    Until the canvas isn't the bottleneck anymore, Javascript graphical programs will continue to suck, and no amount of ASMJS magic will help with that bottleneck.

    1. Re:How about making the Canvas tag not suck by Anonymous Coward · · Score: 0

      Yes! - this is where chrome spanks firefox blue. I write a lot of data visualisation software, and it spends so much time painting on firefox. Chrome is nice in that regard, it paints fast, both canvas and svgs.

    2. Re:How about making the Canvas tag not suck by Anonymous Coward · · Score: 0

      Who cares about canvas anymore? A few people who still don't use WebGL or SVG? Seriously, most of the performance problems people whine about with Canvas use are people trying to abuse it without realizing there are better solutions for their needs.

    3. Re:How about making the Canvas tag not suck by ChunderDownunder · · Score: 1

      Sounds like the WebGL behind one's browser is using software rendering because hardware acceleration has been blacklisted. (Or at least that's the case for my onboard Intel GPU)

      A previous rich-client browser platform, AWT/Swing (which bit the dust for a variety of reasons), had OpenGL/DirectX accelerated drawing pipelines for nearly a decade for Java2D, Java3D & jogl.

      Yet in 2013 we're still stuck with unstable graphics drivers. Hmmm...

    4. Re:How about making the Canvas tag not suck by Anonymous Coward · · Score: 0

      Today's OpenGL is not necessarily the same as the one from ten years ago. Browsers may require extensions and capabilities that did not exist back then, plus while an older chipset may be perfectly fine at flinging a few thousand textured polygons they might not be able to rasterize text and scroll large amounts of web-style information without crashing a lot. Not to mention the capabilities of the modern web, with CSS/SVG filters and WebGL. Doubly so if the drivers aren't as good as the ones for older OSes ten years ago, when these graphics chips were the company's flagship products and they had to care to support them.

  37. "So who needs native code now?" by Cammi · · Score: 1

    Anti-Criminals ... aka real programmers.

  38. 64 Bit Integers by Anonymous Coward · · Score: 0

    float64 is not good for human programmers. You can't store even 64 bit integers in native javascript. You don't have to be a scientific programmer to need Int64. There are tons of applications where 64bit integers are used and javascript can't handle it. For example in .net DateTime ticks are a 64 bit integer type, try taking the current time in .net ticks and using it in javascript. Not wanting to know the variable type is crazy, strongly typed code is always more manageable and less prone to mistakes.

  39. Here's who needs native code: by Reliable+Windmill · · Score: 1

    People implementing JavaScript engines. Among many other. You would instantly lament if every bit of machine code deployed in the world were suddenly to reimplement itself in your beloved JavaScript.

    --
    Signature intentionally left blank.
  40. Re:Numerical Calculations dont use Java by Anonymous Coward · · Score: 0

    Java is not IEEE compliant for floating point calculations anyway. All high performance computing that needs reliability and IEEE compliance uses either C, or specialized asm libraries.

    Using Java for numerical analysis is like using a monkey to design a space shuttle.

    LOL, are you high? Java runs Wall Street.

  41. Everything Must Be a Web Site by Sanians · · Score: 2

    The "everything must be a web site" mentality has confused the hell out of me for ages as well.

    For some time I assumed it was probably for portability, but while writing a game I'm sure no one cares about I found that portability actually isn't all that difficult. The number of #ifdef involved to make it compile for both Windows and Linux (and FreeBSD, though I haven't compiled for it in about a year) amount to a very minor part of the code, and probably wouldn't have been even that much if I were more of a fan of using other people's libraries. (It does use GLFW, which no doubt is taking care of at least 95% of the portability issues for me.) I suspect even a Mac OS version wouldn't be too difficult though I never could figure out how to produce one from Linux. Granted, I don't have a reliable Linux version available due to LGPL issues, but no one cares about Linux anyway. They could certainly achieve portability between the platforms they care about (anything Windows runs on, and Mac OS) easily enough with a compiled C program, and if they really cared they could also set up a server farm of Linux machines so that they have a copy of each distribution available to compile a Linux version too.

    So then why is it I go to YouTube and deal with shitty web video that barely plays correctly if it does at all? I've seen the red and blue channels reversed in video, I've seen 30-second seek times (even seeking backwards), and at times it simply doesn't work at all. The same goes for hulu.com or any online radio web site. Even Facebook could benefit from having a custom application. ...and all of these things would run more efficiently as an application than they do as a web site.

    Hell, the new flickr.com is probably the best example. In their desire to have a wall of images in the search results, the javascript spends so much time examining possible arrangements of the images that the computer grinds to a halt. The web site is damn-near unusable, and certainly only "usable" if you're desperate. As far as "I'm bored so I'll look for something interesting on Flickr" goes, it's positively worse than being bored. Granted, they should do the intelligent thing and just go back to the web site they had, but as long as they're insistent on styling their image indexes like that, if they were to do it in a custom application, it could figure out the arrangements it wants in the blink of an eye and so the user experience wouldn't be so miserable.

    The craziest thing about it for me is that, given the choice between making a web site and making a proper application, I'd rather make a proper application. Communicating with a server over a TCP connection is a piece of cake, so I don't need a web browser for that, nor do I want to structure everything as an HTTP request anyway. I also don't have to worry about cross-testing in every version of every web browser. Granted, you do then have to cross-test to different operating systems, but at least between Windows and Linux, I've found most of the issues that crop up tend to be data access errors that show up in one version but not the other simply due to data being arranged differently in each executable, and I haven't even seen that since compiling with -fstack-protector-all and writing a wrapper for malloc() in an effort to catch any invalid data access. With web sites I always seem to spend at least 20% of my time trying to make things look at least reasonable in every web browser, and I'm not one of those people who even tries to do fancy shit, I just keep running issues into things like one web browser inserting a blank line somewhere where another doesn't and trying to figure out some way to structure everything so that, if they can't all look the same, then at least none of them end up with ass-ugly formatting.

    So I can only guess that the "everything must be a web site" is a user-driven demand.

    Part of that might be the Windows convention that no matter how trivial

    1. Re:Everything Must Be a Web Site by Anonymous Coward · · Score: 0

      You want Qt. Seriously. It'll be way more fun than developing for bare WINAPI.

  42. Re:don't we know it by Concerned+Onlooker · · Score: 1

    I was referring to you. Pardon me if I misconstrued your meaning. Since websites/applications ARE software I am not sure what you meant.

    --
    http://www.rootstrikers.org/
  43. Re:don't we know it by Bite+The+Pillow · · Score: 1

    Instead of overgeneralizing, let's specify the subject. As was said above, "scripting isn't programming". This ignores many of the huge libraries written in scripts, such as ASM.js, which were nowhere near trivial to crap out.

    A few lines of scripting isn't programming, but it qualifies as "website development". Also included is a fully separated 3-tier, pre-compiled architecture with persistence and unit tests.

    Websites are frequently, way less than distributed applications. Speaking of websites as if they encompass only a part of what's true speaks of the ignorance of your experience. And I would have replied to Dahamma above but you got the mod points.

    I don't see any proof of rigor in anything I have seen - I do see PHP and python, C# and jsp - all both with and without any rigor. Being compiled does not imply rigor, and being separated across N tiers does not mean rigor. I'm pretty sure you mis-typed, but the information here being general is, in general, completely without factual basis.

    In fact, I would argue that more people are writing websites via programming, where they used to do the same via scripts, and with the exact same regard (or lack of) to rigor.

  44. Re:Numerical Calculations dont use Java by viperidaenz · · Score: 1

    Yes it is, see strictfp
    If you don't specify strictfp, the JVM is allowed to use higher precision data types in intermediate calculations, leading to greater precision and better performance at the expense of IEEE conformity.

    If you do, you get IEEE 754 compliance.

  45. Ya well by Sycraft-fu · · Score: 1

    You have to price out all the details. The question isn't what the server costs to buy. It is what it costs to buy, what support on it costs, both in terms of a warranty and sysadmin time, what physical space costs, or is available, what power and cooling cost, and what kind of reliability you need.

    A "cheap" server can end up being not so cheap in many cases. A cheap server is great right up until the point where it fails, and then there is no way to fix it or restore it in a reasonable amount of time.

    You can see what it costs for more realistically reliable things by looking at what VMs cost on the open market. For example Pair, who provides top notch reliability and support, wants about $1500/year for a server with 3GB RAM/80GB disk. Linode, which is much lower end particularly with regards to management, but still solid, wants about $500/year for 2GB RAM/96GB disk. These are for virtual servers, not physical systems. That gives you some idea what a server might actually cost in terms of all the things like power, cooling, bandwidth, maintenance, management, hardware refresh, backup, and so on.

    That aside, if the program is for a very specific task, ok then development cost can be looked at fairly straight to server cost 1:1, if it is for resale/use elsewhere, then not so much. You can't very well try and foist off the development cost to each customer or argue they should be willing to buy a lot of hardware to support it.

    I'm not saying programmers should spend man-years optimizing for every little fractional ounce of improvement (though in some cases it is worth it, read up on some of the stuff Michael Abrash has done) but that optimization does matter.

    1. Re:Ya well by Bert64 · · Score: 1

      You can't very well try and foist off the development cost to each customer or argue they should be willing to buy a lot of hardware to support it.

      This is exactly what happens, customers of software have gotten used to ever increasing requirements so the only code that ever gets any kind of optimization tends to be code that the developer is planning to use a lot themselves.

      --
      http://spamdecoy.net - free throwaway anonymous email - avoid spam!
  46. Re:Numerical Calculations dont use Java by ChunderDownunder · · Score: 1

    Jane Street runs OCaml! :-)

  47. I hate theories like this. by ddt · · Score: 0

    I'm sorry, but this is just wrong, and I'm sick of hearing these theories about why JavaScript must always be sloewr. There's nothing limiting to the potential back-end performance of a JavaScript VM just because of a lack of data types. If you want to get serious about execution speed, then you dynamically profile the domains and ranges of all your operations. You don't make assumptions about them. When you know what their potential ranges given the input domains, then you use as small a datatype as you can in order to get optimal performance (cache locality, memory bandwidth, as well as auto-vectorization opportunities and even table-lookups).

    This is HARD WORK to do, but it is NOT impossible, NOR is it a limitation of languages lacking a rich set of numeric datatypes. In fact, once you get serious about domain/range analysis, you can potentially pull WAY AHEAD of statically compiled languages in speed, because they are stuck performing full 64-bit or 80-bit FP operations (and moving all that bloated data around) on numbers that often doesn't need even a fraction of that precision.

    1. Re:I hate theories like this. by dzfoo · · Score: 1

      What are you talking about? JavaScript must always necessarily be slower than native code due to its abstracted nature. If it needs an interpreter, or virtual machine, or any other intermediate process between the program code and the CPU, there will be overhead.

      Having the CPU execute native code directly will always be faster.

      Now, there's an argument to be made that a higher-level, more abstracted language makes people more productive, and by extension, program code more expressive. But this is a different trade-off and objective than building a high-performance application.

                  -dZ.

      --
      Carol vs. Ghost
      ...Can you save Christmas?
    2. Re:I hate theories like this. by PCM2 · · Score: 1

      What are you talking about? JavaScript must always necessarily be slower than native code due to its abstracted nature. If it needs an interpreter, or virtual machine, or any other intermediate process between the program code and the CPU, there will be overhead.

      This is kind of an old-fashioned argument. Modern VMs are often essentially executing native code by the time the code is actually running. If the bulk of the overhead happens at launch time, or a JIT compiler only has to step in every so often, the level of performance can be such that the difference from "pure" native code is insignificant for most applications. Don't mistake a modern VM for a 1980s style Basic interpreter. The two are very different beasts.

      --
      Breakfast served all day!
  48. I can't answer for C but I can for delphi and C++ by Anonymous Coward · · Score: 0

    But in delphi it is trivially easy with an onmouseover event. And as far as I remmember some of the GUI framework and delphi compiler can also do it in C++, such event also exists in them... Sure it isn't C ANSI, but C ansi does not specifiy those event as far as I know, the GUI gframework can and do.

  49. Re:Numerical Calculations dont use Java by Anonymous Coward · · Score: 0

    No, you don't. Read http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf

    About the author (W. Kahan) from wikipedia: "Kahan was the primary architect behind the IEEE 754-1985 standard for floating-point computation (and its radix-independent follow-on, IEEE 854). He has been called “The Father of Floating Point,” since he was instrumental in creating the original IEEE 754 specification. Kahan continued his contributions to the IEEE 754 revision that led to the current IEEE 754 standard."

  50. kernel extension by kernel_user · · Score: 1

    What are the chances that this will be integrated in the Linux kernel ? For better performances as a host and as a guest. I can already see large cluster of Linux running in heterogeneous environments.

  51. Great another case of JS being abused....... by Anonymous Coward · · Score: 0

    If you are writing assembly in javascript you are doing it wrong. A web broswer is supposed to display documents, not run desktop applications. If you really need to process dynamic data with that level of control and efficiency with the result put on a dynamic web page, then you need a daemon or some service application doing it, and have JS pull the result. NOT make JS do the entire damn thing.

    The only times I see the argument "Who needs native code?" is when:
    A. Someone is trying to make sales / sound good to their boss by using $BUZZWORD / being lazy / $ULTERIOR_MOTIVE.
    B. They clearly don't care about resource usage. (Which is what TFA is about.)
    C. The user base does not want to install a program, or has some objection as they want it to "Just work" regardless of where they are.
    D. There is some crippled device somewhere that is prohibited from running some application due to a walled garden.

    In the case of A and B, it's clear abuse. Case A is self-serving, where as B does not care and therefore, cannot be helped.

    In C's case, there is some justification, as the user base would most likely move to a different product / service or just get pissed off if it suddenly required downloading an application. Regardless as to what some programmer's believe, if they piss off their user base, they loose users. If they loose too many users, they are running a dead project, or are out of a job. So in this case abusing JS can be somewhat justified.

    D is special, as it's a fallacy. The idea of writing some JS to bypass a more serious problem, (I.e. The fact you are trying to run something the device does not permit for some stupid reason.), does not actually fix the real issue. Eventually the gatekeepers will figure out they left a hole in the wall, and they WILL do something about it. The chances of that only go up, as the practice becomes more common place.
    The real solution is to get a better platform. Either by convincing the gatekeeper that the application you want to write has merit and should be permitted, or by getting the gatekeeper to open up their platform more. Barring that your only option is: Get a different device, and explain to your users the reason for the lack of support on the old device. Not pretty, and it conflicts with my justifcation of case C, but it's better than ignoring the real issue.

    If someone has a case I did not think of, please feel free to add to it. Also if someone has another justification for using JS and asm together I'd love to hear it.

    1. Re:Great another case of JS being abused....... by Cyko_01 · · Score: 1

      If you are writing assembly in javascript you are doing it wrong. A web browser is supposed to display documents, not run desktop applications.

      If you are writing desktop applications (ie. a windows PC) for a web browser, then yes, you are doing it wrong. "who needs native code" is certainly over-stating things. HTML + Javascript is appealing when you want to write an application - what smartphones call "apps - that runs on as many platforms - architectures, operating systems, screen sizes - as possible without rewriting all of your code 300 times for each device. If you can write your main code once and have it run on your xbox, playstation, samsung S4, blackberry, iphone, PC, linux, mac, your refrigerator and barbeque then why wouldn't you do that! And with html + javascript there is no installation required - just send a mass email with a shortcut to the webpage for everyone that needs it. It's more like "who needs 300 different versions of the same native code"

      If you really need to process dynamic data with that level of control and efficiency with the result put on a dynamic web page, then you need a daemon or some service application doing it, and have JS pull the result. NOT make JS do the entire damn thing.

      so you are saying you should spend money beefing up your server so you can present info from the client, to that very same client, after doing some calculations it could have done itself? If the client already has a system capable of doing its share of the work, then why not distribute the load and enable it to do so?!

    2. Re:Great another case of JS being abused....... by Anonymous Coward · · Score: 0

      > A web broswer is supposed to display documents, not run desktop applications.

      This hasn't been true for at least 10 years. Get with the program! (pardon the expression)

  52. Re:don't we know it by Anonymous Coward · · Score: 0

    Except for the fact that JavaScript is neither a scripting language nor Java based at all, but rather a complete programming language with a stupid name.

    You'd do well to watch these 3 videos if you want to know more about JavaScript.

  53. Re:Numerical Calculations dont use Java by Anonymous Coward · · Score: 0

    One of these days I will be next to somebody who will not be an AC and who will confuse Javascript with Java and that person will be very sure of himself that what comes out of his mouth makes any kind of sense. It will be a fine day to murder that person right on the spot. I will truly and thoroughly enjoy it.

    will you wait until the rise of your lord and savior to the position of eternal emperor of the world first, so that you can murder this other person on religious grounds and be excused for it?

  54. This is just... by Anonymous Coward · · Score: 0

    10/10 flamebait.

  55. Re:don't we know it by Anonymous Coward · · Score: 0

    I'm guessing he thinks of "software" as a prepackaged binary you buy or download and install on your machine.

  56. Real programmers not caring about types by Anonymous Coward · · Score: 0

    What kind of programmer doesn't care about the difference between int, int32, float, float32 or float64 ?

    The lack of these types makes JavaScript not really a proper programming language in my book.

    1. Re:Real programmers not caring about types by Anonymous Coward · · Score: 0

      > What kind of programmer doesn't care about the difference between int, int32, float, float32 or float64 ?

      Gee, I dunno, Lisp programmers? Smalltalk programmers?

      Lots of high-level languages don't distinguish numeric types by word size or int vs. float, so I guess those aren't really "proper" programming languages either?

  57. Re:don't we know it by Dahamma · · Score: 1

    Well, I guess it may be splitting hairs... but IMO a "website" is not necessarily "software" any more than a house is "wood" or "plumbing". I can have a "website" that is made up entirely of static HTML and images - or as its simplest, just a single image. And no, I don't think HTML qualifies as software, as it really doesn't fit the common definition of "instructions that direct the operation of hardware"; HTML is structured data, not code.

    Anyway, my point in replying to the OP is that even the silliest static website (let alone some Javacript-based client) would not work without the dozens of *native* (or Java-based servers, whatever) software components that are required to realize it in your web browser on your screen.

  58. Re:don't we know it by Dahamma · · Score: 1

    It's not Java-based, obviously, but it's origins *were* definitely as a scripting language. It was basically designed to automate the creation of HTML documents/fragments on the client by embedding interpreted code. Now, of course, it does a lot more than would be described strictly as a "scripting language", but colloquially most people now equate dynamic interpreted languages with scripting, anyway...

  59. Re:don't we know it by Anonymous Coward · · Score: 0

    The way I look at it is the Web is a platform. Your front-end code and markup are just as important to your application as if you were coding to X11, to Cocoa, to Win32 or to NCURSES. The logic is still the important part, and it can be implemented on the front end, the back end, or a combination of the two. That makes it inherently more complex than a monolithic application, so programmers who dismiss web scripting as "not real programming" should actually TRY it before looking down their nose at it.

    You think it's easy to deploy an accessible, localized, dynamic web application that runs on the desktop and mobile devices flawlessly? It's not, it's quite difficult!

  60. Re:don't we know it by Anonymous Coward · · Score: 0

    A "scripting" language is just a programming language targeting applications instead of the OS or bare metal.

    JavaScript was originally intended only for the browser, yes, but Brendan Eich had big ideas about it. He wanted to use Scheme, but management insisted that the language "look like Java."

    https://brendaneich.com/2008/04/popularity/