Brainfuck Javascript



  • @the site said:

    tl;dr I just made a tool to transform any javascript code into an equivalent sequence of ()[]{}!+ characters.

    Why?

     

     



  • Because reasons.



  • Someone thinks it's funny. That person should be hunted down and forced to watch Mystery Science 3000 until he develops a heathy sense of humor.

    Apparently "heathy" isn't a spelling error according to Chrome, so I'll leave it there without looking up what the word means. If it doesn't make sense you can mentally swap it for "healthy".



  • @blakeyrat said:

    Someone thinks it's funny. That person should be hunted down and forced to watch Mystery Science 3000 until he develops a heathy sense of humor.

    Apparently "heathy" isn't a spelling error according to Chrome, so I'll leave it there without looking up what the word means. If it doesn't make sense you can mentally swap it for "healthy".

    heathy: full of heath.



  • @Cassidy said:

    http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html

    @the site said:

    tl;dr I just made a tool to transform any javascript code into an equivalent sequence of ()[{}!+ characters.

    Why?

    ({}+[])[!+[]+!![]]+([][+[]]+[])[!+[]+!![]+!![]]+({}+[])[!+[]+!![]+!![]+!![]+!![]]+(+{}+[])[+!![]]+([][+[]]+[])[+[]]+(![]+[])[!+[]+!![]+!![]]+([][+[]]+[])[!+[]+!![]+!![]]+({}+[])[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+([]+[][(![]+[])[!+[]+!![]+!![]]+({}+[])[+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]]({}+[])[!+[]+!![]+!![]+!![]+!![]]+({}+[])[+!![]]+([][+[]]+[])[+!![]]+(![]+[])[!+[]+!![]+!![]]+(!![]+[])[+[]]+(!![]+[])[+!![]]+([][+[]]+[])[+[]]+({}+[])[!+[]+!![]+!![]+!![]+!![]]+(!![]+[])[+[]]+({}+[])[+!![]]+(!![]+[])[+!![]]())[+[]]+([][+[]]+[])[!+[]+!![]+!![]]+({}+[])[!+[]+!![]+!![]+!![]+!![]+!![]+!![]]+({}+[])[!+[]+!![]+!![]+!![]+!![]]+({}+[])[+!![]]+([][+[]]+[])[+[]]+(![]+[])[!+[]+!![]]+([][+[]]+[])[!+[]+!![]]



  • Because some people think they just need a blacklist of words to prevent malicious JavaScript from running (but still allow harmless JavaScript). As this page (and other similar projects) prove, there is no way to do things like that in a dynamic turing-complete language like JavaScript :-)



  • Saw this on Reddit the other day. Actually, it's a pretty awesome method of obfuscation... :D



  • @Cassidy said:

    http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html

    @the site said:

    tl;dr I just made a tool to transform any javascript code into an equivalent sequence of ()[{}!+ characters.

    Why?

    Well, as it says at the site, near the top, in big letters:

    What do you know about non-alphanumeric XSS?



  • @blakeyrat said:

    Someone thinks it's funny. That person should be hunted down and forced to watch Mystery Science 3000 until he develops a heathy sense of humor.
     

    You're a code-conservative!

    You poopy-head!



  • @dhromed said:

    Your a poopy-head!


    FTFY



  • @flabdablet said:

    @Cassidy said:

    http://patriciopalladino.com/blog/2012/08/09/non-alphanumeric-javascript.html

    @the site said:

    tl;dr I just made a tool to transform any javascript code into an equivalent sequence of ()[{}!+ characters.

    Why?

    ({}+[)[!+[+!![]+([[+[]+[)[!+[+!![+!![]+({}+[)[!+[+!![+!![+!![+!![]+(+{}+[)[+!![]+([[+[]+[)[+[]+(![+[)[!+[+!![+!![]+([[+[]+[)[!+[+!![+!![]+({}+[)[!+[+!![+!![+!![+!![+!![+!![]+([+[[(![+[)[!+[+!![+!![]+({}+[)[+!![]+(!![+[)[+!![]+(!![+[)[+[]][({}+[)[!+[+!![+!![+!![+!![]+({}+[)[+!![]+([[+[]+[)[+!![]+(![+[)[!+[+!![+!![]+(!![+[)[+[]+(!![+[)[+!![]+([[+[]+[)[+[]+({}+[)[!+[+!![+!![+!![+!![]+(!![+[)[+[]+({}+[)[+!![]+(!![+[)+!![]())[+[]+([[+[]+[)[!+[+!![+!![]+({}+[)[!+[+!![+!![+!![+!![+!![+!![]+({}+[)[!+[+!![+!![+!![+!![]+({}+[)[+!![]+([[+[]+[)[+[]+(![+[)[!+[+!![]+([[+[]+[)[!+[+!![]

    Syntax error: Unexpected )



  • It's awesome. First thing I tried gave a syntax error, but hey, the idea is just brilliant.



  • @TGV said:

    It's awesome. First thing I tried gave a syntax error, but hey, the idea is just brillant.

    FTFY :)



  • Interesting... I did a very similar thing a while back. http://jsfiddle.net/Daniel15/Z6FBf/2/ (Community Server seems to eat some of the characters)



  • @Ben L. said:

    Syntax error: Unexpected )

    Yeah, that's CS eating square brackets in a manner I couldn't find a way to fix before the edit window closed. Here's the string again at pastebin.



  • @flabdablet said:

    @Ben L. said:

    Syntax error: Unexpected )

    Yeah, that's CS eating square brackets in a manner I couldn't find a way to fix before the edit window closed. Here's the string again at pastebin.

    Following your link I ended up browsing the "trending pastes" page and found myself reading conspiracy theories and weird h4x0r stuff posted by random people. Even more entertaining than the Coding Snacks forum on DonationCoder.com.

    Internet is a very peculiar place.



  • @Daniel15 said:

    Interesting... I did a very similar thing a while back. http://jsfiddle.net/Daniel15/Z6FBf/2/ (Community Server seems to eat some of the characters)

    Your solution is sub-optimal. Ditch the '' in favor of [] and it's even more fucked.



    TRWTF: CS eating ] but not [



  • @ekolis said:

    @TGV said:
    It's awesome. First thing I tried gave a syntax error, but hey, the idea is just brillant.
    Error'd that for you  :)
     

    FTFY



  • Ah, Javascript, with it's confusing crazy syntax (happy-go-lucky type casting, semicolon insertion) and it's having been shoehorned into a functional language despite taking at least 11 characters to define a lambda.



  • @MiffTheFox said:

    Ah, Javascript, with it's confusing crazy syntax
     

    What?

    @MiffTheFox said:

    (happy-go-lucky type casting, semicolon insertion)

    It's fine.

    @MiffTheFox said:

    having been shoehorned into a functional language despite taking at least 11 characters to define a lambda.

    You're insane! You've lost all capacity for reason!

     

     



  • @MiffTheFox said:

    Ah, Javascript, with it's confusing crazy syntax (happy-go-lucky type casting, semicolon insertion)

    I agree the semicolon insertion is slightly WTF.

    @MiffTheFox said:

    and it's having been shoehorned into a functional language

    It was designed to be usable as a functional language. (In JavaScript, everything is an object. Especially functions.) Or you can write procedural code. Or you can write OOP code. Or you can combine those three concepts in any way you please.

    @MiffTheFox said:

    despite taking at least 11 characters to define a lambda.

    How many characters is the correct amount?

    JavaScript worse than PHP? You're fucking insane.



  • Brainfuck Javascript is redundant.



  • First of all, JavaScript was designed... first by Netscape, then Microsoft, now Google, and then the jQuery foundation. Not even PHP requires a third-party library just to guarantee basic functionality across platforms.

    @blakeyrat said:

    It was designed to be usable as a functional language. (In JavaScript, everything is an object. Especially functions.) Or you can write procedural code. Or you can write OOP code. Or you can combine those three concepts in any way you please.

    JavaScript doesn't have OOP. It has objects, which are more in line with a Python dict or a PHP associative array. Granted the objects have things that resemble types and constructors, but there's no way to guarantee that particular fields exist or are of a specific type, nor is there a way to directly inherit a parent object.

    As for procedural programming, we'll look a simple animation code, and we'll be insane and not use jQuery. The correct procedural way to make an element fade out would be:

    function fadeOut(element){
        for (var opacity = 1.0; opacity >= 0.0; opacity -= 1.0){
            element.style.opacity = opacity;
            sleep(100);
        }
    }
    

    Obviouly, the sleep function isn't really feasable. Javascript doesn't yet have threading (implemented in a standard way across all major browsers) so this would also freeze the browser. What's the recommedned way to do this?

    function fadeOut(element, opacity){
        opacity = opacity || 1.0; // Only way to specify default parameters, btw.
        if (opacity >= 0.0){
            element.style.opacity = opacity;
            window.setTimeout(function(){ fadeOut(element, opacity - 1.0); }, 100);
        }
    }
    

    And of course, if you want to do something after fading the element out, you need to add a callback fo the fadeOut function, whereas a procedural language will just let you place it after the fadeOut call.

    @blakeyrat said:

    [quote user="MiffTheFox"]despite taking at least 11 characters to define a lambda.

    How many characters is the correct amount?[/quote]

    C# can do it in two ( x => ), ML and it's descendants in five ( fun x -> ), and Haskell in four ( \x -> ). Sure, other languages like C and PHP require the longer function(x){ } syntax, but none of them are functional languages.

    @blakeyrat said:

    JavaScript worse than PHP? You're fucking insane.

    Maybe if I wrote a "JavaScript: a fractal of bad design" blog post people would start agreeing with me.



  • @MiffTheFox said:

    JavaScript doesn't have OOP.

    Oh noes! Now we can't trust anything else you said, because it might be just as stupid!



  • @MiffTheFox said:

    First of all, JavaScript was designed...

    Yes.

    @MiffTheFox said:

    first by Netscape,

    Yes.

    @MiffTheFox said:

    then Microsoft,

    No.

    @MiffTheFox said:

    now Google,

    WTF!?

    @MiffTheFox said:

    and then the jQuery foundation.

    WTF WTF WTF!!!

    Netscape passed JavaScript to the ECMA, who has been responsible for developing it. Microsoft never did any JavaScript work; they built their own implementation which was close, but not exactly, an implementation of the ECMA JavaScript spec. Since it wasn't 100%, they called it "JScript" instead of JavaScript. (A lot of past WTFs are from the fact that IE was running JScript and not JavaScript proper.)

    Google? Google worked on building a better JavaScript compiler (V8), but they've never worked on the JS spec as far as I'm aware. If you have a link, please provide it.

    jQuery? jQuery has nothing to do with JavaScript; it's a replacement/enhancement for DOM. Nothing jQuery does replaces or enhances any part of JavaScript. (Again: as far as I'm aware. If you have a link, please provide it.)

    @MiffTheFox said:

    JavaScript doesn't have OOP. It has objects, which are more in line with a Python dict or a PHP associative array.

    But it also has Prototype Objects, which make it OOP. You can twist the definitions all you want, but everybody (except you, apparently) agrees JavaScript is an OOP language.

    BTW, OOP doesn't require inheritance.

    @MiffTheFox said:

    As for procedural programming, we'll look a simple animation code,

    It is true that JavaScript has no threading. It's not designed to be used for things that require threading. The setTimeout() function isn't JavaScript; it's DOM.

    It's hard to debate the merits of JavaScript with someone who doesn't know what JavaScript actually is. But if it makes you feel better: I do agree that DOM is fucking awful, and tools like jQuery only exist because DOM is fucking awful. However, that has nothing to do with JavaScript-- DOM would be just as fucking awful if browsers happened to run Lua or VBA or whatever embedded language you like.

    @MiffTheFox said:

    Maybe if I wrote a "JavaScript: a fractal of bad design" blog post people would start agreeing with me.

    Maybe but I doubt it.



  •  I think someone doesn't know the difference between a programming language and the libraries and environment it's used it. JavaScript as a language is pretty neat, and I use it outside the browser in some tools and scripts (using node.js mainly) and it's not nearly as horrible as using it in the browser. I've grown to like it.



  • Not even PHP requires a third-party library just to guarantee basic functionality across platforms.

    PHP just has a single main implementation, though.

    JavaScript doesn't have OOP.
    Intrinsic types like strings have instance methods on them (like toUpperCase)... Looks pretty OO to me.


  • @Daniel15 said:

    Not even PHP requires a third-party library just to guarantee basic functionality across platforms.

    PHP just has a single main implementation, though.

    JavaScript doesn't have OOP.
    Intrinsic types like strings have instance methods on them (like toUpperCase)... Looks pretty OO to me.
    (7).toString(2)


  • Ok, first off I'm talking about Javasript the environment, not just Javascript the language. I'd be like I was complaining about Python the environment or Java the environment or .NET the environment, instead of Python the language, Java the language, or C# the language.

    DOM is inextricable from Javascript and thus is part of the environment. If this is false, where can I use JavaScript wihout DOM? Even node.js implements it to some extent. (setTimeout and setInterval for one are there.)

    Microsoft and Google added features to DOM (an increasingly misleading title, seeing as it does more standard library functions beyond document manipulation) which later became "standard", one such example is XMLHttpRequest, which was designed solely by Microsoft as an ActiveX object (Msxml2.XMLHTTP). Some of those features, like querySelector are designed first and foremost with jQuery in mind.



  • @MiffTheFox said:

    DOM is inextricable from Javascript and thus is part of the environment. If this is false, where can I use JavaScript wihout DOM?
     

    ASP classic.

    WSH.



  • @MiffTheFox said:

    DOM is inextricable from Javascript and thus is part of the environment. If this is false, where can I use JavaScript wihout DOM? Even node.js implements it to some extent. (setTimeout and setInterval for one are there.)

    Rhino



  • @MiffTheFox said:

    DOM is inextricable from Javascript and thus is part of the environment. If this is false, where can I use JavaScript wihout DOM? Even node.js implements it to some extent. (setTimeout and setInterval for one are there.)

    Your parochialism rivals the best around here. In addition to what others have pointed out, behold the magic that is:

    wxJavascript

    It uses SpiderMonkey as the javascript interpreter, which you can embed in whatever application you like, even ones that don't know anything about DOM!

    Also, your statement that node.js "implements it to some extent" shows that DOM isn't inextricable at all. And the fact that it adds stuff like setTimeout, which is something that also exists in DOM doesn't really support your argument.



  •  Okay, so we've adequately demonstrated the separation between DOM and JS, now I shall do my best to summarize!

     

    JavaScript doesn't have OOP.

    False.

    we'll be insane and not use jQuery.

    True.

    despite taking at least 11 characters to define a lambda.

    This is inconsequential.

    confusing crazy syntax

    It's misused hyperbole. I think you're thinking of INTERCAL. JS' syntax is very clear. It reads like kind of like python but with accolades.

    It is true that JavaScript has no threading. It's not designed to be used for things that require threading.

    Given the things JS is used for, threading would be a fun thing to have.



  • @MiffTheFox said:

    Ok, first off I'm talking about Javasript the environment, not just Javascript the language.

    JavaScript doesn't have a "the environment." JavaScript is designed to be embedded. That is why it exists. That is its raison d'être.

    The JavaScript "environment" consists of the Math object, Date object and... that's it. That's all it is. It doesn't even have any I/O. At all. The setTimeout() function isn't part of the JavaScript environment, it's part of DOM. Without being embedded in some other environment (that provides at least I/O), JavaScript can do literally nothing at all. It is nothing on its own. Nothing. This is by design.

    I know I'm explaining this slooowly (as I would a child), this is because it's obvious and every dumbshit already knows it, and I'm hoping typing this like a kindergarten PowerPoint presentation will maybe help it sink in.

    You can't say "JavaScript" magically means something other than what ECMA says it means, otherwise we're in a world of shit where nobody can communicate with anybody else ever anywhere ever in history ever because nobody uses the same definitions for words. For instance, when I said "dumbshit" up there you might have read it as "an outstanding and intelligent human being" when I really meant "dumbshit."

    @MiffTheFox said:

    I'd be like I was complaining about Python the environment or Java the environment or .NET the environment, instead of Python the language, Java the language, or C# the language.

    Python and Java do ship with default libraries, though. As does .net. (But remember: .net isn't just C#, it's a half-dozen languages.) JavaScript does not.

    @MiffTheFox said:

    DOM is inextricable from Javascript and thus is part of the environment.

    JavaScript is always part of some environment; again that is the point of the language, it's designed to be an embedded scripting language.

    @MiffTheFox said:

    Even node.js implements it to some extent. (setTimeout and setInterval for one are there.)

    Good for node.js? Now see if ActionScript (Flash/Air) has it, and JScript (running in WSH). (Although honestly I think both probably do. This is because setTimeout() and setInterval() are handy to have, not because they are part of JavaScript.)

    @MiffTheFox said:

    Microsoft and Google added features to DOM (an increasingly misleading title, seeing as it does more standard library functions beyond document manipulation) which later became "standard", one such example is XMLHttpRequest, which was designed solely by Microsoft as an ActiveX object (Msxml2.XMLHTTP). Some of those features, like querySelector are designed first and foremost with jQuery in mind.

    Wow that's one hell of a sentence.

    And yet it says nothing about JavaScript.



  • @blakeyrat said:

    see if ActionScript has it, and JScript.
     

    Actionsscript has it, because its purpose is pretty much the same as Javascript in a browser.

    JScript as used in ASP classic has no timeouts.



  • @blakeyrat said:

    I know I'm explaining this slooowly (as I would a child)

    This was possibly the least likely quote from a mildly successful sci-fi movie ever. Are you planning to bust a record*?

    * notice the intense look on the guy's face around 1:13, it shows how badass videogame players can be.



  • @Speakerphone Dude said:

    This was possibly the least likely quote from a mildly successful sci-fi movie ever.

    Kids these days.



  •  oh god yes galaxy quest


  • Discourse touched me in a no-no place

    @dhromed said:

    galaxy quest
    was crap. Don't start this again - it's only been 10 weeks since the last time ('I hate place-holder code' for those who can be bothered.)



  • @PJH said:

    @dhromed said:
    galaxy quest
    was crap.

    NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!



  • Alright, I concede defeat. Javascript is an amazing language and DOM, an implemention, fucks it up. Here's a snippet from a site I'm working on, armed with this new knowledge:

    <script type="application/dom" src="editor.dom"><script>


  • Hey you should maybe try learning something from this thread instead of dismissing it.

    Also you do realize that, back when VBScript was supported as a scripting language in some (ok, one) browsers, it still used DOM, right? DOM is the Document Object Model, it's completely divorced from the programming language used to interface with it (hell, C# has DOM bindings), all it requires is that the language have a concept of an "object".



  • @PJH said:

    @dhromed said:
    galaxy quest
    was crap.
     

    INFADEL



  • @MiffTheFox said:

    Alright, I concede defeat. Javascript is an amazing language and DOM, an implemention, fucks it up.

    Yeah, just like how Win32, a C implementation, skull fucks the C programming language.


  • :belt_onion:

    php.js

    That is all.



  • @Onyx said:

    php.js

    That is all.

    Can't wait until they do the opposite, I always wanted to use alert() in php...


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.