Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 Internet speed test! ×
Firefox Mozilla Programming The Internet

Will WebAssembly Replace JavaScript? (medium.com) 235

On Tuesday Firefox 52 became the first browser to support WebAssembly, a new standard "to enable near-native performance for web applications" without a plug-in by pre-compiling code into low-level, machine-ready instructions. Mozilla engineer Lin Clark sees this as an inflection point where the speed of browser-based applications increases dramatically. An anonymous reader quotes David Bryant, the head of platform engineering at Mozilla. This new standard will enable amazing video games and high-performance web apps for things like computer-aided design, video and image editing, and scientific visualization... Over time, many existing productivity apps (e.g. email, social networks, word processing) and JavaScript frameworks will likely use WebAssembly to significantly reduce load times while simultaneously improving performance while running... developers can integrate WebAssembly libraries for CPU-intensive calculations (e.g. compression, face detection, physics) into existing web apps that use JavaScript for less intensive work... In some ways, WebAssembly changes what it means to be a web developer, as well as the fundamental abilities of the web.
Mozilla celebrated with a demo video of the high-resolution graphics of Zen Garden, and while right now WebAssembly supports compilation from C and C++ (plus some preliminary support for Rust), "We expect that, as WebAssembly continues to evolve, you'll also be able to use it with programming languages often used for mobile apps, like Java, Swift, and C#."
This discussion has been archived. No new comments can be posted.

Will WebAssembly Replace JavaScript?

