Slashdot Mirror


How Converting A C++ Game to JavaScript Gave Us WebAssembly (ieee.org)

Slashdot reader Beeftopia shares "a detailed history of WebAssembly...from one of the developers." IEEE Spectrum reports that "Like a lot of stories about tech innovation, this one started with video games." [Mozilla's Alon Zakai] wanted to take a game he had helped write in C++ and convert it to JavaScript code that would run well on the Web. This was in 2010, and back then, converting C++ to JavaScript was unthinkable... so he started working to adapt an open-source tool that could translate C++ code into JavaScript automatically. He called his project Emscripten... we were able to formalize the permitted JavaScript patterns, to make the contract between Emscripten and the browser completely clear. We named the resulting subset of JavaScript asm.js... I would optimize the JavaScript engine in Firefox to run the resulting code even faster...

This brings us to the present... Emscripten can take code written in C++ and convert it directly into WebAssembly. And there will be ways in time to run other languages as well, including Rust, Lua, Python, Java, and C#. With WebAssembly, multimillion-line code bases can now load in a few seconds and then run at 80 percent of the speed of native programs. And both load time and execution speed are expected to improve as the browser engines that run the code are made better.

They'd started with a C++ game because "If we could make games run well on the Web, other computationally intensive applications would soon follow."

The article -- by Mozilla software engineer Luke Wagner -- remembers that the name Emscripten was a "a mash-up of 'script' from JavaScript and 'embiggen' from the TV show The Simpsons."

74 of 139 comments (clear)

  1. I see the problem. by Anonymous Coward · · Score: 2, Insightful

    With WebAssembly, multimillion-line code bases can now load in a few seconds and then run at 80 percent of the speed of native programs.

    You appear to believe that is a good thing, in a web browser.

    1. Re:I see the problem. by Gavagai80 · · Score: 4, Insightful

      It is a good thing, for a handful of uses, which you might run into once a year. Unfortunately the other 99.99999% of the time it'll be used to create monstrosities which every website will shove down your throat.

      --
      This space intentionally left blank
    2. Re:I see the problem. by Anne+Thwacks · · Score: 1
      who the fuck plays games in the web browser.

      The extremely gullible - ie the target most marketeers would give their eye-teeth for

      --
      Sent from my ASR33 using ASCII
    3. Re:I see the problem. by serviscope_minor · · Score: 1

      The extremely gullible - ie the target most marketeers would give their eye-teeth for

      That doesn't make any sense.

      People who want to play a game that happens to be written for a browser play games in a broswer. It's a portable platform for better or worse which provides graphics, sound and keyboard input.

      i.e. it provides far more than the minimum needed for videogames.

      And some people write games for it just because the can and those ones tend to be pretty good.

      --
      SJW n. One who posts facts.
    4. Re:I see the problem. by jeremyp · · Score: 1

      If only computer languages could be used for something other than games. Oh, wait, they can.

      The fact that this makes it possible to use languages other than Javascript in the browser should be a cause for rejoicing.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  2. Sounds like a dumb ass by Snotnose · · Score: 4, Insightful

    if you are halfway competent in C/C++ you can see at a glance what a steaming pile Javascript is. Especially the 2010 version of Javascript.

    I don't like C++ for various reasons, but the only language in a good 40 years of programming I've learned to hate is Javascript.

    1. Re:Sounds like a dumb ass by PolygamousRanchKid+ · · Score: 1

      So what's up next . . . ? Erlang . . . ? There's still probably a pretty big pile of FOTRAN waiting around to be WebAssembled.

      Hey, and what about all that IBM 360 mainframe code that's been running since the 60's . . . ? Although, IBM probably has that code wrapped up in some legal shackles, so you can't do anything with it, except run it on a newer mainframe.

      Maybe we could start WebAssembling JavaScript code . . . ?

      --
      Schroedinger's Brexit: The UK is both in and out of the EU at the same time!
    2. Re:Sounds like a dumb ass by Anonymous Coward · · Score: 2, Interesting

      This "dumb ass" basically did what Google's NaCl engineers couldn't do, and helped find an agreeable migration path for web browsers to alter their existing VMs to support other languages. Thanks to him, contrarian fogeys may finally be able to shut the fuck up about JS in a few years. And I consider that a MAJOR win for everyone's sanity.

    3. Re:Sounds like a dumb ass by GuB-42 · · Score: 1

      He probably talked about the language itself, not the way it is used.
      JS is used for more than just webpages, even if it is, by far, its most common use. And ads and tracking are not only JS. On Android, it's Java, on iOS, it is Objective C or Swift.

    4. Re:Sounds like a dumb ass by Anonymous Coward · · Score: 4, Interesting

      Wow, modern /.ers really like to dump on people doing fun projects, never mind completely missing the point of the article. Did you even read TFS before making up your knee-jerk response?

    5. Re:Sounds like a dumb ass by Snotnose · · Score: 5, Funny

      I've got some C++ on a microcontroller that detects kids on my lawn and does the yelling for me. Had I written it in Javascript it would activate twice as often for no good reason, and miss real issues 50% of the time.

    6. Re:Sounds like a dumb ass by Billly+Gates · · Score: 1

      Woosh

      Let's ignore software distribution, access rights to your own computer (if this is a school or work PC), phones, tablets, other platforms, etc.

      If C++ was all in why don't we see these win32 apps on Linux or MacOSX if it was so easy and portable?

    7. Re:Sounds like a dumb ass by Billly+Gates · · Score: 1

      Erlang man is what all the cool kids use now PYSCHO BITCH

    8. Re:Sounds like a dumb ass by epyT-R · · Score: 1

      Unless of course it's the article that positions opinion as fact...eg 99% of the political articles posted here.

    9. Re:Sounds like a dumb ass by epyT-R · · Score: 1

      bookmarks? Sure beats wading through the mountains of pointless clickfests modern 'UX' designed sites have brought us.

      Reductionist? Nah, the problem is the bloat inherent in needless expansionism. Now we have slow, overwrought versions of applications that were already been-there-done-that in 1995, except now they're on a remote site that can change/disappear tomorrow, is loaded with ads/malware, and we get to pay 'subscription' fees for this wonderful 'convenience.'

       

    10. Re: Sounds like a dumb ass by Anne+Thwacks · · Score: 1
      so why would anyone do it when they have better things to do with their time?

      They don't - that is why the need to make the code run 20% slower!

      --
      Sent from my ASR33 using ASCII
    11. Re:Sounds like a dumb ass by Anonymous Coward · · Score: 1

      But it's so easy with Javascript if you use jQuery.

      $('kids').on('myLawn').yell("Get off!")

    12. Re:Sounds like a dumb ass by Anonymous Coward · · Score: 1

      argh, come on man, CALLBACKS!
      var kids_on_lawn=function(o,c){
        if(o.onLawn===true){
          c(null,'GET OFF MY LAWN');
        }else{ c(null,true); }
      };

      you can also do it asynchronously to take advantage of modern multi core CPU's

      var yell=function(o,c){ alert('get off my lawn '+o.name); if(c){c(null,true);}else{return true;} };
      var kids=['andy','jane','tod'];
      var operations=[];
      kids.forEach(function(name){ operations.push(async.apply(yell,{name:name})); });
      async.parallel(operations,function(err,res){});

    13. Re:Sounds like a dumb ass by angel'o'sphere · · Score: 1

      But it would yell in a very deep monster voice!

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    14. Re: Sounds like a dumb ass by Zero__Kelvin · · Score: 1

      It's all fun and games until someone gets hurt. If someone had done this and just showed it off on their blog it would be a "fun project", but as it stands it has affected us all, so we have every right to criticize it if we don't like the impact it is having.

      --
      Guns don't kill people; Physics kills people! - John Lithgow as Dick Solomon on Third Rock From The Sun
    15. Re:Sounds like a dumb ass by gbjbaanb · · Score: 1

      surely
      $(""#my street" house[lawn]").on("change", ".kids", function() { yell ("get off my lawn") ) });

      (so that's in the area of my street identified, the lawn attribute as part of the house element has an event handler attached that looks for changes to it from items of class "kids" and calls a function to do some yelling. Frankly, its starting to make perl look sane.

      and the whole thing has to be placed well away from the lawn, in order to use security measures like content security policy that prevents inline js from being modified and so the code is totally separate from the markup UI (which might be a good thing) except that the code is now totally distant from the UI so if you try to debug someone else's code, you're in a world of "where did that come from?" guesswork. Awesome, and don;t try to debug it because you'll only go down the rabbit hole that is jQuery to find where it thinks the JS event is attached from, and won't easily tell you where the frigging handler is to debug.

    16. Re:Sounds like a dumb ass by brantondaveperson · · Score: 1

      I couldn't disagree more. Javascript is an excellent language, elegant and simple, and a joy to write code in. Building UIs in HTML and CSS is a bit of a pain, and websites that use excessive javascript where none might be necessary are certainly annoying, but neither of those things are anything to do with the language itself.

      It's quite different to C++ obviously, but differences in languages encourage you to think differently about problems, which is normally a good thing. WebAssembly, on the other hand, seems to be re-inventing various things, and re-attacking already solved problems, such as how to build a simple and fast VM (see Lua's VM, for instance).

    17. Re:Sounds like a dumb ass by EETech1 · · Score: 1

      10 PRINT "GET OFF MY LAWN!"
      20 GOTO 10

      stupid lameness filter

  3. Re:converted by Njorthbiatr · · Score: 1

    The... Web?

  4. Re:My new WebAssembly project by RightwingNutjob · · Score: 1

    No systemd joke?

  5. Re:My new WebAssembly project by Megol · · Score: 1

    Great, that way you'd be able to run Linux!

  6. And this is how JavaScript dies by DeplorableCodeMonkey · · Score: 4, Insightful

    And there will be ways in time to run other languages as well, including Rust, Lua, Python, Java, and C#

    It's only a matter of time before TypeScript skips JavaScript and goes straight to WebAssembly. When Python and Ruby can cleanly target WebAssembly and the DOM, it's game over for JavaScript. What'll happen is quite simple. The people who are decent and kinda like JavaScript will jump to TypeScript. Everyone else will write code in something like Python or Ruby. In fact, I'll say right now that I expect that Facebook will rewrite React and GraphQL in TypeScript or one of those languages within no more than a few years of WebAssembly being supported in all browsers.

    1. Re:And this is how JavaScript dies by Snotnose · · Score: 1

      Pray pray pray.

      I think you're wrong.

      pray pray pray pray pray pray

      Javescript/Ecmascript (giving it a real name, a spec, and a couple books doesn't make it better) really needs to die.

    2. Re:And this is how JavaScript dies by h33t+l4x0r · · Score: 1

      There's no need for that. You can write it in any version of javascript you want and transpile it to any other version when you deploy.

    3. Re:And this is how JavaScript dies by evileeyore · · Score: 1

      Sooooo you are flaming something simply because you never use it? why would anyone ever try to write a device drive in JS? Thats like trying to ask someone to screw in a screw with a hammer. Use the language that most fits the job at hand. Nothing about this post is advocating that JS be used for everything.. its a tool designed for a specific purpose.

    4. Re:And this is how JavaScript dies by evileeyore · · Score: 1

      Redux isn't facebook's but yes :)

  7. Re:My new WebAssembly project by 93+Escort+Wagon · · Score: 2, Funny

    Pottering has stated that systemd’s web browser won’t be ready until mid-2018 at the earliest.

    --
    #DeleteChrome
  8. Re:Incredible by theweatherelectric · · Score: 1

    what an achievement

    It is. It's ideal for running emulators for projects like the Internet Archive's MS-DOS software library or their console video game collection.

  9. How hard can this be? by Blackeneth · · Score: 5, Funny

    JavaScript only has 6 commands:

            create_message_box_subscribe_to_my_newsetter()
            create_message_box_take_our_survey()
            create_message_box_our_cookie_policy()
            create_message_box_allow_us_to_send_notifications()
            create_message_box_behind_browser_advertisement()
            create_message_box_behind_browser_clickbait()

    --
    -- Knowledge is power. -- Francis Bacon
    1. Re:How hard can this be? by jeremyp · · Score: 1

      You forgot

              create_message_box_use_your_location()

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  10. People who see the web as documents by tepples · · Score: 5, Informative

    You failed to address the elephant in the room: Javascript is the language of the web browser platform.

    I think the idea is that a lot of people who regularly post comments on Slashdot and SoylentNews don't want the web browser to be an application platform. They see the web as documents, not applications. They point out that much is achievable through link navigation, form submission, and CSS, such as a script-free version of the "Fast Good Cheap" 2-of-3 checkbox demo. If they wanted an application more sophisticated than that, they would download its source code, compile it, and install it.

    1. Re:People who see the web as documents by roca · · Score: 1

      Having an application platform that isn't controlled by a single vendor, has no gatekeeper, and can run on any device --- and actually has a huge number of apps --- is incredibly important. The Web is that.

      People who don't want the web browser to be an application platform are welcome to disable Javascript in their browser. I'm happy to leave it on.

    2. Re: People who see the web as documents by c6gunner · · Score: 1

      Having an application platform that isn't controlled by a single vendor, has no gatekeeper, and can run on any device --- and actually has a huge number of apps --- is incredibly important. The Web is that.

      Um, yeah, the WEB is that. The web is not your browser.

      Applications run server side and the output displays in your browser. There's absolutely no good reason to be writing the goddamn application to actually execute in your browser.

    3. Re:People who see the web as documents by religionofpeas · · Score: 2

      That script free version is ugly and slow, even for a trivial example.

    4. Re: People who see the web as documents by religionofpeas · · Score: 1

      There's absolutely no good reason to be writing the goddamn application to actually execute in your browser.

      Yes there is. It's much more efficient.

    5. Re: People who see the web as documents by c6gunner · · Score: 1

      JavaScript.

      Efficient.

      Pick one.

    6. Re: People who see the web as documents by angel'o'sphere · · Score: 1

      While I agree that there is to much JS horrorr in modern browsers, there are plenty of reasons to have part of the logic as JS in the browser.
      One is scalability. Keep in mind the 'power of JS' with libraries like jquerry, reactJS etc. come from the fact that browser vendors could not agree on standards. Erm ... could not agree to implement and adhere to standards.
      As soon as you give someone a tool, like a 'nice JS library' he has it easier to 'abuse' the tool than to learn the underlying principles of the domain.
      Well, I only use JS forr real programming, controlling Eclise, the debugger, downloading code for tests on hardware etc.
      I avoid web programming like the plague, unless it is done in GWT (browser heavy) or Vaadin (back end heavy). The programming model of Vaadin, I really like, though.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    7. Re: People who see the web as documents by c6gunner · · Score: 1

      Alright, I was over generalising; I HAVE done web development, and yes, there are times when (properly done) JS is useful and actually adds value either in terms of user experience or efficiency.

      However, I also run NoScript in Firefox because the overwhelming majority of JS code out there adds nothing but bloat and constant tracking. Unfortunately, unlike the sites which I developed, many modern sites end up being unusuable or severely crippled without JavaScript enabled, which is a constant source of annoyance for me.

      I guess the tl;dr version of that is that JavaScript in the browser is a sometimes useful tool which has caused far more harm than good. At this point I would gladly give up the little utility it provides in order to get rid of all the crap that comes with it.

    8. Re: People who see the web as documents by tepples · · Score: 1

      Applications run server side and the output displays in your browser. There's absolutely no good reason to be writing the goddamn application to actually execute in your browser.

      Running part of an application on the client allows for three things:

      Drag as an input Script-free HTML has a control for coordinate input, namely the ismap attribute of the <img> element. But it takes only clicks, not drags, making it unwieldy to (say) draw a curve on an image. Immediate validation of input without repeated full page reloads Reloads are costly in both time and data transfer charges imposed by the ISP. In the example of a script-free drawing application, every time you click on the image to make a revision, it has to download the entire image anew, not just the changed portion. Nor is it fun to fill out an HTML form multiple screens long only to submit the thing and discover that you made some easily preventable inconsistent input several screens ago, such as a date in an unrecognizable format, start and end dates out of order, or two passwords that do not match. Real-time communication with other users of an application Script-free HTML makes it unwieldy to (say) wait for new messages sent by other users of a chat room and display them once they arrive or to display things drawn by other users of a collaborative whiteboard as they draw them.

      Or would these three things be grounds for requiring each user to download the application, compile it, and install it, if it's even ported to the operating system of the user's device?

    9. Re:People who see the web as documents by tepples · · Score: 1

      A patch to its CSS to make it less ugly is welcome.

    10. Re: People who see the web as documents by tepples · · Score: 1

      JavaScript less runtime-efficient than writing six C++14 apps, one for each platform (Win32, UWP, macOS, X11/Linux, iOS, Android). But it's more programmer time-efficient, and it's more efficient than requiring full page reloads of the web IRC gateway every 15 seconds in case someone in an IRC channel typed a new message.

    11. Re: People who see the web as documents by angel'o'sphere · · Score: 1

      Well,
      I'm not a fan of JS in the browser.
      I'm actually not a fan of web apps either. I mean, web sites that try to behave like an app/program.

      I think this is more a 'how should the web work' question than a JS question.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    12. Re: People who see the web as documents by tepples · · Score: 1

      Would you rather have a web app or a Mac-only app?

      Or if your primary computer is a Mac:
      Would you rather have a web app or a Windows-only app?

    13. Re: People who see the web as documents by evileeyore · · Score: 1

      I mean you guys can flame back and forth all you want. But javascript is never going anywhere. Not until web browsers are a thing of the past... you can love it or hate it but to call someone who does brilliant things on one platform a retard simply because he is on said platform is about the most naive comment in the thread....

    14. Re: People who see the web as documents by evileeyore · · Score: 1

      Your comment is correct, but in this context is is completely off... This like compare apples to satellites, when having a conversation about seahorses. Of course i can make an application that spits output to the a web browser, but this requires network activity, (literally the most inefficeint least reliable thing in coding now that > 60% of all traffic is coming over mobiel networks). So you can't tell me that offloading 95% of those "web requests" for silly things that complex applications need to perform, ont a javascript based app, that now only has to send 1 in 20 requests to your server for display calculation is less efficient. Don't flame just to flame friend :)

    15. Re: People who see the web as documents by angel'o'sphere · · Score: 1

      I avoid using web apps.
      And I don't really develop web apps.

      All desktop apps I develop are in Java/Groovy/Scala ... so I don't care.

      'Web technology' as in HTML5/CSS etc. makes sense for cross platform mobile development.

      I don't want a web site as an app ... the only thing that comes close to it that I'm using is FB.

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    16. Re: People who see the web as documents by tepples · · Score: 1

      If the developer of a particular application has the budget to make it for only one target platform, the dichotomy is true. And the web with client-side script has greater user base reach than any single native desktop platform.

    17. Re: People who see the web as documents by tepples · · Score: 1

      It's only true if doing a cross-platform release will cost more than doing a web-based app, and I don't see any obvious reason for that to be the case 100% of the time.

      Anti-script hardliners believe it to be the case 0% of the time, which I imagine is even less likely to be true than 100%.

      Allow me to begin the cost analysis:
      A web-based application requires a domain (with renewals per year) and a (free) domain-validated TLS certificate, which are less expensive than a set of organization-validated code signing certificates, one for each platform, and renewals per platform per year. Hosting of an applcation's online component is a wash between web and native.

  11. Re: Incredible by tepples · · Score: 1

    The lack of indication of tone of voice in text makes it unreliable for a reader to distinguish deadpan sarcasm from sincerity.

  12. Real languages do pointer arithmetic by aberglas · · Score: 1

    Until WebAssembly can do that it is rubbish.

    1. Re:Real languages do pointer arithmetic by Hal_Porter · · Score: 1

      You can take code with pointers and compile it to WebAssembly

      https://stackoverflow.com/ques...

      Now you may start shouting "All of this is ungodly! All of you are impure!" upon reading this and chant the operator precedence mantra from The Bible until you calm down and you'd be totally justified in doing so. Still it works.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    2. Re:Real languages do pointer arithmetic by aberglas · · Score: 1

      Pointer arithmetic is adding numbers to pointers. It is why

      int x;...
      myOutput("The Answer is " + x)

      produces a core dump (if you are lucky). It is what makes C/++ what it is today.

      JavaScript is all about pointers, and also has closures, so that is not the issue. It I the unconstrained arithmetic.

      Incidentally, 30 years ago Lisp machines used a Lisp-ish assembler that looked a bit like this.

  13. What could possibly go wrong? by peppepz · · Score: 5, Insightful

    Am I alone in thinking that giving CPU-level access to our browser to ad networks, hackers, scammers, governments* from all around the world with no authentication and no accountability whatsoever** is a bad idea? Haven't we seen what happened in the past with Java and ActiveX***? Moreover, back then at least Java ran "safe" high-level bytecode, whereas this thing will give to honest programmers the joy of buffer-smashing into adjacent variables, and to dishonest programmers the power to mine bitcoins at nearly native speeds! And once the next hip web frameworks start relying on this technology, there's no way we'll be able to disable it if we want to access the Internet as it's intended.

    * in no particular order of undesirability.
    ** the same-origin policy helps but is not enough, we can't make a trust decision every time we click on a URL, especially now that browser authors have made it so difficult to even see what a link points to, or even understand whether something is a link in the first place. Also, web developers tend to include large amounts of third-party code that they do not inspect, and if such code comes in binary form even before they minify it, then they won't be able to audit that code even nominally.
    *** I'm not adding JavaScript to the list. See? I'm not an old person. I like new things!

    1. Re:What could possibly go wrong? by roca · · Score: 3, Insightful

      WebAssembly programs have access to exactly the same set of APIs that JS programs do. They just run some things faster. There is no change in security (except slightly more attack surface in the form of the WebAssembly compiler, and even that's minimized since browser WebAssembly implementations reuse existing JS compiler backends).

      WebAssembly is no more obfuscated than minified Javascript.

    2. Re:What could possibly go wrong? by Gravis+Zero · · Score: 1

      Am I alone in thinking that giving CPU-level access to our browser to ad networks, hackers, scammers, governments* from all around the world with no authentication and no accountability whatsoever** is a bad idea?

      Nope, you are just one of many people. The bad news is that this outcome was inevitable but the good news is that this isn't the final outcome. After a drawn out tug-of-war, a new incarnation of HTML will come to being and it will have limited scripted CSS events that cannot be abused. Ads as we know them will cease to exist and will instead be replaced by a crediting system which will effectively pay sites for content based on various metrics. Credit can be purchased or earned through various means (e.g. executing computational units). Naturally, it will be the company that organizes the credit system that will develop the dominate browser. "Content piracy" is going to be a thing but it's impact will continue to be minimal (despite the vocal objections of corporations).

      The world is changing but it's not entirely unpredictable. Prepare yourself for the ensuing tug-of-war that is about to go full scale.

      --
      Anons need not reply. Questions end with a question mark.
    3. Re:What could possibly go wrong? by peppepz · · Score: 2

      But JavaScript programs cannot smash a buffer and write into another variable, as is required by the C memory model, and JavaScript libraries are not distributed in minified form (before development).

    4. Re:What could possibly go wrong? by Ace17 · · Score: 1

      I think the comparison is unfair ; Javascript/asmjs/WASM can't address the host memory the way an ActiveX component could.
      It's easy for an ActiveX component to crash almost any host, simply access a NULL pointer from your code. Doing this from a Javascript/asmjs/WASM program is several orders of magnitude harder, and generally needs to be specially tailored for one specific version of one specific browser.

    5. Re:What could possibly go wrong? by peppepz · · Score: 1

      Java and ActionScript couldn't access the host memory, too, but that didn't prevent the Java plugin and Flash from becoming the preferred carriers for browser malware. And those ran type- and memory- safe languages, not C. In order to reach an awful lot of people, an exploit needn't work on every machine, it's enough for it to target the most commonly used platform. Given that the browser landscape has been converging towards a monoculture lately, this could become even easier than it was in the past.

    6. Re:What could possibly go wrong? by Ace17 · · Score: 1

      What you say makes sense ; but then, the issue comes from the browser monoculture (which allows exploit scaling). Or from the precompiled plugin monoculture, which applies to Java and Flash, who were only distributed as precompiled binaries.

      Exploits as well exist in almost any code that parses complex data coming from outside (loaders for PNG, JPG, HTML, WEBM...) ... why make a special case for WASM?

  14. WebAssembly and SIMD by Hal_Porter · · Score: 2

    It's kind of a hack, but it gets the job done. Basically you have types like float32x, int32x4 etc. There are methods to add and subtract them using non vector code but if the hardware supports them using vector instructions, those vector instructions get substituted for the non vector code.

    https://github.com/tc39/ecmasc...

    --
    echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    1. Re:WebAssembly and SIMD by abies · · Score: 1

      Is it implemented anywhere? From what I was able to quickly find, it is an _idea_ that somebody in future might be bothered by replacing it by true vector instructions, but nobody yet implemented it, so currently it will always fallback to polyfill. It would be great if you could point to changeset which implements it in natvely in one of major browsers.

    2. Re:WebAssembly and SIMD by Hal_Porter · · Score: 1

      They're working on it it Chromium

      https://bugs.chromium.org/p/v8...

      However this page

      https://peterjensen.github.io/...

      Complains that SIMD isn't implemented in Chrome 62, and unfortunately it's not implemented in Firefox 57 either.

      So the answer is probably no, not yet.

      Last time I used SIMD I used the Intel intrinsics in C++. Which are OK, but Visual Studio's C compiler didn't do a particularly good job at generating efficient assembler. Mind you, a vectorizable algorithm will still run faster using the intrinsics than not using them, and the compilers get better with each release. And of course if you use the intrinsics wrapped in a Float32xN class instead of hand rolled assembler it's pretty easy to support other SIMD instruction sets. E.g. 128 bit SSE to AVX512 you just need to fill in the operators with the appropriate intrinsic function and then tell your code to use Float32x16 instead of Float32x4. With hand rolled assembler you'd have to rewrite everything. So they do make sense. AVX512 has gather too -

      https://en.wikipedia.org/wiki/...

      And if you need to support NEON you can use the NEON intrinsics.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
  15. Re:My new WebAssembly project by angel'o'sphere · · Score: 1

    I think we have a linux running javascript based 'VM' in the browser since over ten years.

    --
    Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  16. Re:WebAssembly = Not ready for prime time? by narcc · · Score: 1

    It runs perfectly fine for me on an old budget laptop. Movement is smooth, with no stuttering or slowdowns. I expected it to be a total flop once I saw the Unity logo.

    I can only assume that you're trying to run this on your Kaypro II.

    Still, that demo is a pretty stupid choice. There are many more interesting demos that better showcase the capabilities of modern browsers. That this is what they selected tells me more about the website operators than it does about WebAssembly.

  17. Re:WebAssembly = Not ready for prime time? by Travelsonic · · Score: 1

    Runs fine on my end, though I'd imagine that there are aspects of Unity that would add at least a little overhead to the mix.

    --
    If you believe in privacy, and believe you have "nothing to hide" at the same time, you're a goddammed idiot
  18. No, it's STILL unthinkable by RogueWarrior65 · · Score: 1

    The word you should have used was "impossible" but even today it's unthinkable. I mean, key-rist, why the hell would anyone want to work in JavaScript? Blech.

  19. One problem I have with JavaScript games by OrangeTide · · Score: 1

    I suspect after several years the games, if unmaintained to the latest whiz-bang JS frameworks, will bitrot and newer browsers will cease supporting older javascript feature. I've seen this happen before when JavaScript was younger. And not much has been done to address the interface and feature stability of the language. We'll still be at the whims of the policies set by the top web browsers.

    Maybe a little game isn't worth having 20 years later. But there are plenty of cases where old C/C++ code is brought back to life. And where 10, 20 or even 30 year old binaries are successfully ran in an emulator or in a Win95-compatibilty box. We are not likely to see

    Back to the original topic, I think something like Emscripten (which I've used to run some C-based GUI libraries in a web browser). is very valuable for the long term use of a project. Writing things in an ISO standardized language that changes slowly every 10 years seems like a better play than an ECMA standardized language that changes significantly every year. I understand that JavaScript is still new and evolving, but we've had it in one form or another for over 20 years. At what point can I write a piece of software for the Web that will last? Perhaps never?

    --
    “Common sense is not so common.” — Voltaire
    1. Re:One problem I have with JavaScript games by theweatherelectric · · Score: 1

      I suspect after several years the games, if unmaintained to the latest whiz-bang JS frameworks, will bitrot and newer browsers will cease supporting older javascript feature.

      DHTML Lemmings still works and that was last updated in 2004. I'm using Firefox and DHTML Lemmings was released before Firefox was.

  20. Their candid honesty is quite refreshing by AlejandroTejadaC · · Score: 1

    Their frank opinion about JavaScript::::::: "When Mozilla began its games program, a lot of its engineers focused their efforts, naturally enough, on JavaScript performance. It was an intense and exciting time, with people using cutting-edge academic research and an array of optimization techniques from industry. With these, our team was able to speed up JavaScript so it could deliver something close to a native-software experience, the gold standard.......... The problem was that these performance gains weren’t consistent. Sometimes the code ran really fast, but sometimes it didn’t. The design of JavaScript made it difficult to determine when and where the slowdowns were occurring, and it was almost impossible to predict when they’d crop up."