Javascript amazeballs
August 11, 2012 6:54 AM   Subscribe

One for the javascript geeks: Transform any javascript program to use only the ()[]{}! and + characters.
posted by zoo (23 comments total) 25 users marked this as a favorite
 
Now if the tool would just convert all if statements to boolean it would just be perfection.
posted by sammyo at 7:04 AM on August 11, 2012


sammyo: There are other tools that sort of can do exactly that. Details can be found in a talk from Paul Irish [slyt].

On a lighter note and related: WAT [yaslyt]
posted by KMB at 7:19 AM on August 11, 2012


This is an amazing bit of geekry.
posted by JHarris at 7:20 AM on August 11, 2012


Good god. That actually made me cackle at a couple of points.
Would this actually be useful in real life if you were trying to inject malicious code somewhere?
posted by lucidium at 7:23 AM on August 11, 2012


The obfuscated C contest can pack it in. This has won the internet.
posted by localroger at 7:28 AM on August 11, 2012 [3 favorites]


Clever.

And yet another demonstration why JavaScript is a fucked-up, awful language.

(I've had to use it since 1998, and I'm pretty good, but the language itself still blows. It's only the emergence of decent libraries like jQuery, YUI, etc, and better, faster computers that keeps this terrible language around)
posted by Artful Codger at 7:45 AM on August 11, 2012 [1 favorite]


The Hacker News discussion includes an interesting optimization: "Trick #1 is to get the letter S. You can extract this from the source code of the String constructor".

Helpful and related, table of Javascript equivalences.

I know everyone likes to hate on Javascript, and this kind of weirdness doesn't help make the case. But it's a remarkably flexible and productive language. There's some core good ideas in it, particularly the ease of creating closures and adding functions to objects. I genuinely enjoy programming in it and most of these language details don't matter much in practice.
posted by Nelson at 7:54 AM on August 11, 2012 [3 favorites]


Now that JS has acheived Perl's level of obfusgreatness, it's probably got another 10 years to go.

And don't feed the Artful Codger troll.
posted by furtive at 8:29 AM on August 11, 2012


Welp, now my eyes are bleeding.
posted by subbes at 9:06 AM on August 11, 2012


When I was programming in Perl, I had a great extension called Acme::Bleach, which took any code you fed it and converted it into a trinary alphabet whose consisting of the space, tab, and newline characters. It was great opening up a file that just said something like Use Acme::Bleach at the top, followed by a bunch of white space, and then be able to execute it.
posted by kaibutsu at 9:13 AM on August 11, 2012 [11 favorites]


Can't wait to see this shit turn up in hacks to my WordPress site.
posted by Legomancer at 9:38 AM on August 11, 2012


There's some core good ideas in it, particularly the ease of creating closures and adding functions to objects.

As someone else once said about something else, the parts of Javascript which are good are not original, and the parts which are original are not good. Of course many of the parts which are not original are not good either.

This should not be construed as a personal attack on Brendan Eich himself: the language is quite a solid accomplishment given the ludicrous deadline and nonsensical design constraints he was working under. We're just stuck, forever, with all the loose ends and poorly thought out quirks of something that should have been an early draft and not a final design.

signed, a grouchy old compiler hacker
posted by Mars Saxman at 11:30 AM on August 11, 2012 [4 favorites]


I'm reminded of this image of the Javascript: The Good Parts book.

I love coding in Javascript. But it may be a case of Stockholm Syndrome.
posted by zsazsa at 3:08 PM on August 11, 2012 [5 favorites]


So this transforms javascript into something worse-looking than brainf*ck? Nice.
posted by plinth at 3:24 PM on August 11, 2012


When I was programming in Perl, I had a great extension called Acme::Bleach

Perl hackers just love to reinvent the wheel, don't they?
posted by thelonius at 4:50 PM on August 11, 2012


furtive: And don't feed the Artful Codger troll.

JavaScript is soooo wonderful it's now used by/in _________________

No troll, JavaScript is ... a mediocre programming language, and the only reason it's less painful and more productive today is because, since it was the only game in town, the entire developer community struggled with it until there was a canon of reliable tricks, kludges and workarounds to be able to get work done. (and better faster computers for the client-side libraries to work on)

I will admit that at least 50% of my ire comes from the standards-bending and f'ed up divergent DOMs foisted on us in the Browser Wars.

Maybe I shouldn't complain too loudly. Developers like me got paid not inconsiderable bucks to do client-side things that should have been just a few trivial lines, if there had been a better-suited language and a standards-compliant DOM.

I know it's a pointless rant. JavaScript is in the browser for the foreseeable future, and many clever people have worked hard to made it bearable.
posted by Artful Codger at 6:09 PM on August 11, 2012


Since every JavaScript thread turns into a bash fest, I am, as usual, forced into the position of JavaScript apologist.

I like working in JavaScript for the following reasons:
  • First order functions enable functional-style programming, which is widely regarded as less prone to bugs.
  • Closures make it easy to control scope and write efficient code.
  • Coffeescript offers a nice syntax wrapper for a lot of JavaScript's harder-to-grok features, like its inheritance model. JavaScript-targeted compiled languages are really promising.
  • JavaScript is easy to extend by allowing overwriting of object prototypes.
  • It's already native to the web. Java applets are dead. Dart is dead. There are no real promising alternatives to JavaScript if you want to write programs that run in the browser, as of right now.
  • Rich JavaScript applications are the future of the web and older patterns that focus on server-side rendering seem increasingly anachronistic given the speed of JS engines available on modern browsers.
posted by deathpanels at 12:16 AM on August 12, 2012 [2 favorites]


I used his online tool to convert
     var a = 'I am the answer';
to the bracket language. I would print the result here, but it was just shy of 28,000 characters.
posted by maxwelton at 1:08 AM on August 12, 2012


It's out of my system now, I promise never to rant about JS on the blue again.

Yes, people are doing amazing things with it.

going back under my bridge now.
posted by Artful Codger at 7:06 AM on August 12, 2012


I like working in JS because there are no alternatives? That's … not the most compelling reason. Nor is "I like working in JS because there are other languages that compile to JS that I like working in."
posted by kenko at 8:40 AM on August 12, 2012 [1 favorite]


but it was just shy of 28,000 characters.

Hey, CPU perfromance and memory capacity are acclerating so much that you should just ignore that. Only suckers optimize their code.
posted by localroger at 7:27 PM on August 12, 2012 [1 favorite]


I'm at a Chick-Fil-A, coding some JS. -- PLT Zizek
posted by A dead Quaker at 8:46 PM on August 12, 2012


Is "I like working in JRuby because it runs on the JVM" not a valid reason for liking JRuby?
posted by deathpanels at 10:13 AM on August 13, 2012


« Older To the Moon! (almost)   |   Kenyan record-winning distance runners trained by... Newer »


This thread has been archived and is closed to new comments