Slashdot Mirror


The Next Browser Scripting Language Is — C?

mad.frog writes to tell us that in a recent talk by Adobe's Scott Petersen he demonstrated a new toolchain that he has been working on (and soon to be open-sourced) that allows C code to be run by the Tamarin virtual machine. "The toolchain includes lots of other details, such as a custom POSIX system call API and a C multimedia library that provides access to Flash. And there's some things that Petersen had to add to Tamarin, such as a native byte array that maps directly to RAM, thereby allowing the VM's "emulation" of memory to have only a minor overhead over the real thing. The end result is the ability to run a wide variety of existing C code in Flash at acceptable speeds. Petersen demonstrated a version of Quake running in a Flash app, as well as a C-based Nintendo emulator running Zelda; both were eminently playable, and included sound effects and music."

40 of 375 comments (clear)

  1. Browser-based OS by rustalot42684 · · Score: 4, Funny

    Now we can finally get this "web operating system" thing I've heard so much about...

    1. Re:Browser-based OS by Hatta · · Score: 5, Insightful

      Well this just underscores how silly the whole web-application thing is. An application running on a browser is a silly idea for the same reason an OS running on a browser is. We already have operating systems to run programs on. Give us native programs, not some horrid mishmash of technologies.

      --
      Give me Classic Slashdot or give me death!
    2. Re:Browser-based OS by Yold · · Score: 4, Insightful

      What the hell are you talking about? Web applications have some really good uses in the real-world (read business world). Instead of updating every computer in the office with a new version of some data management app, it is deployed once.

      Native programs are optimized for speed, Web Applications are optimized for Rapid Application Development. Remember visual basic? Thats what web apps do nowadays, and trust me, its better.

      As for "your horrid mishmash of technologies" statement, I agree that AJAX is overused, but believe me it is very nice to be able to do stuff on the server side (think form validation), and then not have to redo on the client-side in javascript.

    3. Re:Browser-based OS by Anonymous Coward · · Score: 4, Funny

      You need an operating system to run programs? Bah! Real programmers aren't afraid of programming directly to the hardware.

      This whole operating system fad won't last. Who wants to waste so many resources just to simplify development and portability? If we don't stop this operating system fad quickly, the next thing you'll see is people developing virtual machines so that girly programmers won't have to have to test their applications across various platforms. And then they'll start integrating these virtual machines into normal applications! What are they thinking? That memory and processor speeds are growing exponentially?

    4. Re:Browser-based OS by Whatanut · · Score: 5, Funny

      If you run a browser based OS... and install a browser in it. And then use that to run a browser based OS, why... we could have infinite amounts of computing power! Or space time will tear itself apart. Either way, I'm making popcorn.

      --

      yvan eht nioj
    5. Re:Browser-based OS by bestinshow · · Score: 5, Insightful

      Not really. I do agree that native applications are nicer than web applications, especially if you compare, e.g., Google Docs to Office, or even WordPad.

      However what we have discovered is that (1) web applications are easier to write, and (2) it's nice having a consistent platform to develop to, even if that platform is mildly ridiculous (HTML + CSS + JavaScript + Browser-Workarounds + JavaScript canvas thing). Getting stuff to display and layout on this platform is easy, and simple to prettify, far easier than most native platforms have been in the past. There are also a dozen different ways to write the server side of things, and I think for many developers it is nice to be forced to split up the client interface from the meat of the system.

      Of course, things are going too far. What should be happening is the simplification of native application programming, with a common platform, etc, without the overhead of having to run a Javascript or HTML rendering engine, and native full-speed canvases. I think that Apple is getting there, QT and KDE4 may be getting there but I haven't really looked into that platform. Java should have gotten there but early design mistakes (AWT, Swing) have killed that off, and SWT is a last-generation UI library. Maybe something like Fenggui on Java might help this platform, but I think Java's dead on the home desktop (and extremely alive and profitable on the server).

    6. Re:Browser-based OS by rustalot42684 · · Score: 4, Insightful

      Instead of updating every computer in the office with a new version of some data management app, it is deployed once.

      Or you could have a sensible package system which does updates (eg, one of the Linux package managers), or have the program itself do the updates (eg, Firefox). Your problem is solved.

      A commonly mentioned benefit of web apps is portability, but this isn't really true either because of the variety (and inconsistency) of web browsers. What I think is a better approach is something like the solution we see with Qt, where you write your program once, then compile it for different platforms, and it looks native every time. You get the speed and the portability and the UI consistency and the tech support only needs to support one program.

      I agree with you, however, that web apps are the new Visual Basic. They're slow, crappy, and often insecure.

    7. Re:Browser-based OS by Yold · · Score: 5, Insightful

      #1, Yes, it is hard to push out an application to every University computer when you are at one w/ 50,000 students.

      #2, see #1

      #3, everything is done on the server-side, and prior to AJAX, it was redone in Javascript on the clientside for a more responsive user interface. Now, both the client and server use the server-side procedure.

    8. Re:Browser-based OS by sjames · · Score: 4, Funny

      Sonny, back in the day we didn't need a machine to test our code. We ran it in our heads as we punched it into the cards. Sure, there were a few new guys who used pencil and paper to help them, but if they didn't shape up in a month or so, we ran them out of the industry.

      Now get off my lawn!

    9. Re:Browser-based OS by Hairy+Heron · · Score: 5, Informative

      especially when the proprietary part is very large and complex (eg Java)

      You're about 3 years out of date on calling Java proprietary, kiddo. In case you forgot, it's been GPLed for over a year now.

    10. Re:Browser-based OS by sconeu · · Score: 5, Funny

      So it's browsers all the way down?

      --
      General Relativity: Space-time tells matter where to go; Matter tells space-time what shape to be.
    11. Re:Browser-based OS by grasshoppa · · Score: 4, Insightful

      Or you could have a sensible package system which does updates (eg, one of the Linux package managers), or have the program itself do the updates (eg, Firefox). Your problem is solved.

      That certainly is a simplistic concept. Now, let's talk about largish environments. You know, where the user is running as a limited user, therefore the app can't update itself. Or where windows is required, so we can't use linux's update mechanisms.

      Or how about the simple logic that updating one app once is more likely to go smoothly than updating one application 100 times. Or a thousand. No matter how automated, problems crop up.

      Honestly, if you are going to argue the point, at least think about your arguments first.

      --
      Mod me down with all of your hatred and your journey towards the dark side will be complete!
    12. Re:Browser-based OS by jsebrech · · Score: 4, Insightful

      A commonly mentioned benefit of web apps is portability, but this isn't really true either because of the variety (and inconsistency) of web browsers. What I think is a better approach is something like the solution we see with Qt, where you write your program once, then compile it for different platforms, and it looks native every time.

      That still doesn't solve the deployment problem. You need rights on the local system to install that software. Why do you need those rights? Because native apps can interact in too many ways, and they can't be trusted, so rights are not automatically granted.

      The clever thing about the web platform, and what sets it apart from other platforms, is that the security model by default lets you run any app, even one you don't trust, on any system, without it causing major catastrophes.

      The web platform is building on a new concept: ubiquitous internet. The idea is that your applications and data live in the cloud, and are available to you on any device, anywhere, any time. Off-line support is only necessary as a short-term stopgap until the cloud is visible again (like the offline support of google docs).

      This is why the web makes sense: it just works. No installs, no administration, no lost data when your local machine fails, no shuttling different versions around on usb sticks. It's true that it's less powerful, but it doesn't matter because the ease of use gained from having the apps and the data "out there" will vastly outweigh the lack of capability for the majority of users.

  2. Meet the new boss by vivaoporto · · Score: 4, Funny

    Same as the old boss.

  3. And once we have C... by Anonymous Coward · · Score: 5, Funny

    We can write PHP! And then browser security will be top notch.

  4. what? by thermian · · Score: 5, Funny

    You mean my preferred language has just become cool?

    Ok, this is either great news or the world is about to end.

    I think I'll go stand in a doorway for an hour or two, just to be on the safe side.

    --
    A learning experience is one of those things that say, 'You know that thing you just did? Don't do that.' - D. Adams
    1. Re:what? by eviloverlordx · · Score: 5, Funny

      I heard that COBOL is next on the TODO list.

      --
      'Loose' is when your pants are three sizes too big. 'Lose' is when you misuse 'loose'.
    2. Re:what? by dgatwood · · Score: 4, Interesting

      I'd use C for everything if its string handling weren't so utterly broken. It makes sense from a pure performance, near-the-hardware perspective to handle strings the way it does, but what is desperately needed is POSIX standardization of stracat/stracpy. That one change would make it trivial to eliminate 99% of all buffer overflows in typical apps (and, ideally, kernel code)....

      char *stracpy(char *src) Returns a copy of a string in a newly allocated buffer large enough to hold the result. char *stracat(char *string1, char *string2 ...) Returns a newly allocated string that contains the concatenation of two or more strings.

      Sure, I could write my own, and pretty much everybody on the planet has done it at least once in their lives, but it seems ridiculous that such obvious operations require hand holding. Outside of embedded platforms where malloc is expensive, dynamically allocating a new buffer for concatenations should be the norm. For situations where performance takes a big hit because you can't afford to copy the source string every time, you could also add this API:

      strbuf_t strbufalloc(char *src [, size_t size_hint]) Returns a copy of a string in a newly allocated buffer large enough to hold the result. The optional second parameter size_hint allows you to specify a suggested size for the buffer. strbuf *strbufcat(strbuf_t string1, strbuf_t string2 ...) Returns a newly allocated string that contains the concatenation of two or more strings. The value of string1 must be a string buffer (strbuf_t). The value of string2 may be either a strbuf_t or char **.

      Wherein strbuf is opaquely defined as:

      struct strbuf_private {
      char *content; // null-terminated string
      size_t length;
      void *private_history_data;
      };

      struct strbuf;
      typedef struct strbuf *strbuf_t;

      and the routines automatically realloc the internal char * buffer as needed to grow the size to hold incoming content and likely future content based on historical data about prior operations on the structure, the algorithm for which would be an implementation detail outside the scope of the standard. That said, for the rare cases where a simple copy hurts performance badly enough for most folks to care, chances are your application knows its own growth policy better than the OS could guess anyway, so you probably should just roll your own buffer management code. The important bits to add to the standard are those first two functions (stracpy and stracat).

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

    3. Re:what? by naasking · · Score: 4, Informative

      See The Better String Library. Haven't used it myself, but it's supposedly very portable, high performance, and has good interoperability with normal null terminated C strings.

  5. Re:Sound and Music? by 2nd+Post! · · Score: 4, Informative

    Nope. SFX is generally event driven (hit a key, hear the sword swing) where music is not (enter an area and music plays continuously in the background).

    SFX requires timing, latency, and speed to be accurate. Music requires bandwidth and a minimum level of continuous CPU cycles.

    Both have different needs so you can have one without the other (when you are talking emulation).

  6. Where did they get the Zelda on PC? by Anonymous Coward · · Score: 4, Insightful

    Is that a pirate copy? Just curious...

    1. Re:Where did they get the Zelda on PC? by Rob+T+Firefly · · Score: 5, Funny

      It's a secret to everyone.

  7. am I the only one bored with the software world? by Anonymous Coward · · Score: 5, Insightful

    Everything's being constantly reinvented but no actual progress is being made. Oh look, the 100th toolkit to do exactly the same thing! Oh look, a new way of layering something old on something old on something old to give something new! Oh look, another silver bullet framework!

    Can anyone here remember the web of 10 years ago, for example? Content = text for reading + graphics for illustration. No bullcrap, just Google/Wikipedia style web sites to give me a simple navbar + content.

  8. But is it secure? by Animats · · Score: 4, Informative

    If the "byte array mapped to RAM" installed in Tamarin allows the code to store anywhere in the interpreter's space, that's a huge security hole. It can do anything the user process can do. If you're going to allow that, you may as well just load executable machine code directly, as with Active-X.

    Anyway, the article is a blog post that rehashes an interview from last year. The info in that article is better.

    1. Re:But is it secure? by ergo98 · · Score: 5, Insightful

      If the "byte array mapped to RAM" installed in Tamarin allows the code to store anywhere in the interpreter's space, that's a huge security hole. It can do anything the user process can do. If you're going to allow that, you may as well just load executable machine code directly, as with Active-X.

      You should email them and tell them about this! Surely they haven't though of such a thing!

      Sarcasm aside (sorry, I couldn't help myself), I suspect the VM needs to actually hand you a block of memory, and on accesses it validates that it is within the VM allocated range. Anything less would be silly, however such a thing would provide a huge win (I've tried to do image editing in pure managed code, and then found a massive performance win switching it over to P/Invoke native code).

  9. Re:Right... by Nyall · · Score: 5, Insightful

    primary? ummm... I thought the primary point of layers is so that you can do a lot with only a few simple function calls

    --
    http://en.wikipedia.org/wiki/Jury_nullification
  10. Ah, the Memories... by Tickenest · · Score: 5, Insightful
    Petersen demonstrated a version of Quake running in a Flash app, as well as a C-based Nintendo emulator running Zelda; both were eminently playable, and included sound effects and music.

    So Flash can simulating computing as it was back in 1998? Super....

    --
    This is the NFL, which stands for "Not For Long" if you keep making those bulls*** calls.
  11. Re:Right... by Chris+Mattern · · Score: 5, Funny

    The circle is now complete. When C left Unix it was but the back-end. Now, it is the API.

  12. Adobe Systems != Open Source by mpapet · · Score: 5, Informative

    The last time I checked, Adobe Systems is about as hostile to open source as possible. They are the seldom acknowledged masters of the "first hit on the crack pipe is free" scheme.

    http://labs.adobe.com/technologies/eula/air.html

    Multiple helper libraries licensed under the MPL doesn't change the fact they are promoting another information silo.

    --
    http://www.maxineudall.com/2010/02/should-economists-be-sued-for-malpractice.html
  13. Re:Right... by camperdave · · Score: 4, Insightful

    How so? That's like saying sushi bars are there to try to get away from fishing.

    Well, it must work because I've never had to catch a fish to eat sushi.

    --
    When our name is on the back of your car, we're behind you all the way!
  14. Re:Sounds fantastic by UnknowingFool · · Score: 4, Funny

    I feel a great disturbance in the force as if a million admins suddenly screamed in terror . . .

    --
    Well, there's spam egg sausage and spam, that's not got much spam in it.
  15. Perl is Interpreted C by Doc+Ruby · · Score: 4, Interesting

    There's very little if any C code that can't be written basically the same for Perl to interpret it basically the same way. The exception is direct memory access, but there are ways. And besides, I'd rather access memory through an API that really manages it, like making it hard to unexpectedly overflow buffers or grant access to unauthorized other users.

    I'd love a Perl interpreter embedded in my browser. I'd love to have a Perl API directly to the browser app and the browser documents' DOM. I'd love to have a "Perl commandline" that returns text like usual, or that works on remote data by URL, or that returns icons or other data displayable in the browser.

    Javascript is a pain in the ass. I'd rather have a Perl engine, and all the Perl modules and scripts, to run against my browser the way I usually run against my terminal window.

    --

    --
    make install -not war

  16. Guitar Hero and Lumines by tepples · · Score: 4, Informative

    Nope. SFX is generally event driven (hit a key, hear the sword swing) where music is not (enter an area and music plays continuously in the background).

    SFX requires timing, latency, and speed to be accurate. Music requires bandwidth and a minimum level of continuous CPU cycles.

    Both have different needs so you can have one without the other (when you are talking emulation).

    In Parappa the Rapper, Beatmania, Guitar Freaks, Drummania, Keyboard Mania, Frequency, Amplitude, Taiko Drum Master, Donkey Konga, Guitar Hero, Rock Band, and even scenes in the Mario Party and WarioWare series, the player triggers sound effects at specific times, and these sound effects represent music that the player is performing. If the background music becomes desynchronized from the sound effects that represent music, the emulated environment becomes unusable. Even games that aren't directly about performing music, such as Rez, Lumines, and some scenes in Super Mario RPG, indicate the timing of various game world events using the music.

  17. Startup latency by IamTheRealMike · · Score: 5, Interesting

    Being able to run Python or Quake inside a Flash VM sounds useful at first blush, but it seems you'd lose most of what makes webapps nice for both developers and users. In particular, C based apps are not designed to be streamed, whereas Flash or AJAX apps usually are (to some extent). Nobody wants to browse to a "web app" and then spend 5 minutes twiddling their thumbs whilst 20 megabyte of Python runtime or Quake is pulled down over the wire. Web apps just have a different DNA to desktop apps.

    I can see this being used to accelerate computation-heavy subelements of a regular Flash app though. I wonder how much of this is being driven by a desire to run a Photoshop subset inside Flash?

  18. Re:Sounds fantastic by dedazo · · Score: 5, Funny

    Those who don't remember ActiveX are doomed to reinvent it. Poorly.

    --
    Web2.0: I love when people Flickr my cuil and digg my boingboing until my google is reddit and I start to yahoo
  19. A mighty hack, but of dubious use. by Peganthyrus · · Score: 4, Informative

    Hooray! Now C programmers can join the fun of writing sluggish applications that eat up huge amounts of CPU even when they're doing nothing!

    Deceptive headline, too, as this is just about compiling C to the bytecode that the Flash player interprets. Or even worse, now that I RTFA: "The LLVM instructions are converted into opcodes for a custom Virtual Machine that runs in ActionScript, a variant of ECMAScript and sibling of JavaScript." So your C is compiled to bytecode, that is interpreted by an interpreter that is, itself, a stream of the Flash player's bytecode.

    Moore's Law notwithstanding, this is a pretty insane use of processor cycles, guaranteed to make your program run a couple orders of magnitude slower than it would if you actually compiled it, or rewrote it in Actionscript!

    --
    egypt urnash minimal art.
  20. Re:Right... by Achoi77 · · Score: 5, Funny

    only an API of evil, Darth!

  21. Easier way... by Anonymous Coward · · Score: 5, Interesting

    chrome://browser/content/browser.xul

    Firefox inside Firefox inside Firefox...

  22. Re:Sounds fantastic by DoofusOfDeath · · Score: 4, Funny

    Those who don't remember ActiveX are doomed to reinvent it. Poorly.

    A poorly re-invented ActiveX? I feel like I've just stared into the abyss, and seen Bill staring back at me.

  23. Re:Right... by msuarezalvarez · · Score: 4, Insightful

    I'm pretty sure the current Linux GUIs owe a lot to to Motif.

    Indeed. The violent urge to get rid of Motif has been a driving force in most of the modern GUI development.