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.
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.
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.
1 | function 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:
1 | function tm(I,tape,end,state,i,cell,current) { |
5 | current = (cell) ? I[state][cell] : I[state].B; |
8 | tape.splice(i, 1, current.w); |
Someone has overbidded it with only 90 bytes of JavaScript.
1 | function (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} |
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.
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.
17259 lines of “Hello World†code…
Check also the hillarious comments on GitHub page.
Source : http://yeblon.com/the-craziest-javascript-implementations?ver=desktop