Hacker News new | past | comments | ask | show | jobs | submit login
TrollScript, an esoteric dialect of Brainfuck. (github.com/tombell)
111 points by wlll on Sept 8, 2011 | hide | past | favorite | 43 comments



I can't understand why anyone would choose to use this language. Clearly it is unreadable and I highly doubt this scales. Can somebody give me a good reason for using this on my Facebook clone instead of a more mature language such as PHP, Python or Java? Also, I heard somebody was developing a web framework, Trolls under Bridges. Has anybody heard about this?


I don't think this is a language people use in real life. It's more for testing. When I went for a job interview at Alexander Interactive http://www.alexanderinteractive.com/ one of the tests they gave me was to write a short bit of code in Brainfuck to reverse a string. The string they gave me was "Hello World". I was allowed to look at the Wikipedia page regarding Brainfuck. They had an interpreter running, into which I could type my code and see the results. I had 15 minutes to make it work.

I think that is where these kinds of languages are used. I think the idea is to test how fast a programmer can learn something new. (For the most part, I'm doubtful about these tests.)


My friend, I believe you've missed the tongue-in-cheek nature of the parent comment (and, in fact, that of Brainfuck itself).


Sounds like either they were messing with you; you are messing with us; or Alexander Interactive doesn't respect their applicants


Impossible, or seemingly impossible, interview questions are actually quite useful. It can be quite informative to see how the applicant response to such a situation, and what their "Oh shit, wasn't expecting this" emergency problem solving techniques are.


Which is another way of saying, messing with people is a respectable interview tactic--see how they react to a little nudge.


> Which is another way of saying, messing with people is a respectable interview tactic

I don't think so. Rather it's that technology jobs (and others, surely) often confront frustrating, confounding, and even downright impossible tasks. The ability to identify a situation as impossible or otherwise -- to drill down to the point of conflict -- is prized, as well as the ability to keep it together mentally and keep plugging away.


beautiful! 12 minutes :

>,[[>,]]<[.<]

edit: of course it should be

>,[>,]<[.<]


">,[>,]<[.<]"

    pStr++;
    *pStr = getc(stdin); //or wherever
    while *pStr {
      pStr++;
      *pStr = getc(stdin);
    }
    pStr--;
    while *pStr {
      putc (*pStr, stdout)
      pStr--;
    }
It'll print the reverse of a string, but it will also print everything before it until it hits a null byte. I'd add

    <[-]
to the beginning to null out the preceding byte and hope it wasn't important.

As silly as brainfuck seems, I could see something like it being used in nanobots (should such a thing ever come to pass), where memory would be at a severe premium.


Brainfuck doesn't really save more memory than any other Turing machine language. However, it could save you silicon space in your hypothetical nanobot because everything is an increment -- incrementing can be done by a chain of half adders, which require fewer gates than full adders.


>It'll print the reverse of a string, but it will also print everything before it until it hits a null byte.

exactly! The brainfuck execution starts with the pointer at the first byte of zero-filled array:

http://www.muppetlabs.com/~breadbox/bf/

So the first ">" in my program moves the pointer to the next byte, and this skipped first byte would serve as a stopper when pointer moves back.


Ah. I wasn't aware of that part of the spec. In that case, then, the code would work.

It's an interesting language, and one that I'm not convinced is so entirely without practical application as is commonly stated.


I think this is a case of premature optimisation. Trolls under Bridges is struggling to hit v1.0 due to the limited memory capacity of trolls, but someone is hard at work on a Node.js implementation of the interpreter. This will allow spawning a new worker process, or "troglodyte", for each request, and will be totally webscale (there will be no unnecessary trolling for events).

In addition, there's also a JVM port of TrollScript in the works, which will add a static type system to the language for troll-safety. This should alleviate any concerns that the language would be unmaintainable for large systems. JTrollScript will also have type inference to maintain the terseness of the original language.


Re: Node.js implementation

my buddy has been hacking on this and he says the benefit of being able to troll on the server the same way you troll the client is a huge benefit.


True, but at the same time it's no match to the TIT (Troll In Time) compiler in cases where every ounce of performance counts.


The various derivatives of Brainfuck are all joke languages.

That said, Brainfuck originally had an at least interesting purpose: The idea was to create a language that could be handled by the smallest possible compiler.

AFAIK a Brainfuck compiler can be implemented in less code than a compiler for any other Turing-complete language.

Still not practical, but interesting nonetheless.


PHP, Python and Java don't have a 'lol' operator!


There's Like, Python, which is arguably even more readable than plain Python! http://staringispolite.com/likepython/


Sorry, meant to vote up.


A trollscript interpreter in trollscript:

https://raw.github.com/gist/1204925/743626cf2313690d82243e99...

Have it sung to you on OS X: $(curl https://raw.github.com/gist/1204925/743626cf2313690d82243e99... | say -v "Bad News")


And I thought brainfuck was hard to read... Pretty funny.


Thanks to HN's URL shortener, with a little help from copy-paste, my mac is now singing the page source of github's 404 page


The biggest obstacle to me using TrollScript professionally is lack of testing tools. Troll-driven development is a fundamental tenet of XP which I'm not willing to forsake. Is anyone working on TSUnit or TSSpec? In addition, Cuke4Trolls would be a worthwhile project. I'd like to practice behaviour-driven trolling expressed in natural troll language, so TrollScript seems like the perfect target.


Someone (definitely not me) should make a GCTA version of this where the 'codons' map to the 8 opcodes.

Then you can execute any DNA string ;)


Now compile the Mr. Trololo video transcript and see what Soviet software he was actually transmitting!


Has anyone done a proper comparison to Ook ?

http://www.dangermouse.net/esoteric/ook.html


Get back to me when I can write it in an IDE with syntax highlighting and content assist.


Be careful what you wish for!



How do I parse Trollscript with Regular Expressions?


  str.scan(/.{3}|.{1,2}$/).each do |bit|
    process(bit)
  end


Something inspired me to write a Brainfuck interpreter after reading this so I just put together one in Scheme with a TrollScript compatibility layer. I haven't tested it extensively but it seems to work with everything that I've thrown at it.

https://github.com/Wollw/BrainScript

I wrote it using Guile 1.8.7 and I have no idea if I'm using Guile specific features or not.

edit: Seems it's still a bit broken. The reverse string example in this thread doesn't work for example.

edit2: Well the reverse string example works now. I changed it to read the EOF as equal to 0.


Here's one a friend and I did in Prolog last year:

https://github.com/danieldk/brainfuck-pl

Why? Because it can be done. And actually prolog's tracing mechanism makes debugging brainfuck code quite insightful.


I coded one in Pharo Smalltalk last year: http://www.squeaksource.com/BrainFuck.html It's so slow it's almost hilarious. It took it 8 hours to print an ASCII mandlebrot fractal frame, NO KIDDING.


Not another scripting language. Google announcing Dart and now this?. I think I like the syntax improvements though.


I work for a company that primarily uses LOLCODE. I've been trying to convince my boss of the benefits of moving to Trollscript, so I wrote this Trollscript interpreter in LOLCODE: https://github.com/aduros/trollcat


If I could, I'd upvote you a million times.


Part of the troll is that it's programmed on top of Ruby...


[deleted]


That's just not _serious_ enough for a name :)


As amusing as I find all this, can you imagine what would happen if one of these took off? I had enough trouble several years ago convincing my boss that we really did need to get a copy of Satan... can you imagine trying to even fill out a PO to order 1000 licenses of Brainfuck with the optional TrollScript extension?


Your trolling is highly inappropriate.


This is the best thing I've seen in my whole life. Word.


Wow... I never knew a 'Hello World' program could look like this. Mind = Blown.

Trooloolooloolooloolooloolooloolollooooolooloolooloolooloolooooolooloolooloolooloolooloolooloooooloolooloooooloooloolooloololllllooooloololoooooololooolooloolooloolooloololoolooolooloololooooooloololooooloololooloolooloolooloolooloolooloolooloolooloololooooolooolooloololooollollollollollolllooollollollollollollollollloooooololooooolooll.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: