Retro Roundup: Old Computers Emulated Right In Your Browser
An anonymous reader writes: If you ever wanted to program an Altair, an Apple I, or a COSMAC ELF you may think you either have to buy one (expensive now) or load and configure simulation software. However, there's a slew of browser-based emulators for everything from a PDP-11 to Windows 1.0 out there. Some use Java, but many use Javascript and many perform better on a modern PC then they did in their original. If you want to learn some history or just want to finally play with the computers you saw in the magazines 35 years ago, these are great fun and slightly addictive.
The problem, as I see it, is that by doing it in Javascript, we're introducing a new dependency: the code will only work on a browser produced in 2015.
That's because Javascript, as implemented in a browser, is itself is a moving target. Go on, just try to browse the modern web in Mozilla 1.0. Or Firefox 3.6. You'll find half the Javascript-dependent sites of 2015 simply doesn't work on older browsers. Sometimes it's performance-related (Slashdot's JS is a prime example of a site that took several seconds to render in older Firefoxes, but worked fine on IE), and some of it fails to render anything at all.
Compiling C/C++ to native gives you a binary that, once compailed, will continue to work as long as the hardware does. Win10 runs 32-bit binaries that are 15-20 years old without compilation. Linux rebuilds from source are typically a "make" command away. (If such support is ever dropped, run a Linux or Windows gues in the VM hosting solution of 2030.)
From the point of view of a software preservationist, I fail to see the point in adding a dependency on "Your 30-year-old ROMs now require whatever Javascript interpreter shipped with the binaries for Chrome 44-through-57, IE11 from mid-2014 to late-2016, and Firefox 41-through-56."
The problem, as I see it, is that by doing it in Javascript, we're introducing a new dependency: the code will only work on a browser produced in 2015.
Well you can rest easy then, because no one is writing this stuff in JavaScript.
What triggered this change is Emscripten, which is a back end for LLVM that targets ... JavaScript. Actually it targets asm.js, which runs at about 1/2 native speed in Firefox (not so fast in Chrome, because Google thinks the solution to the same problem is NaCl).
What that means is any compiler that uses LLVM can now compile to asm.js. Which means any program written in Python, Rust, Go (there are a whole pile of languages) can now be compiled to run in the browser. In particular Clang is a C compiler for LLVM. Dosbox is a x86 + MSDOS emulator, written in C. Ergo Dosbox can now be compiled to JavaScript and this run in the browser. Js-dos is a site apparently dedicated hosting games that does just that. The game console emulators are also written in C. So they to can and now have been compiled to asm.js. Because modern web browsers support WebGL, OpenGL games that have been open sourced (like Quake3) have also been compiled to JavaScript, and run spookelly well. Which is how we get to the plethora of games mentioned in the article. Pity it didn't mention the technology behind it.
But why stop a games? Sqlite3 has been recompiled for Javascript. It can do in browser SQL queries in about 2ms, and is a damned site nicer to use than wandering through a spiderweb of Javascript objects. But why stick to something sane? You can now do ffmpeg encoding in your browser.