Comments Filter:
  • No (Score:5, Informative)

    by Anonymous Coward on Saturday March 11, 2017 @04:45PM (#54019467)

    From the web assembly web page:

    Is WebAssembly trying to replace JavaScript?

    No! WebAssembly is designed to be a complement to, not replacement of, JavaScript. While WebAssembly will, over time, allow many languages to be compiled to the Web, JavaScript has an incredible amount of momentum and will remain the single, privileged (as described above) dynamic language of the Web....

    • Re:No (Score:4, Interesting)

      by JDG1980 ( 2438906 ) on Saturday March 11, 2017 @11:51PM (#54021003)

      No! WebAssembly is designed to be a complement to, not replacement of, JavaScript. While WebAssembly will, over time, allow many languages to be compiled to the Web, JavaScript has an incredible amount of momentum and will remain the single, privileged (as described above) dynamic language of the Web....

      That's disappointing. JavaScript is an absolutely terrible language, and it's insane that it has been the only choice for client-side Web scripting/programming up until now. Hopefully this is just diplomatic BS. Once WebAssembly is updated to support access to the DOM (the current version can't do that), then there is no good reason for anyone to use JavaScript for anything ever again.

    • by tgv ( 254536 )

      Imagine the people who write buggy Javascript writing C++. A recipe for disaster.

  • by slazzy ( 864185 ) on Saturday March 11, 2017 @04:46PM (#54019469) Homepage Journal
    Yeah!
  • The cloud (Score:5, Insightful)

    by Anonymous Coward on Saturday March 11, 2017 @04:46PM (#54019473)

    This new standard will enable amazing video games and high-performance web apps for things like computer-aided design, video and image editing, and scientific visualization...

    But I don't *WANT* to do that shit in a web browser. I want it to live on my local computer where companies can't charge me $5, $10, or $250 per month or I lose access to all my critical data.

    I'm still astonished that one of my clients is running a Linux mail server and it works perfectly for them. Their total cost over the ~8 years they've been running it has been about $1,000/year, and most of that is paying for us to add new users, create mailing list/groups, and remove fired employees.

    Their first year on the Exchange 358 cloud bullshit would have cost them approximately $15k in licensing.

    • Re: (Score:3, Funny)

      by Anonymous Coward

      It's cute that you're your small town IT guy, but real businesses where people deal every hour with more money than you make a year require professional software, and that's where the quality of advanced offerings from Microsoft shine.

      • Re: (Score:2, Funny)

        by Anonymous Coward

        You had me up until "Microsoft."

      • Re:The cloud (Score:5, Insightful)

        by Pinky's Brain ( 1158667 ) on Saturday March 11, 2017 @06:53PM (#54020019)

        Since small businesses make up most of the economy I hope we don't run out of small town IT guys.

        The professionals seem comparatively completely fucking useless.

        • by rtb61 ( 674572 )

          It seems the 'professional' plugging M$ cloud are just really, really lazy and greedy. Take the credit and the pay and blame M$ when it all blows up, which it inevitably will. The bigger your company the sillier you are to trust the cloud because it will fail, it absolutely guaranteed will fail and catastrophically so. Never ever forget, they will take short cuts to inflate profits, they will pry into what they store because it is literally worth billions in insider information, the cloud serves you web int

    • But I don't *WANT* to do that shit in a web browser. I want it to live on my local computer

      What's better: using a JavaScript or WebAssembly app in a web browser, or not being able to use an app at all because it's native but doesn't happen to have been ported to your device's operating system?

      • by epyT-R ( 613989 ) on Saturday March 11, 2017 @10:27PM (#54020731)

        What's better: using a JavaScript or WebAssembly app in a web browser and having it fuck up your workflow when it magically changes/disappears one day, or having to run a specific OS to run a native, local application that's there forever until you choose to abandon it?

    • by ledow ( 319597 )

      Or they could have just used a Google Apps account, got email with it, without needing to pay you to add users or groups, and paid - what? You don't say how many users but it wouldn't be much more.

      Or they could have just bought any domain, and got free webmail and an interface panel for hundreds of users fora couple of dollars a year.

      Just because your use-case can't imagine the use of such a thing doesn't mean it's not sensible.

      To me, $1000/year for a mail server is a piss-take.

      Sure, you can do it for not

      • by lucm ( 889690 )

        Or they could have just bought any domain, and got free webmail and an interface panel for hundreds of users fora couple of dollars a year.

        Spot on. For $4/month total (including a free domain) with Bluehost you can have unlimited mailboxes, plus a website, blog, ecommerce site, etc. Sure, you don't get the massive data centers that come with Google or Microsoft mail servers, or their flawless antispam, but it's an annual budget of under $50 for your email to be hosted and they've maintained fairly decent uptime for decades.

        And even at that rock-bottom price you still get something more reliable than an in-house solution.

    • I also like to save my work locally. I don't like to do everything via the cloud. Let's be specific about what that means:

      The cloud:
      The real work of the application is done on some company's servers. Your machine is only the UI.

      Web Assembly and asm.js (and C, C#, Swift etc):
      The application runs on your local computer. The whole thing is on your computer, not just the UI.

      Javascript is rather slow (thousands of times slower than C), so you don't do video editing in Javascript, Javascript sends your data off

      • The only required difference between the traditional applications you're accustomed to and Web Assembly applications is that Web Assembly applications don't have to be installed.

        I have gathered that many users of Slashdot actually want the barrier of installation because it protects a user from code that he hasn't explicitly chosen to run. Some even want the barrier of compilation because distributing source code to the public discourages underhanded behavior by putting a program's developer on notice that any third party could audit the code.

        Both do the work locally, and can save the work locally - even on a device with no network connection.

        I thought web applications were subject of a quota of 5 MB of local storage per origin. You aren't going to be able to fit a lot of video int

    • How would this technology stop that.
      We had Time computing where we paid for access to the mainframe.
      Then we had SaaS where we hosted the app remotely.
      Now we have cloud where the services are more distributed.

      Nothing is stopping you from installing your own web server and use these apps on your intranet. But most people don't like paying thousands of dollars for software anymore.

      • Nothing is stopping you from installing your own web server and use these apps on your intranet. But most people don't like paying thousands of dollars for software anymore.

        Nor do they like paying thousands of dollars over the course of several years for a subscription that allows access to what FSF calls "service as a software substitute" [gnu.org]. Just because it's on the web doesn't mean it's available without charge.

    • And what is their lost time in dealing with spam, inability to properly and effectively share calendars, etc.?

      Email is one thing where hosting makes sense. We had gmail for our company free for over a decade, and recently went "premium" to add a few features. Smartest business decision we made.

      On the other hand, Asterisk locally was arguably our second best IT decision. 10-year cost under $15k, compared to $65k for a comparable hosted solution.

      You have to understand when hosted solutions make sense, and w
    • Re:The cloud (Score:4, Interesting)

      by lucm ( 889690 ) on Saturday March 11, 2017 @08:53PM (#54020377)

      Their first year on the Exchange 358 cloud bullshit would have cost them approximately $15k in licensing.

      For a service similar to a Linux mail server, that means they have 250 users (Office365 = $5/mailbox). I don't know how fast you can drive to their office but if their Linux mail server crashes or gets stolen, that's 250 people with no email for as long as it takes for you to fix the problem.

      On the other end, if the office loses internet connection (which would also make a Linux server useless), those users can still access their Office365 email from their phone or home internet connection.

      Email is a commodity and it's a no-brainer to outsource it to a provider that benefits from economy of scale and state-of-the-art data centers staffed 24x7.

    • I want it to live on my local computer where companies can't charge me $5, $10, or $250 per month or I lose access to all my critical data.

      But they can already do this even if the app does live on your local computer. See: Adobe Creative Cloud.

  • But not in the near future: JavaScript is a very well established technology for web UIs!
    • by Richard_at_work ( 517087 ) <richardprice@nosPAm.gmail.com> on Saturday March 11, 2017 @05:13PM (#54019555)

      Meh, not so much - its the *default* language for clientside web interaction right now, and thats the *only* reason it has the establishment that it has.

      The only thing that would have to happen for Javascripts domination to be threatened is for multiple browsers supporting something better, and thats happening with WebAssembly. Once developers realise they can stick to their language of choice and cross compile to WebAssembly, thats pretty much game over for JS - think of all the reasons touted for using Node.js, just this time think about them being used against JS...

      I wouldnt be at all surprised to see a significant shift start to happen in the next 18 months.

      • Where I work, the run of the mill web developers basically know js and php. So if they drop js I know what they will use.

        • But at least they get to concentrate on one language, rather than splitting their valuable attention and time over multiple languages, all with their own foibles. Far far too many "full stack web devs" claim to know JS but actually know very little, and subsist on broken pockets of experience. Think of how many atrocities have been committed with JQuery plugins by "full stack web devs" who basically chain pre-existing stuff together.

      • by lysdexia ( 897 )
        God speed the day. If I have to use that horrible half-scheme NaN more time I'm going to undefined.
  • No (Score:3, Insightful)

    by thegarbz ( 1787294 ) on Saturday March 11, 2017 @05:15PM (#54019563)

    But a longer answer is: 99.999% of the Javascript out there is not slow but waiting on some server to send back content.

    Yeah if you're crazy enough create a image editor or a game that runs only in a webbrowser then maybe you would consider this. But no it won't replace Javascript.

    • But a longer answer is: 99.999% of the Javascript out there is not slow but waiting on some server to send back content.

      You'd be surprised at how much time the browser spends running ad exchanges' "real-time bidding" processes, collecting bids from a dozen different ad networks for each ad unit on a page just to eke out a larger fraction of a cent. On the weaker ARM or Atom CPUs of compact laptops, tablets, and smartphones, adtech scripts often cause the web content process to take a whole core for several seconds.

    • Yeah if you're crazy enough create a image editor or a game that runs only in a webbrowser then maybe you would consider this. But no it won't replace Javascript.

      I'm always amused that the "Flash haters" at Google/Chrome still insist that you run the YouTube video editor under Flash. Heck, I can barely get a WebM file from YouTube some days.

      Anyway, replacing Flash for use cases that aren't video streaming would be a welcome use of WebM. Possibly that's what they're waiting for and the reason they're still

  • Chrome too (Score:5, Informative)

    by campuscodi ( 4234297 ) on Saturday March 11, 2017 @05:19PM (#54019579)
    Google also officially added support for WebAssembly in Chrome 57, released 3 days ago, btw
    • by ledow ( 319597 )

      Yeah, but that EpicZenGarden demo doesn't work in Chrome.

      I get an error after about 2 minutes of downloading hundreds of megs: Uncaught TypeError: Cannot read property 'getParameter' of undefined

      Doesn't matter how good your demo is if it doesn't work on other software. The old "web browsers don't support standards the same way" problem strikes again.

      • The old "web browsers don't support standards the same way" problem strikes again.

        But it's still probably a lot less effort to port a web app from Chrome to Firefox or vice versa than to port, say, a macOS app using Cocoa to Windows.

      • by haruchai ( 17472 )

        Yeah, but that EpicZenGarden demo doesn't work in Chrome.

        And it sorta worked in my portable FF. All 4 CPU cores went to 100% when it was compiling WebAssembly, dropped to 85% while the demo was playing, which crashed after about 30 seconds - but only took out the 1 tab, did not kill the browser.

  • by gweihir ( 88907 ) on Saturday March 11, 2017 @05:22PM (#54019591)

    WebAssembly will primarily allow real coders to write applications that run in browsers. No JavaScript wannabees need to apply.

    • It's still going to be a few years. Right now, you can't even access the DOM from Webassembly.

      Eventually it will be in there, and eventually they will be adding hooks so garbage collected languages can run in WebAssembly, too. They're taking it slow though, because they don't want to make the world suffer by making it too miserable. CSS and HTML might be getting an overhaul too, but the whole process could go on until 2030. For right now, we still have to write web pages using lousy frameworks.
      • by gweihir ( 88907 )

        Aehm, why would languages with a GC not run in WebAssembly?

        • Right now WebAssembly doesn't have primitives that support it. You could hypothetically write your own garbage collector and port it over (so when people load your web page they also have to load a C# runtime or whatever), but I don't think anyone is going to do that since it would become outdated soon.
          • by gweihir ( 88907 )

            Ahem, that is not hypothetical at all but the way it is done? Languages with GC come with a GC adapted to their needs. GC is not something an execution platform supplies and it does not need to have "primitives" for it. In fact, I do not think such primitives exits in any assembler dialect, as memory management is a high-level function provided by the kernel and/or runtime library. A GC then sits on top of that. In particular, WebAssembly aims at very close to native performance, so having a GC implemented

            • In fact, I do not think such primitives exits in any assembler dialect,

              Well get ready, because you're going to see it in WebAssembly.

              GC is not something an execution platform supplies and it does not need to have "primitives" for it.

              WebAssembly is going to have it whether it needs it or not. That's the plan. In your confusion about the exact definition of assembly language, you seemed to have missed the point. Languages with GC are not likely to be ported to WebAssembly because in a few years, it will be much, much easier to port them.

              • by gweihir ( 88907 )

                That is complete nonsense. A GC needs to be custom-tailored for the language used. A GC primitive is not going to help for any language besides exactly the one it was designed for. Seriously, read up on what a GC is and how it works. It is not some function you can call that works the same everywhere.

                • Oooh, insults. I can do that too: you're an ignoramus, know nothing about WebAssembly except what I've told you, and most likely your knowledge of GC is almost as bad.
      • It's still going to be a few years. Right now, you can't even access the DOM from Webassembly.

        I can code in JS, assembly, C*, html*, and even I wouldn't want to access the DOM from WebAssembly. Put the tight CPU stuff in WA and keep the majority of the high-level code in JS or if some kind of miracle happens and Rust becomes a better web app platform, something like that (unless there's a miracle and perl6 becomes relevant). The extant JIT's should be fine for high-level code, and if the VM team wants to

      • Eventually it will be in there, and eventually they will be adding hooks so garbage collected languages can run in WebAssembly, too. ...

        And for how many years will they be fixing obvious vulnerabilities in the code? How long before the language has some semblance of security?

        • WebAssembly will likely never be more secure than Javascript is now, because the people who are implementing it are the same ones who implemented Javascript.
    • by Anonymous Coward on Saturday March 11, 2017 @07:50PM (#54020183)

      SO much this.

      The reason JS gets so much hate is not because the language itself, it's the horrific fucking developers that (ab)use it.
      Most of them abstract the damn language away under shit like jQuery that adds a metric fuckton of overhead to the language.

      It's not even amateur small-time devs either, it's huge ones too.
      So-called Enterprise-quality code, full of high-overhead code for very little functionality, said overhead only there to prevent IDIOTS from making mistakes.
      Google even do it. Youtube, Gmail, Maps, all slow as fuck now. Try run ANY of those on a machine from even 5 years ago, never mind 10. They are even slow on modern hardware for NO FUNCTIONAL REASON, just lazy developers writing high-overhead code for obfuscation / low-transmission cost reasons. (yet it would be far easier to compress your code and decompress it on client end, then run THAT, insanely faster too)
      The HTML5 video system is so slow it is funny, especially since most major browser vendors are pushing for its replacement as primary content source for video over Flash. The piece of shit spec has barely any support for hardware emulation on old or NEW hardware. The levels of inconsistency in HTML5 video is nuts. I've seen old machines handle it fine, yet something from past 2 years choke on it. It is a horrible, horrible spec not even remotely close to being complete.
      As much as I hate W3C for their monolithic nonsense of yesterdecade, they were 100% correct when they said HTML5 wouldn't be complete until 2020~. 100% correct indeed. The amount of syntactic sugar in that spec to cater to retards that refuse to learn the language is only going to make things even slower.

      It happens in loads of other languages as well.
      PHP another common one. The PHP community is horribly stupid as a collective. (including ITS own developers!)
      Python is another. Python suffers even more so because it is ridiculously high-overhead NATIVELY, it is horrendously slow. I have no idea why people can stand it. Even for prototyping it is bad. (more so because the syntax is horribly different from most languages)

      Idiots are ruining the programming community.
      They've made the entire industry horrible to live in.
      If you know anyone considering programming, tell them fucking no and get in to computer science instead. Or mechatronics or something else interesting. That one in particular will be a very good one since robotics is a hugely growing industry.
      Programming is a dying area. It's saturated with IDIOTS that are too lazy to learn languages, so ask "smarter" people on Stackoverflow or similar sites.
      There's literally summer courses in programming that teach people to ASK questions on stackoverflow! (fucking India)

  • If we can get rid of the current source code soup in web apps, that would be a good thing.

  • If it finally kills that damn Flash dead, I'm all for it.

    • I agree about removing Flash Player from the mainstream web. Almost everything modern has moved to HTML5 technologies. Classic animations and games, such as those found on Newgrounds, Dagobah, Albino Blacksheep, Homestar Runner, or Weebl's Stuff, can be run in a specialized browser in a virtual machine.

      But Flash is more than Flash Player. Without Flash, what timeline-based graphical tool do you use to author an SVG or Canvas animation? Typing the coordinates of each vertex of each keyframe into a text edito

  • So what's the principle difference between this and Java byte code?
    • The first difference I see is that wasm is not encumbered by Oracle's licensing restrictions. In addition, wasm is designed such that traditionally unmanaged languages like C++ can compile to it, whereas the JVM and CLR impose type system constraints that make it hard to define how to compile something like standard C++.

    • by ledow ( 319597 )

      This doesn't run as an NSAPI plugin.

  • Web Assembly is like the bytecode of Java. In the future, JavaScript will compile to it. As will other languages. The only question is whether languages other than JS can be distributed as source code and compiled to WebAssembly inside the browser.
  • Looks good to me (Score:5, Informative)

    by steveha ( 103154 ) on Saturday March 11, 2017 @06:17PM (#54019873) Homepage

    I read through the fine articles and even watched a couple of the videos. Overall this looks like a good idea to me.

    The basic idea: WebAssembly is an assembly language for a virtual machine, which is very easy to translate into native code. It was designed to be compact so it will download quickly; in particular they chose a stack-based virtual architecture so that an "ADD" instruction implicitly adds the top two numbers on the stack, so "ADD" and similar operations are always single bytecodes. Also, while JavaScript only has a single "number" type which is implicitly float, WebAssembly has multiple built-in native types including 64-bit integer.

    It should be no less secure, and no more secure, than JavaScript. However almost all the overhead of an interpreted language is gone: instead of just-in-time compilation, detecting "hot spots" and optimizing, and de-optimizing when assumptions are invalidated, all the browser has to do is translate the virtual machine code into native code and run it.

    For the initial release (i.e. right now) WebAssembly does not support garbage collection. This is a sensible decision given what it is and what it does, but they said they will look at giving it some GC abilities in future releases.

    I like the original idea that JavaScript would always be human-readable and people could learn by studying the code from the sites they visit. However, this idea is not really active now. It's common practice to run JavaScript code through a "minifier" that packs it to make it as small as possible so it will load quickly, and minified code isn't very friendly to read. There are tools available to somewhat beautify minified JS, but I'm certain that there will be tools to "decompile" WebAssembly and produce something sort-of readable. So while in this one area WebAssembly is not quite as nice as JavaScript, I don't think it's a significant thing, and it's not even remotely enough to make me oppose WebAssembly.

    Developers will be able to take existing code in languages like C, C++, etc. and compile them into this portable virtual machine language, and web browsers will be able to load and run them quickly. People will be able to write browser apps that run at near-native-speed and they will run on all the major web browsers and on whatever CPU you have (x86 and ARM for now). I don't really see a downside and I see lots of upside.

    • by Augusto ( 12068 )

      Innovative!!! It sounds like Java ... (or basically any other bytocode compiled language ...)

    • "ADD" instruction implicitly adds the top two numbers on the stack

      Maybe I should look at compiling Forth to WebAssembly.

      • by steveha ( 103154 )

        Maybe I should look at compiling Forth to WebAssembly.

        Should be possible. But I looked at some examples and it looks like they went for a LISP-like syntax rather than FORTH-like:

        https://rsms.me/wasm-intro [rsms.me]

        Also somewhere in the fine article or one of the videos, somebody said that the stack-oriented bytecodes would likely be translated into register-based native code for efficiency. But it seems like they should make a simple virtual machine that can directly execute the bytecodes, for debugging or whatever

  • by Blaskowicz ( 634489 ) on Saturday March 11, 2017 @07:05PM (#54020065)

    Obviously this will allow much faster "apps" but we all know what that means. Tons of "features" i.e. yet more bloat and "innovation" i.e. new version of shit that looks like it's for cell phones and runs 4x slower.
    Javascript engines got a lot faster a few years ago and all we got was a ton of garbage and google making their "Maps" excruciatingly slow unless you run brand new hardware. Also, javascript Doom got taken off the internet for copyright infrigement and all the games are on Android Google Play anyway.
    Devs, stop masturbating to your i5/i7 laptop and your Samsung S7 and don't forget to also test on sensible specs like 1GHz and unsupported AMD graphics. People aren't interested into upgrading every other year to a computer that can run Crysis just to do the same things we did back in 2005 or so.

  • It's beyond me why people confuse operating systems with web-browsers. Being able to run code from somewhere on the net and executing it locally (either sandboxed in a virtual machine or directly on the hardware) is something every major operating system has been able to do for many years.

    And there have been good reasons why operating systems got safety mechanisms to not overly trust code from somewhere on the net.

    Having a browser instead of an operating system do that just means to exchange the experti
    • by tepples ( 727027 )

      Being able to run code from somewhere on the net and executing it locally (either sandboxed in a virtual machine or directly on the hardware) is something every major operating system has been able to do for many years.

      But can you run the same code in all five major end-user operating systems (Windows, macOS, GNU/Linux, iOS, and Android)? Or do you have to beg an application's developer to recompile it for your platform?

    • But the operating systems don't always do a great job. For example, linux distros require software to keep being updated and maintained forever so that it stays compatible with what's reasonably current. So, it seems like we'll be stuck forever with Gimp, Inkscape, Blender, Audacity, Libre Office etc., not that there's necessarily anything wrong with these but there's not much else at all. Little new software (e.g., deadbeef music player) compared to a decade ago, besides new versions of toolkits and librar

  • The ability to implement a web browser within WebAssembly is going to change the Internet forever. No more downloading and installing browsers. This is so exciting.

  • I worked on this development for over two years, since before the WebAssembly CG was created, and have been demonstrating some of the best performance from asm.js and wasm style code, and I believe the process and outcome has been somewhat of a failure. There are some positive outcomes, such a set of operators, but this seems just a small step from asm.js (adding some 64-bit operators etc).

    At the end of this process it became clear that seeking a single virtual machine or encoding was not a good outcome, be

  • by CnlPepper ( 140772 ) on Sunday March 12, 2017 @09:04AM (#54022257)

    I'm just going to leave this here: https://en.wikipedia.org/wiki/... [wikipedia.org]

    If you want native speeds, use the OS. This is doing nothing more than complicating development - now rather than just OS differences you have every possible permutation of OS and browser to deal with when bug fixing.

When it is incorrect, it is, at least *authoritatively* incorrect. -- Hitchiker's Guide To The Galaxy

Working...