Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run C code directly in the browser?

Performance considerations aside, is there any known way to take existing C, C++, or Objective C code and run it directly in the browser? For example, a compiler that converts all the code into some interpreted language that can be run in the browser. Like Javascript, or Actionscript and the Flash player, or I suppose Java and the JVM.

I recognize there are higher level languages like Haxe that can be compiled to different targets. And on the other side there are projects like Cappuccino and GWT that attempt to make Javascript development more like traditional desktop development.

But I was wondering if you had an application that worked on a desktop or an existing code base done in C, C++, or Objective C could it easily be converted to a web based application?

Is there work being done on this front? Is there any practical reason to do this? Basically turn the browser into the OS?

Beside the performance issues, and the entrenchment of OS vendors, are there any technical reasons this couldn't be accomplished? Could this kind of C like code be shoehorned into a virtual machine hosted in a browser?

like image 911
Gordon Potter Avatar asked Sep 18 '09 10:09

Gordon Potter


People also ask

Can C program run without compiler?

If you only have a ". c" file, then you don't have a program. You must compile the program first to make an executable, and then you must run the program to get its output.

Can we run C++ in browser?

Use codepad, a website which lets you compile and share code online. Show activity on this post. There is also Google Native Client SDK that allows C++ code to run in browser. Microsoft Active X is also a viable option.


1 Answers

Google's Native Client (NaCl) uses a tweaked compiler to create x86 object code that can be verified by the browser and run in a sandbox, without a major performance hit - pretty cool stuff. They've compiled Quake under it.

This Matasano article has a good run-down on how it works.

like image 65
caf Avatar answered Nov 15 '22 17:11

caf