The craziest Javascript implementations

  yeblon.com        2012-01-03 12:09:42       3,547        0    

Since its birth in 1994, Javascript has come a long way. Today it’s one of the most popular programming languages on the web because of high popularity of AJAX based web-applications. Also the rise of micro-frameworks such as jQuery (also Prototype, Moo Tools etc) which have reduced dramatically the complexity of code developers needed to write, it is well tested, has a ton of plug-ins, has a large development community and reduced development time.

And lately even Server-Side JavaScript (SSJS) like Node.js which allows you to create high performance, real-time web applications easy. It allows JavaScript to be used end to end, both on the server and on the client. So you only need to learn one language.

Below there is a list of the craziest Javascript implementations I have come across with.

A famous software developer, book author, podcaster and writer of the popular blog Coding Horror,
Jeff Atwood said:

Any application that can be written in JavaScript, will eventually be written in JavaScript.

He called it Atwood’s Law.

1) Face Detection in JavaScript

A Chinese developer Liu Liu has implemented the algorithm using the canvas element. The algorithm is implemented on top of a JS port of a C-based computer vision library made by also the Liu Liu. It works off a grayscale version of the image, and is quite reliable in detecting faces in photographs.
jQuery version is also available.

2) A Turing machine in 133 bytes of JavaScript

A Turing machine is the simplest form of a computer. The concept was invented by Alan Turing in 1936. This was the first computer invented (on paper only). Apparently someone has decided to write a nondeterministic Turing machine simulator in 20 lines JavaScript.

1function tm(I,t,e,s,i,c,k) {i=0;while(s!=e){c=t[i];k=(c)?I[s]1[/c]:I[s].B;if(!k)return false;t.splice(i,1,k.w);i+=k.m;s=k.n;}return t;}

And readable version:

1function tm(I,tape,end,state,i,cell,current) {
2    i = 0;
3    while(state != end) {
4        cell = tape[i];
5        current = (cell) ? I[state][cell] : I[state].B;
6        if(!current)
7            return false;
8        tape.splice(i, 1, current.w);
9        i += current.m;
10        state = current.n;
11    }
12    return tape;
13}

Someone has overbidded it with only 90 bytes of JavaScript.

1function(a,b,c,d,e,f,g){for(e=0;d<c;b[e]=(g=(f=a[d])[b[e]]||f.B).w,e+=g.m,d=g.n);return b}

3) Java Virtual Machine JVM written in JavaScript

Java Virtual Machine JVM written in JavaScript sounds like another level of insanity but it’s true. This isn’t a Java to JavaScript translator but a real JVM that runs byte code. This means it could run any language that compiles to byte code.

4) x86 Emulator written in JavaScript

32bit x86 emulator in JavaScript – a virtual PC that runs inside your browser, using JavaScript. And of course also a Linux kernel that can run inside it, so you can have a full-featured PC inside your browser.

5) “Hello World” in Dart, Compiled to JavaScript

17259 lines of “Hello World” code…
Check also the hillarious comments on GitHub page.

Source : http://yeblon.com/the-craziest-javascript-implementations?ver=desktop

JAVASCRIPT  JVM  TURING MACHINE  CRAZY IMPLEMENTATION 

       

  RELATED


  0 COMMENT


No comment for this article.



  RANDOM FUN

Front end again