Brain F**k in 100 Seconds | Prime Reacts:

Поделиться
HTML-код
  • Опубликовано: 20 сен 2024
  • 100 seconds of Brain F*** by non other than the GOAT himself, Fireship!
    GO SUB!!
    / @fireship
    Recorded live on twitch, GET IN
    / theprimeagen
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord

Комментарии • 228

  • @ThePrimeTimeagen
    @ThePrimeTimeagen  Год назад +305

    THE GOAT HIMSELF: www.youtube.com/@fireship
    GO SUB TO HIM

    • @duwangchew
      @duwangchew Год назад +9

      Too late, already subbed

    • @cthutu
      @cthutu Год назад +1

      BASIC reference?

  • @BrunodeSouzaLino
    @BrunodeSouzaLino Год назад +1328

    If he's impressed by the 107 byte compiler, someone wrote a Brainfuck interpreter in Brainfuck.

    • @BusinessWolf1
      @BusinessWolf1 Год назад +101

      w...hat?

    • @electricengine8407
      @electricengine8407 Год назад +134

      i did that, if you know the language and play around with it a ton to learn the concepts and patterns its actually not extremely difficult, i made my own interpreter and debugger

    • @grzzltn
      @grzzltn Год назад

      @@electricengine8407 github (or other place where code is) or didn't happen

    • @the-pink-hacker
      @the-pink-hacker Год назад +59

      Even BF is bootstrapped!? When will this end?

    • @Takyodor2
      @Takyodor2 11 месяцев назад +37

      ​@@the-pink-hacker The end is the beginning, as the universe is bootstrapped

  • @Impatient_Ape
    @Impatient_Ape Год назад +637

    Brainfuck is an example of a "Turing tarpit" language, where "everything is possible but nothing of interest is easy".

    • @denissorn
      @denissorn Год назад +51

      Everything is possible with assembly. Even RISC assembly is a lot easier than this insanity.

  • @headlights-go-up
    @headlights-go-up Год назад +631

    Your main channel will always be my favorite, but seeing your disbelief and wonder (i.e. at the recursive main) is contagious and hilarious.

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Год назад +119

      :)
      it was SOOO fun to see that

    • @khalilbessaad5553
      @khalilbessaad5553 Год назад +39

      I didn't even know this is the secondary channel. I thought that I was on the main channel, I just saw Prime and clicked

    • @aws-china
      @aws-china Год назад +3

      yeah it was definitely a W move to become active on the clips channel again

    • @CuriousAnonDev
      @CuriousAnonDev Год назад +2

      @@khalilbessaad5553 same🤣

    • @RenderingUser
      @RenderingUser Год назад +4

      Wait
      This wasn't the main channel?
      Bro i legit thought this guy only had about 50k subs

  • @dealloc
    @dealloc Год назад +158

    the syscall is for I/O where !b will be evaluated to an int from a bool so it will call 3 or 4 which corresponds to read and write, respectively.

  • @_imawesome
    @_imawesome Год назад +126

    Back in college I had come up with a project related to compilers, so I submitted a transpiler that translates Brainfuck to functioning C code. The whole class was impressed, but really it takes one to know how Brainfuck theoretically works to know how easy it really is. 😂

  • @WyzrdCat
    @WyzrdCat Год назад +92

    Anything more is just unnecessary bloat. Variables are crutches.

  • @Jaiden-2013
    @Jaiden-2013 4 месяца назад +11

    4:33 quick brown fox jumps over the lazy dog

  • @jfbarbosaboro
    @jfbarbosaboro Год назад +147

    Assembly was the first language I've learned. Then I started experimenting with C. I thought functions were just like labels in Assembly, and I used a recursive main in one of my beginner C codes. My teacher told me "just don't do that".

    • @AlLiberali
      @AlLiberali Год назад +29

      He was being very considerate

    • @aziemelzapratama5257
      @aziemelzapratama5257 Год назад +10

      How long are you in the industry?😅

    • @mynameisname6162
      @mynameisname6162 8 месяцев назад

      @@aziemelzapratama5257 op has seen dinosaurs

    • @Anubis1101
      @Anubis1101 3 месяца назад +8

      dont let them cramp your style, recursively call main all you want

  • @adambickford8720
    @adambickford8720 Год назад +221

    You can almost feel it moving a mechanical something inside your machine with every character. I bet i could hear it with a stethoscope on an HDD.

    • @e.zarate
      @e.zarate Год назад +7

      Gold comment

    • @Oaisus
      @Oaisus 9 месяцев назад +5

      It sure seems like someone could build a mechanical bf interpreter with punch card instructions

    • @tornoutlaw
      @tornoutlaw 9 месяцев назад

      Yeah...or slowly move an oszillograph along your RAM xD

  • @fosstera
    @fosstera 2 месяца назад +4

    A brilliant friend of mine programmed a mandelbrot set in brainfuck, showed me the code, and the compiler, and the resulting output
    it was an incredible thing to see

  • @seveninchbread
    @seveninchbread Год назад +11

    brainfuck is basically a slightly modified Turing machine. it's a good intro into computability and formal language theory

  • @MegaMech
    @MegaMech Год назад +14

    ChatGPT programmed a recursive main in C and I was like "Waaaaa?!?"

    • @SforSamPlays
      @SforSamPlays 22 дня назад +1

      Fun Fact:
      C allows main to be called within a program.
      But, as per the C++ spec, using main within a program (like calling main within main) is considered undefined behavior. “The function main shall not be used within a program" (C++11 §3.6.1/3)”

  • @huckleberryfinn8795
    @huckleberryfinn8795 Год назад +25

    Watching you get your mind blown as you read the code of a language named "brain f***" is HILARIOUS 😂

  • @alangamer50
    @alangamer50 Год назад +17

    Gotta love how Brainfuck is Turing complete, so you can technically build anything with it

  • @mateuscortianoschwarz7276
    @mateuscortianoschwarz7276 Год назад +31

    as turing intended lolol

  • @TheJobCompany
    @TheJobCompany Год назад +29

    ngl, the first time I saw a recursive main, my reaction wasn't any different than prime's; it's a powerful code obfuscation tactic

  • @cherubin7th
    @cherubin7th Год назад +6

    I moved from too complex to simple: Rust -> Zig -> Brain F**k

  • @spr3ez
    @spr3ez Год назад +40

    Saw on stream. Still watching since its so funny how mind blown you are ;)

  • @RTXMemes69
    @RTXMemes69 Год назад +11

    Only Prime can take a 2:09 minute video into over 5 minutes and still make it entertaining.

  • @Hobbitstomper
    @Hobbitstomper Год назад +20

    Yeah, create your own language where logic makes no sense, like
    null == 0; // -> false
    null > 0; // -> false
    null >= 0; // -> true
    A language like that would be a real brainf*ck. Oh wait...Hello JavaScript my old friend.

    • @raianmr2843
      @raianmr2843 Год назад +1

      LMAO

    • @theodorealenas3171
      @theodorealenas3171 Год назад +1

      Hey is it what I think it is? >= defaults to the opposite result to < and that's why?

    • @user-sl6gn1ss8p
      @user-sl6gn1ss8p Год назад

      @@theodorealenas3171 oh, is that it?

    • @theodorealenas3171
      @theodorealenas3171 Год назад +3

      @@user-sl6gn1ss8p I know Python does this, with operator overloading (but C++doesn't). If you overload what the < operator does, the >= operator will work accordingly.

    • @isodoubIet
      @isodoubIet Год назад

      @@theodorealenas3171 In C++20 you're supposed to overload spaceship so all the comparisons will work as intended

  • @vanminhle850
    @vanminhle850 Год назад +24

    Somehow he always found a way to shit on javascript and I love that.

  • @boi8240
    @boi8240 9 месяцев назад +4

    This is the world functional programmers want for our children.

    • @null-0x
      @null-0x 10 дней назад

      Brainfuck is not functional

  • @nickr753
    @nickr753 Год назад +7

    Your entire hard drive is a one-dimensional array of bytes. Or (galaxy brain) it’s a scalar unsigned integer with a maximum of 2^(drive size in bits).

    • @kibe2134
      @kibe2134 Год назад

      It can be signed if you start counting the index from 1

  • @alexandrosvangelatos9979
    @alexandrosvangelatos9979 Год назад +14

    My brain hurts... 🤯

  • @carlweis
    @carlweis Год назад +3

    Love your vides, always fun to watch. This was interesting for sure. BFJS sounds like a fun project for a live stream ;)

  • @AtRiskMedia
    @AtRiskMedia Год назад +1

    You, my friend, are a extra special kind of special. Appreciate you so much =D

  • @nic37ry
    @nic37ry Год назад +5

    A friend create a Linux binary interpreter with size of 380 bytes for brainf*ck :D

  • @brentsaner
    @brentsaner Месяц назад +1

    The design is very human

  • @mangotea9764
    @mangotea9764 Месяц назад

    I fucking replayed the part where you were so confused so many times.. i was just as confused and it was funny to see that i wasnt the only one 🤣

  • @RedOchsenbein
    @RedOchsenbein Год назад +10

    Actually BF make quite some sense when you use it to generate code using genetic algorithms. It's pretty easy to represent it as genes and mutate it to find solutions.

    • @CFEF44AB1399978B0011
      @CFEF44AB1399978B0011 6 месяцев назад +2

      If we scanned the human genome and used it to find valid brain fuck programs i wonder how many of them would actually output some fun strings. Like are there any randomly occurring words in the human genome?

  • @ThePouetman
    @ThePouetman Год назад +1

    The ai in brainfuck video by mitxela is my favorite video out of all the ones I've seen about esoteric languages

  • @spitefol5504
    @spitefol5504 Год назад +8

    Wow this new coding language is like rust without all the bloat

  • @wchorski
    @wchorski Год назад +4

    I hope Jeff recursively reacts to this video

  • @griffitaj
    @griffitaj Год назад +1

    Recursive main just blowing prime's mind #wholesome

  • @boahneelassmal
    @boahneelassmal 2 месяца назад

    23 seconds into the video and his brain was thoroughly fucked :'D

  • @m4rt_
    @m4rt_ Год назад +4

    1:03
    if !b does the same thing in C as in JS it would make it 0 if the number is non zero, and 1 if the number is zero, so 4 - 0 or 4 - 1 I think...

  • @nullbeyondo
    @nullbeyondo Год назад +2

    I'd just stick to machine code. It is much easier and a 0-byte compiler 🥴

  • @zachb1706
    @zachb1706 Год назад +1

    4:40 Windows PowerTools baby!

  • @CapnSlipp
    @CapnSlipp 6 месяцев назад

    2:15: _“Notice how Brainfuck^beep^ doesn't require silly things like…”_

  • @TheSkepticSkwerl
    @TheSkepticSkwerl Год назад

    from what i understand the loop to do. it increments or decrements a cell. once the cell hits zero the loop ends. you can move other values up and down as necessary. once value 0 becomes 0 your loop ends.

  • @HernanSoberon
    @HernanSoberon 3 месяца назад

    FINALY the code where regular expressions was created.

  • @hotrodhunk7389
    @hotrodhunk7389 Год назад +1

    That's awesome recursion is my favorite part of coding.

  • @PiereWoehl
    @PiereWoehl 24 дня назад

    3:08, if you minus zero you rollover to 255
    and thenn -5 +3 until you get back to 0 at that stage the increment operation happend 103 times wtf. :D

  • @keokawasaki7833
    @keokawasaki7833 Год назад +2

    It's gotta be "like && subscribe"

  • @patrickprucha5522
    @patrickprucha5522 3 месяца назад

    I guess in those days, memory was not like today and one had to be very very and very efficient. Today we have so much power, memory and space that we don't care that much on efficiency. Very cool anyway!!! Are you going to bite LOL!!!
    Cheers

  • @BudgiePanic
    @BudgiePanic 7 месяцев назад

    BF ray tracer implementation that outputs the rendered image as mono color byte array

  • @UnspeakableCreature
    @UnspeakableCreature 3 месяца назад

    I will wait till he discovers Malbolge.

  • @talideon
    @talideon 11 месяцев назад

    I wrote an interpreter for it back in college in ARM ASM, so mine came in at ~300B when assembled. Unfortunately, ARM machine code isn't super dense!

  • @xraptor94x
    @xraptor94x Год назад

    One of my first programming projects when i came back to programming was an Brainf**k interpreter written in C++ which i called Brainfluff.
    I think such interpreters are fun project to see how an very simplistic compiler works.
    I will rewrite it probably in a few days or so when i have less work.

  • @Joker22593
    @Joker22593 Год назад

    I wrote a BF interpreter once, and main recursion within a loop is the easiest way I found to code the [ and ] operators.

  • @frydac
    @frydac Год назад +1

    I wonder what (double precision) floating point division looks like in this language.. it would be quite the challenge

  • @wertrager
    @wertrager Год назад +1

    It's not recursive, it's the Y Combinator, therefore inductive over program

  • @TheOzumat
    @TheOzumat Год назад +2

    Just as Turing intended :`)

  • @jaredbecker3152
    @jaredbecker3152 Год назад

    The code there outputs "what a free t-shirt? be the first person to comment my encephalon hurts! "

  • @snarekeeper8053
    @snarekeeper8053 3 месяца назад

    Mitxela build a full tic-tac-toe ai in bf.
    Such a freaking mad man

  • @kreuner11
    @kreuner11 Год назад +3

    That's not a compiler that's an interpreter

  • @SammyForReal
    @SammyForReal 10 месяцев назад

    "I dont even know what four minus BANG B means" 😂

  • @Takyodor2
    @Takyodor2 11 месяцев назад

    On the topic of "recursive main", function-level try-catch works on "main" in C++, so if you place a call to main inside "catch" attached to main, your code is now un-crashable by pesky exceptions!
    For legal reasons, this should not be used in real code. I don't take responsibility for any consequences that may result from this practice. Try-catch safely.

  • @postelb8046
    @postelb8046 11 месяцев назад +1

    it is time to write js framework on brainfuck

  • @slawek0latka
    @slawek0latka 16 дней назад

    Every main (etc) is a recursive ;)

  • @modolief
    @modolief Год назад

    Primeagen: Please look at sectorlisp! Could you give us a deep dive on that one? I want to learn the metacircular evaluator, the computer science equivalent of Maxwell's Equations. And sectorlisp can set up the basic LISP machine in less than 512 bytes of 8088 machine code. That's a small compiler! Almost as tiny as bf.

  • @TheKahiron
    @TheKahiron 6 месяцев назад

    Played about some with Brain Fuck years ago. Still have a habbit of typing 'p' for '+', just from commenting code.

  • @totalmonkeyspeed260
    @totalmonkeyspeed260 Год назад +1

    I love the original, you add some nice spice and detail to it.❤️🙏 Could you do a Vim for Brainf**k brainf**k please?

  • @Ou8y2k2
    @Ou8y2k2 13 дней назад

    4:30 Type it in? What are we, cavemen? Take a screenshot, then use OCR to recognize the characters. Paste said characters in a bf online interpreter and you get "Like and subscribe to yo momma." jk, I'm too lazy to even do that.

  • @wysera1999
    @wysera1999 Год назад

    I just learn that some people made a brainfuck compiler in brainfuck

  • @basboerboom9328
    @basboerboom9328 10 месяцев назад

    It's a rick roll for sure. The last code

  • @sillymesilly
    @sillymesilly 2 месяца назад

    You can do recursive main in C.

  • @PiotrPavel
    @PiotrPavel 8 месяцев назад

    Advent of code in Brain F****.....next year

  • @MrFoulkes
    @MrFoulkes 4 месяца назад

    AWS shoulkd bring BF lambda SDK for next years April fools.

  • @mskiptr
    @mskiptr Год назад

    > recursive main!? what?!
    Just before, I watched the video that Haskell appeared in lol
    (main being recursive is pretty normal there. And it's not even a function…)

  • @omdevs
    @omdevs 9 месяцев назад

    Great video! also I just noticed are you sitting on an exercise ball?

  • @tordjarv3802
    @tordjarv3802 Год назад

    BrainF**k is not entirely useless. I recently saw a paper by some mathematicians showing an algorithm to factorize arbitrarily large integers asymptotically optimally (that is it has the same O(f(n)) as the most efficient classical factorizing algorithm, the could not show what that was, and finding the most efficient factorizing algorithm is still an open problem), and BF was a crucial part of that algorithm. Basically what they did was a BF program, execute one step in it, then create a second program, execute two steps in the fist program and one in the second one step and then create a third program (in every iteration each program executes twice as many steps as in the previous iteration), and so on until one of all the programs they created spits out the correct factorization of the large integer that was given (which is easy to check since multiplication is polynomial in the number of bits in the integer). They actually wrote a python program that did this, (it was excruciatingly slow, it took several days for it to factorize 4). The point is that Brainfuck is not completely useless.

    • @hereandnow3156
      @hereandnow3156 8 месяцев назад

      I wonder what made Brainfuck helpful for this problem vs using assembly?

    • @tordjarv3802
      @tordjarv3802 8 месяцев назад

      ​@@hereandnow3156 brainf**k is extremely simple to implement while most assembly languages are way more complicated. In a way brainf**k is a very simple form of assembly.

  • @gittawat6986
    @gittawat6986 Год назад

    The thumbnail is brilliant

  • @_orangutan
    @_orangutan Год назад +2

    This compiler is interesting, the only downside to it is the writing system/syntax. If you use a different syntax/writing system on this, then it might be usable. By writing system I mean Latin/Greek/Arabic. One thing I've had a big interest in is creating a writing system from scratch but I don't have the time to do so. Think Hangul and Mayan.

  • @shafaitahir4728
    @shafaitahir4728 Год назад +1

    chat GPT cant code in brainfug, what a shame.

  • @aerbon
    @aerbon Год назад

    i have seen a recursive main before. it works.

  • @forno_nicolas
    @forno_nicolas Год назад

    Fireship is so good

  • @TalesMarinho
    @TalesMarinho 11 месяцев назад

    This kind of video makes me want to quit programming then go open a bar

  • @michelfug
    @michelfug Год назад

    THE NAME is the Brainagen

  • @TheSkepticSkwerl
    @TheSkepticSkwerl Год назад +1

    the way he explained it, 5 decrements means 51 loops. how is 51*3 increments 103? Why is it not 153?

    • @robertwagner9014
      @robertwagner9014 Год назад +2

      He adds one first making it 1025 so it is 205 loops which results in 615 or 512 + 103.

  • @anthonysteinerv
    @anthonysteinerv 9 месяцев назад

    I did write a brainfuck interpreter lmao when I was experimenting with compilers.

  • @RicardoSansores
    @RicardoSansores Год назад

    I prefeer to program my systems with lolcode. No memory safety or fearless concurrency but lot o lols.

  • @SB-dd5hc
    @SB-dd5hc Год назад +1

    you should react to JSF*k

  • @deepakpatidar8462
    @deepakpatidar8462 Год назад

    But the real question is, can we write JavaScript compiler using brainfuck? 🤔

  • @bananprzydawka7129
    @bananprzydawka7129 Год назад +2

    has anyone figured out what the video end code does??

    • @user-sl6gn1ss8p
      @user-sl6gn1ss8p Год назад +1

      apparently it was "what a free t-shirt? be the first person to comment "my encephalon hurts!""
      (with the typo)

  • @WilcoVerhoef
    @WilcoVerhoef Год назад

    my encephalon hurts!

  • @fRutrn
    @fRutrn Год назад

    Doom in Brainf^&k when?

  • @amansetia8655
    @amansetia8655 Год назад +1

    can someone explain the loop code of how it got 103

    • @AndresTraks
      @AndresTraks Год назад +13

      The first cell is used as a counter for the loop and is set to 1. For each iteration of the loop, the counter is decremented by 5. Since a cell wraps around the maximum value of a byte (1 - 5 = 252), it takes 205 iterations for the counter to reach exactly 0, which is the exit condition of the loop. The second cell is used as the character value and is first set to 0. For each iteration of the loop, the character value is incremented by 3, which makes 205 * 3 = 615. But this cell also wraps around, so the final value is 615 modulo 256 = 103.

  • @DevRel1
    @DevRel1 Год назад

    This is so exciting

  • @officialabdulrehman
    @officialabdulrehman Год назад +12

    Still better than *JavaScript*

    • @daedalus5070
      @daedalus5070 Год назад +2

      His Javascript for the Haters video is really funny.

  • @PhilipPlunk-n9i
    @PhilipPlunk-n9i 6 дней назад

    Anderson Mary Williams Patricia Clark George

  • @marble_wraith
    @marble_wraith Год назад

    Recursive main... still better than JS event loop 😏

  • @ayhon
    @ayhon Год назад +5

    I prefer JSF*CK, it's more portable

  • @sasso_storto4671
    @sasso_storto4671 Год назад

    JSFuck DOES EXIST!

  • @Merssedes
    @Merssedes 5 месяцев назад

    There is actual language called JSFuck.

  • @neth007
    @neth007 Год назад

    you just need a transpiler from javacript to brainf*ck

  • @brssnkl
    @brssnkl 6 месяцев назад

    Skill issue for all of us :D

  • @TheMultiGuess
    @TheMultiGuess 21 день назад

    Is it memory-safe or should we keep using Rust?

  • @spuzzdawg
    @spuzzdawg Год назад

    Comment without any thought: Is main recursive because it's a recursive descent parser?