Javascript PC emulator runs Linux

Fabrice Bellard, creator of the multiple architecture emulator QEMU and FFmpeg, amongst other open source projects, has unleashed his Javascript powered PC emulator. In its current state, it boots a stripped down, text mode Linux implementation and runs within a modern browser. Interesting curio or a potentially useful tool?

To say it's written in Javascript, an interpreted language that is usually used for client-side scripting on web pages, the emulator runs remarkably quickly. It boots to a command prompt in about a minute on this machine (Sempron 3000, FF 4.1). [Update: Considerably faster than that on my CoreDuo] By the way, the emulator requires a modern browser such as Firefox 4 or Chrome in order to operate.

Things are still at the proof of concept stage but there is already enough to play around with. Sitting on a command line prompt, the first thing I tried was typing ls. Doing this revealed the presence of a single file, a C source code file called hello.c. Attempting to compile with GCC wont work because GCC isn't installed. Examining the content of the file got the the bottom of things:

~ # cat hello.c
/* This C source can be compiled with:
tcc -o hello hello.c
*/
#include <tcclib.h>
int main(int argc, char **argv)
{
printf("Hello World\n");
return 0;
}
~ #


That the system includes the Tiny C Compiler (not to be confused with Small-C) makes sense as that is another project that was started by Bellard. You can get an idea of what other utilities are supported by the system by typing

ls /bin

So, what could this thing actually be used for, I hear you ask? As it stands, not all that much. For one thing, networking is not yet emulated. To perform any type of file transfer between the host and guest environments, one has to use the system cut and paste buffer and a virtual /dev/clipboard device. Other than that, there's no way to get data into or out of the system. This could be a point in the system's favor because, as it really is running locally, rather than on a server, it's fairly good in privacy terms. You can wipe the entire system by simply hitting refresh.

It could perhaps be used to provide some sort of training environment to teach people how to use the Linux command line. As it stands, the system could be used to compile simple snippets of C code if you were to find yourself stuck on a machine without a compiler installed.

[Update: Seems that a pal of mine, Chris Williams, is using it to demo his hobbyist microkernel project Diosix]

The implementation of a complete machine emulator is not the type of task that Javascript was created for. If you really needed a Linux command line that can be accessed without installing anything to the host machine, you'd be better off either SSHing into a remote box or running a virtual machine locally. If it must be browser based, a Java based PC emulator would be quite slow but it would still run faster than one written in Javascript. The JPC website even hosts some example Linux demos that you can try out, but of course, they require that you have Java installed.

Bellard's Javascript PC Emulator is an intriguing feat of programming, but it's likely that it wont see much practical use. It's still cool though.

The Javascript PC Emulator website.

______________________

UK based freelance writer Michael Reed writes about technology, retro computing, geek culture and gender politics.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

I ran rm -rf * LOLOLOLOLOLLL

Anonymous's picture

I ran rm -rf *

LOLOLOLOLOLLL

This is so cool! OK everyone

Anonymous's picture

This is so cool!
OK everyone put your heads together and ponder what other interesting uses this can have.

Absolutely! I have no idea

PeterR's picture

Absolutely! I have no idea what this could be used for, but it is simply cool. Any of you old enough to remember people asking similar questions about Linux itself?

Wow, it's great, Someday I

SESO's picture

Wow, it's great, Someday I wanna make that kind of system : )

Does not require FF 4, unless

Anonymous's picture

Does not require FF 4, unless you are referring to a specific function, seems to run fine on FF 3.6.17 (claims to take 34s to boot).

this is... art.

aryszka's picture

this is... art.

Missed the point entirely

allenbeme's picture

No GCC? Are you serious? This is a demo of Bellard's programming prowess plus the power of JavaScript. Maybe one day, Linux will just be a bootloader for JavaScript.

Nothing wrong with it not

Michael Reed's picture

Nothing wrong with it not having GCC. In fact, it would probably be inappropriate on such a resource constrained environment.

UK based freelance writer Michael Reed writes about technology, retro computing, geek culture and gender politics.

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState