News for hackers. Stuff that matters.
Re:JavaScript was Brainfuck all along by makeworld on Friday February 02, 2024 @03:42PM (#39234060)
Re:JavaScript was Brainfuck all along by artbit on Friday February 02, 2024 @03:49PM (#39234152)
Hah! That's awesome. I wasn't aware of it.

But yeah, it's not a new idea really. Even my original article was written, over a decade ago: https://blog.djordjeungar.com/post/2011-09-13-obscure-javasc...

Re:JavaScript was Brainfuck all along by Player6225 on Friday February 02, 2024 @11:11PM (#39237481)
And then there was that time some people used jsfuck to do xss on Ebay:

https://arstechnica.com/information-technology/2016/02/ebay-...

Re:JavaScript was Brainfuck all along by pona-a on Saturday February 03, 2024 @09:43AM (#39240760)
Cloudflare uses it for some of their challenges.
Re:JavaScript was Brainfuck all along by kderbyma on Friday February 02, 2024 @04:14PM (#39234491)
I have used this on some coding challenges when you try to get the shortest answer or oneliner.
Re:JavaScript was Brainfuck all along by artbit on Friday February 02, 2024 @02:56PM (#39233377)
JavaScript type coercion allows for some really obscure transformations, that make it look like BrainFuck.
Re:JavaScript was Brainfuck all along by klyrs on Friday February 02, 2024 @05:03PM (#39235070)
Hard mode: write a nontrivial program the intersection of javascript and brainfuck (no characters except []+-,.<>), which does the same thing in both languages.
Re:JavaScript was Brainfuck all along by trealira on Friday February 02, 2024 @08:32PM (#39236782)
Brainfuck interpreters just ignore the characters in the file that aren't those particular Brainfuck operators, treating them as comments. So, you could just write a Brainfuck interpreter in JavaScript that interprets a string literal, then write the Brainfuck program as a string literal. You'd still have to write the JavaScript BF interpreter so that everything that isn't the string literal has no observable effect when interpreted by a BF interpreter.
Re:JavaScript was Brainfuck all along by klyrs on Saturday February 03, 2024 @12:20AM (#39237725)
That's easy mode
Re:JavaScript was Brainfuck all along by vrighter on Saturday February 03, 2024 @11:17AM (#39241723)
put the interpreter into a function placed in an array at the beginning. use an array constructor for this and your whole interpreter is now wrapped by a bf loop at the start of the program. Which bf will immediately skip tecause the initial cell will be 0. Then index into an array to get the first item. Another loop on the initial cell. Skipped. Then pass the bf source to the function. No brainfuck commands are needed for this.

<pre><code> [ function(src){ // interpreter goes here } ][[]]("brainfuck source goes here"); </code></pre>So your interpreter could be anything you want and it won't conflict with any other bf code as long as you keep your square brackets matched up (this is easy to do in js).

The rest is, of course, an exercise left to the reader.

Re:JavaScript was Brainfuck all along by hyperhello on Friday February 02, 2024 @05:18PM (#39235201)
Doesn't TypeScript let you build things like this right in the static types?
Re:JavaScript was Brainfuck all along by specialist on Friday February 02, 2024 @08:20PM (#39236710)
The design and impl of Brainfuck represents more thought, effort, esthetics, and clarity of purpose than the initial JavaScript.
Re:JavaScript was Brainfuck all along by Our_Benefactors on Saturday February 03, 2024 @08:52AM (#39240327)
Haha JavaScript bad, amirite fellow codemonkeys?!