21 ms·
While funny looking, what is the ingenuity behind it?
by lysium 13y ago
While funny looking, what is the ingenuity behind it?
- ig1 13y agoIt means it can bypass any automatic "javascript filters" which try and filter out malicious js code while allowing legitimate code.
- bifel 13y agoso does any eval'd code
- tonyarkles 13y agoUnless eval is special-cased to get the evil bit set.
- phillmv 13y agoMany people here on HN never took compsci in school, so strictly speaking it's just a translator - http://en.wikipedia.org/wiki/Translator_(computing) http://en.wikipedia.org/wiki/Translator_(computing) . It's more a showoff of a js idiosyncrasy - they found an ugly looking subset of characters that is Turing complete and wrote a translator to it. If you're new to the concept of Turing tarpits, then this should blow your mind. On the other hand, this is a sufficiently advanced bit of CS thinking that no future employer should question the author's basic competency. I certainly have never written a translator.
- mortenjorck 13y agoAlso worth mentioning the inspiration (and why the name has "fuck" in it): http://en.wikipedia.org/wiki/Brainfuck http://en.wikipedia.org/wiki/Brainfuck
- acjohnson55 13y agoI'm not sure it's a translator by that definition. The input and output are legal Javascript. It's moreso a demonstration of a functionally complete subset of the language. You can get all the primitive values by taking advantage of unary plus, binary +, empty arrays, array dereferencing, function calls, and the standard strings returned by some basic expressions. The numbers are straightforward. The strings are dereferenced with numbers to get some individual letters. You can get methods by using array dereference on objects with strings. You get the rest of the letters with btoa and atob. Then you get eval, and you're off to the races! I'm sure, but I think the encoder just goes token by token, eval'ing string conversions to get identifiers. You'll notice that for pretty simple expressions you get absurdly long strings out.
- phillmv 13y ago>I'm not sure it's a translator by that definition. The input and output are legal Javascript. It's moreso a demonstration of a functionally complete subset of the language. Well, okay, so it's still strictly speaking javascript but if we consider the functionally complete subset to be our 'target' language we end up in the same place, methinks :).
- skue 13y ago> While funny looking, what is the ingenuity behind it? Is there a requirement that HN articles be ingenious? It's a novelty, that's all. And sometimes that's enough.
- lysium 13y agoI guess I was looking for a respond like https://news.ycombinator.com/item?id=6385199 https://news.ycombinator.com/item?id=6385199, making it more than just a mere novelty.