Strange Computer Languages: A Hacker’s Field Guide

Why do we build radios or clocks when you can buy them? Why do we make LEDs blink for no apparent purpose? Why do we try to squeeze one extra frame out of our video cards? We don’t know why, but we do. That might be the same attitude most people would have when learning about esolangs — esoteric programming languages — we don’t know why people create them or use them, but they do.

We aren’t talking about mainstream languages that annoy people like Lisp, Forth, or VBA. We aren’t talking about older languages that seem cryptic today like APL or Prolog. We are talking about languages that are made to be… well… strange.

INTERCAL

We have to start at the beginning. INTERCAL. This was started as a joke in 1972 and the acronym is purportedly for Compiler Language With No Pronounceable Acronym. There was no actual implementation, though, until around 1990. Now there are two: C-INTERCAL and CLC-INTERCAL.

Since INTERCAL is a parody, it makes some very odd choices. For example, bitwise operators like AND operate with two arguments, but one of the arguments is reversed. That is, the top bit of one operand matches the bottom bit of the second operand. In a nod to social convention, there is a modifier known as PLEASE that you should sometimes use when, for example, reading data as in “PLEASE READ IN.” If you don’t use it often enough, the compile will fail warning you that the program is insufficiently polite. However, if you use it too often, you’ll also get an error that your program is excessively polite.

Originally, the implementation used EBCDIC, so it uses some characters that don’t appear on conventional 7-bit ASCII systems. This forced some character substitutions and now, with Unicode, some versions will allow the old-style characters if you prefer them. The INTERCAL manual renames nearly all the special characters for further confusion. A single quote is a “spark” and the equal sign is a “half-mesh”. Only the ampersand remains unscathed.

Want to know more? Be careful what you wish for.

Continue reading “Strange Computer Languages: A Hacker’s Field Guide”

Make Room For A New Arduino Competitor – With Native Brainf*ck!

With so many smaller and more capable microcontroller boards on the market it’s now fairly safe to say that the classic Arduino footprint and form factor is rather outdated. That’s not to say that there’s no fight left in the old contender though, and to prove it here’s a new platform in the familiar style set by the venerable Atmel-based board. [Eduardo Corpeño]’s Brainfuino is an Arduino competitor that runs everyone’s favourite esoteric programming language, Brainf*ck. (Keeping it SFW, folks.)

And in case you mistake it for a Brainf*ck emulator on a PCB then stand ready to be corrected, for this board runs the language natively in a Brainf*ck softcore on a Lattice MachXO2 FPGA. This is the real deal, on which only a true genius or masochist would dare to code.

The board itself is very neatly executed with a graphical style that presents more than a nod to the original Arduino. On this board is the FPGA, 256 kB ROM and 138 kB RAM, an STM32 to provide a USB serial port and an analogue input, and a level shifter to provide Arduino-style 5 V logic on the pins. We can see it’ll provide hours of fun to anyone interested in learning Brainf*ck, but besides that it has potential as an Arduino-shaped FPGA board. We like the joke, we like the graphical and engineering design, but underneath that lies quite the technical achievement.

Brainf*ck has made it to Hackaday before, not least in this jaw-dropping relay computer.

Because Building A Relay Computer Isn’t Hard Enough

For this year’s Hackaday Prize, we’re doing something special. We’re introducing achievements for Prize projects. Think of them as merit badges. If your Hackaday Prize project has multiple parts that come together into one unified, awesome whole, you get the Voltron achievement. If you’ve built a musical instrument that unexpectedly blows everyone’s minds, you get the Diva Plavalaguna Achievement. A select few entries will earn the Pickle Rick achievement. What’s this? It’s a jaw-dropping build that makes you shake your head in the totality of engineering perfection.

Here’s a project that nails this achievement. It’s a homebrew computer, made out of relays, that runs a custom instruction set. It’s built on Brainf*ck. It is, by far, the most absurd and amazing homebrew computer you’ve ever seen.

Several modules on a shelf, for scale.

First, the hardware. This CPU is built out of about 800 Soviet reed relays, RES64, RES55, and RES-43 relays, if you want some part numbers. These relays are mounted on logic cards connected to a backplane. Each backplane consists of thirty-two of these cards, and it takes two backplanes to build up a 16-bit full adder. The 16-bit instruction pointer and 16-bit address pointer each fit on half a backplane.

Moving up one level, the instruction set for this computer is based on Brainf*ck, with a few additions. The ‘+’ instruction adds to the current value, the ‘>’ instruction still increases the current memory address, but there are a few new instructions that make this CPU not an interminable world of suffering. There’s now a ‘write current data value to register’ commands, and logical XOR instructions.

Have relay-based computers been done before? Yes, and so have Brainf*ck ISAs. The combination is rarely seen, and we’ve never seen one that performs this well. Below, you can see a video of this computer counting at 500 operations per second (or 500 Hz from a frequency counter). This is really unimaginable with any other relay computer we’ve seen, and it’s all thanks to those really tiny Soviet tubes. If you want a Hackaday Prize project that’s jaw-dropping, here you go.

Continue reading “Because Building A Relay Computer Isn’t Hard Enough”

Hackaday Links: May 29, 2016

Hackaday has a store‽ Yes, it’s true, and we have a Memorial Day sale going on right now. Get a cool robot had t-shirt, a cool clock, or a GoodFET. Spend money. Consume.

