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.
36 thoughts on “My First Brainf*ck”
I learned programming in 6502 machine language on a KIM-1 microcomputer in the mid ’70s. Not Asembler, actual machine language. Then learned high level languages and spent 13 years as a mainframe programmer. Low level languages can be very rewarding. You learn the mechanics of the processor. Arduino is an ideal bridge between a technical understanding of the operation of a processor and real world applications.
AVR’s bizarre architecture leaves little turds in your source code and encourages coding skills that are useless on any other processor. ARM is the natural successor to the 6502, its architecture is bog-standard, and a much better choice for the budding embedded developer.
Bizarre architecture? Please elaborate.
In my opinion the only “bizarre” thing are separate address spaces for ram and flash.
I had to program an AVR in machine code for a college course. I asked the professor that if, in order to save strings, I could put some bytes in the program memory and then point the stack pointer toward those bytes.
Apparently, program memory and RAM are addressed seperately.
This isn’t that uncommon in RISC processors, but I wouldn’t call AVR a RISC processor.
Why wouldn’t you call the AVR a RISC processor?
It is purely load and store, nearly all instructions are single cycle and there is no microcode. All very much RISC characteristics.
PIC24 is the same, with separate program and RAM memory. A bit disappointing, as I would have like to have played with self-modifying code and JIT compilation in RAM. Storing data in FLASH is also a bit inefficient, using only 16 bits of each 24 bit word by default due to the difference in data/program bus sizes; unless stored and accessed in a nonstraightfoward way. But otherwise it has not proven to be a limitation.
There are legitimate reasons to bash Arduino in my opinion. I have certainly done so on many occasions, and won’t do so again today. But I suspect [F] is just talking nonsense.
thats what printf_P and puts_P are for, all of the _P functions expect a pointer to flash, and use the LMP instruction to read it
This is known as “Harvard Architecture”. It has advantages, which are usually vastly outweighed by it’s disadvantages, so it’s almost never used any more. Von Neumann became the Plato of computer philsophy.
It does have some advantages when you want speed and performance out of smaller cheaper hardware. But mostly yeah it’s goddam ugly. Tho many real-world Harvard-arch chips have an instruction or two to read data from program memory, if not often the other way round. This is known as “Modified Harvard” it’s a sticking plaster over the main arse-pain.
AFAIK it’s other way around. Most of modern chips, including modern x86 processors and ARMv7 chips have modified Harvard architecture on the inside. With program and data memory being the instruction and data cache. On the other hand this is hidden from the user either by using microcode or some clever tricks with address space mapping. However the performance benefit is universal.
To continue, Arduino’s poor design decisions mean that it’s very easy to write bad code and very hard to write good code. It’s great for fun and games and getting “hello world” off the ground but it very quickly turns into a big boat anchor that will weigh down your project and prevent it from achieving quality. Arduino is a bridge to nowhere.
And let’s just ignore the thousands of cases that show otherwise. Right?
Sorry, but first you complain about the AVR architecture and now it’s the Arduino way of doing things. Which is it and specifically what is problematic?
“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.”
“…perfect for such a minimal user interface…”
I used to read the articles…
Now, I just read the headline, look at the pictures/videos, and read the comments. I click links that seem interesting and then I move on. It’s not that I don’t have the time, but that the articles are becoming more silly as time goes on. I read this one and I cringed.
Cool project, though and no personal offense meant towards anyone.
I’ve been wanting to say this for ages, but feared getting anti-trolled and run out of town with pitchforks and torches. Do what you will.
what are you here for? are you here to find ideas to steal? are you here for inspiration? do you like to see other people being creative? it’s not all about technology, it is also about the creative process, why people make the decisions they do, the balance between aesthetic and function. everyone has a different take and it’s fun to see what motivates people and how they apply the skills they have learned. it doesn’t matter so much whether the project is beer brewing or cutting metal or what.
*sigh* Isn’t it obvious? *sigh* He’s here to tell us how much better he is than everyone else. *sigh*
Baseless moaning is now the thing in the HaD comments I gather.
‘You know in the old days I went to HaD to get inspiration to cure cancer, now I just gaze at pictures and blank my mind and think about the youtube comments I can make blaming the jews for things’
‘Also they didn’t have all that hip-hop music that makes the kids crazy’
How am I doing?
Baseless moaning has been a HaD staple since I started following the site a few years ago.
I agree at least that drawing inference between memorizing real assembly opcodes, and a contrived and intentionally obfuscated language like Brainf*ck, is silly.
There is no real world advantage or utility to Brainf*ck. It’s strictly a self-imposed challenge. So is Sudoku. While I might engage in either activity to avoid boredom when avoiding productive tasks, and it does exercise the grey matter, it’s quite a stretch to call it “very, very rewarding”.
I think the Sudoku comparison is quite accurate! It is a self-imposed challenge that some people enjoy – while others consider it meaningless. It’s up to you to find out which category you belong to. However bf is not only a mental challenge, I think that you will also learn one or two things about programming and computers while playing with it.
If you belong to category 1, you might want to understand what this program does (it’s written for My First Brainfuck and outputs binary, not ascii)
I scrolled up to read what you have taken offense to, to read it in context. Hard to tell why you take offense. No grammar or spelling errors that I can see, but that doesn’t mean their are none. Do we need to assume you took offense at the message? Your none worry about running out of town leaves to the reader to wonder why you come to down in the first. Anyway no that you have broken your silence I home your tongue heals quickly.
I find this a little miss leading as an Electrical Engineer I am required to know how to program in opcode and if I ever want a job with NVIDA or other similar companies I need to know how to program in opcode.
Who is this “Little Miss Leading” you speak of?
Must be related to Saran Dippity
LOL ;) I’m fairly certain written communications skills are important for Engineers is general as well. We should give you the benefit of the doubt by assuming you where trip up up by a spellchecker, because anyone says they haven’t may be a liar. I’m guessing in response to the typo misleading, to clicked on the suggestion miss leading while in a hurry and in a hurry means only a cursory proof read. Been there done that… often.
Ah, I remember my first brainfuck, my ear was sore for a week! Anyhoo this looks like a great project for the kiddies.
I’m believe I’m still a virgin. That or it has happen so often, I now think it normal.
It’s called Brainfuck, not Brainf*ck.
Fuck you for self-censorship.
And fuck the censorship implied by criticizing self-censorship :) I wonder if now the terms have been used enough to have filters working overtime?
“Hey guys lets use profanity in the name of our product, it’s sure to be a hit!”
-Things an Electrical Engineer actually thought
Brainfuck’s sortof a joke language. I understand you could view it a really really simple machine code, with no number loading of any kind so relying on long chains of inc and dec to get any data in. Aren’t a lot of the few Brainfuck programs out there written with and by tools?
I suppose a more minimal machine code with fewer features might help people learn the concept. But for that the 6502 is pretty simple, with just it’s paging quirks. I think Z80 is another good one. Lots of instructions, but they’re fairly orthogonal, just a few simple operations on different registers in different address modes.
But no out-there wierdy ones like some of mainframes of the olden days, or the overhead of modern 32/64-bit CPUs that really need an OS to manage the chip itself and all it’s MMU / cache / virtualisation stuff. A lot of OS stuff seems like it’s dropped down into the chip itself, for performance, and to provide a use for the billion extra transistors.
I think either the 7-segment / hex-keypad systems of old, or something that runs through a terminal session, with either an assembler or a cross-assembler, would do a better job. Although what the job is, I’ve no idea!
“Brainfuck’s sortof a joke language.”
wasn’t c++ supposed to be a joke too?
From the success it’s had I’d think of it more as a prank.
I am interested in this idea as a toy to play around with from a programming perspective, but I have absolutely not background in electronics. Is there somewhere I could buy this instead of having to make it? I will do what I have to, but I would prefer not to build it, given that I would probably screw it up badly.
Understanding that low cost is relative, but is this the lowest cost solution to get where this shield goes? An Arduino is going to cost more than $30 after S/H. IMO products that include a programmed micro processor installed on an assembled version, or included in a kit. Even a need for a way to supply power should keep the cost lower. Christmas is coming. A nerdy girl on Shanta’s knee. What to you want for Christmas “young lady?”; I want a brainfuck Santa. I’m pretty sure that’s not going to be a letter to Santa our small rural weekly would be printing.
LOL, but I would like to see that ad!
Many people here misunderstood one thing: The Arduino is only used as a proof of concept. The whole project is designed so it can use an 8-pin microprocessor (ATtiny, pic or similar) running on a 3v coin cell. Then it will be extremely low cost, since only a few LEDs and switches are required. In fact I don’t think that you can find or build any programmable computer cheaper than that…
The Arduino proof of concept fulfills my need (now I know that it works). If more people find this interesting I can quite easily port the code to a tiny low cost platform. Let me know what you think!
has ANYone used the avr brainfuck interperter I wrote for anything?
you cant say you want to go hardcore and use an arduino to make a brainfuck computer, by all rights it should be AVR assembler code!
(ok mines C)
Please be kind and respectful to help make the comments section excellent. (Comment Policy)