[fbustamante] got his hands on an old GP2X Wiz, one of those ARM-based portable media player/emulator things from a few years ago. This is a complete computer, and like the Pandora, it’ll do everything one of those Raspberry Pi laptops can do. The Wiz doesn’t have a keyboard, so [fbustamante] created his own. He etched his own PC, repurposed a keyboard controller from a USB keyboard, and stole the keycaps from an old Sharp digital organizer.

Speaking of portable consoles, [Element18592] built this incredible Nintendo 64 portable. He’s done an XBox 360 laptop and stuffed a Pi into an old brick Game Boy. This N64 mod is great, uses a 3D printed enclosure, and has truly amazing vinyl graphics.

To the surprise of many, [Photonicinduction] is not dead. The drunk brit with a penchant for high voltage electrics and a very, very confused power company is back making videos again. His latest video is a puzzle. It’s a plastic block with a light bulb socket, a UK power outlet, and a switch. Plug in a light bulb, flip the switch, and it turns on. Plug a blender into the outlet, and that turns on too. No wires, so how is he doing it?

Introduced at CES last January, Monoprice – yes, the same place you get HDMI and Ethernet cables from – has released their $200 3D printer. This one is on our radar and there will be a review, but right away the specs are fantastic for a $200 printer. The build area is 120mm³, it has a heated bed, and appears to be not completely locked down like the DaVinci printers were a few years ago.

Genetic Algorithm Programmer Gets Functions

[Kory] has been writing genetic algorithms for a few months now. This in itself isn’t anything unique or exceptional, except for what he’s getting these genetic algorithms to do. [Kory] has been using genetic algorithms to write programs in Brainfuck. Yes, it’s a computer programming a computer. Be thankful Skynet is 18 years late.

When we first saw [Kory]’s work, he had programmed a computer to write and run its own programs in Brainfuck. Although the name of the language [Kory] chose could use some work, it’s actually the ideal language for computer-generated programs. With only eight commands, each consisting of a single character, it greatly reduces the overhead of what any genetic algorithm must produce and what a fitness function must evaluate.

There was one shortcoming to [Kory]’s initial efforts: functions. It’s relatively easy to get a program to say Hello World, but to do something complex, you’re going to need something like a macro or a function. Brainfuck, it its most simple form, doesn’t support functions. This throws a wrench in [Kory]’s plan to have his computer programming computer grow smarter and get over local minima in its genetic algorithms.

The solution to this problem was the creation of a new dialect of Brainfuck [Kory] calls BrainPlus. This takes the best parts of Extended Brainfuck and adds a command that basically serves as a break statement.

With this, [Kory]’s self programming computer can develop more complex programs. Already it has created a program to generate the first few numbers of the Fibonacci sequence. It only goes up to 233 because 255 is the maximum value for a byte, and the program itself took seven hours to generate. It does, however, work. Other programs generated with the new Brainplus functions include reciting 99 bottles on the wall and a program that multiples two values.

Even though [Kory]’s computer is spending a long time to generate these programs, given enough time, there’s really not much this program can’t do. Brainfuck, and [Kory]’s Brainplus, are Turing complete, so that given infinite memory and time it can compute anything. With the new addition of functions, it can compute anything faster.

All the code for [Kyle]’s GA is available on Github.

 

My First Brainf*ck

fuck

There was a time – not too long ago – that a ‘my first computer’ required the use of machine code and an understanding of binary. While an introduction to computers is now just how to put a Raspberry Pi image on an SD card, a few people are keeping the dream of memorizing opcodes alive. One such person is [Johan von Konow], creator of My First Brainfuck, an ultra small, low-cost programmable computer.

My First Brainfuck is an Arduino shield designed to have all the features of a normal computer, but without all those messy mnemonics that make assembly programming so easy. This computer is programmed in Brainfuck, a purposely obtuse programming language that, while being incredibly esoteric and difficult to program in, can be very, very rewarding.

[Johan] has a short tutorial showing how his computer works and how the Brainfuck language operates. There are only eight commands in Brainfuck, perfect for such a minimal user interface, but with enough patience, nearly anything can be written in this difficult language.

Right now there are a few examples showing how to play a scale on the on-board buzzer, displaying a Larson scanner on the LEDs, and a few more programs will be published in the future.

Interpreting Brainf*#k On An AVR

We won’t call it useless, but we will ask why [Dan] wrote a brainfuck interpreter for the AVR

It’s not generating code for the AVR; think of it more as a bootloader. To run a brainfuck program, [Dan] uploads it to the EEPROM inside his ATMega32, after which the microcontroller takes over and starts performing whatever instruction the brainfuck program tells it to do. Because the whole thing runs off the EEPROM, the code size is limited to 1022 bytes. Enough for any brainfuck program written by a human, we think.

As for why [Dan] would want an AVR to build an interpreter for a language that is nearly unreadable by humans, we honestly have no idea other than the common, ‘because it’s there’ sentiment. There are some pretty cool projects out there that use brainfuck, including this genetic algorithm software developer. Right now, though, blinkey LEDs are enough to keep us happy, so you can see a video of brainfuck doing its thing on a LED bar display after the break.

Continue reading “Interpreting Brainf*#k On An AVR”